|
From: <caw...@us...> - 2007-03-15 15:51:01
|
Revision: 2180
http://svn.sourceforge.net/rubyeclipse/?rev=2180&view=rev
Author: cawilliams
Date: 2007-03-15 08:50:40 -0700 (Thu, 15 Mar 2007)
Log Message:
-----------
handle syntax coloring for symbols better now...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-15 14:41:39 UTC (rev 2179)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-15 15:50:40 UTC (rev 2180)
@@ -43,6 +43,7 @@
private int oldOffset;
private boolean isInRegexp;
private boolean isInString;
+ private boolean isInSymbol;
private RubyParserResult result;
private int origOffset;
private int origLength;
@@ -51,7 +52,6 @@
private IToken fSavedToken = null;
private int fSavedLength = -1;
private int fSavedOffset = -1;
-
private boolean lastWasComment;
public RubyTokenScanner(IColorManager manager, IPreferenceStore store) {
@@ -112,11 +112,8 @@
CommentNode comment;
while (!comments.isEmpty()) {
comment = (CommentNode) comments.remove(0);
- // Grab comment and add it's length to our running tally
tokenLength += comment.getContent().length() + 1;
}
- // FIXME What if we have two lines of comments in a row?
-// tokenLength = comment.getContent().length() + 1;
fSavedToken = returnValue;
fSavedOffset = oldOffset + tokenLength;
if (!isEOF) fSavedLength = getOffset() - fSavedOffset;
@@ -145,6 +142,8 @@
@Override
public Token getToken(String key) {
+ if (isInSymbol)
+ return super.getToken(IRubyColorConstants.RUBY_SYMBOL);
if (isInRegexp)
return super.getToken(IRubyColorConstants.RUBY_REGEXP);
if (isInString)
@@ -153,10 +152,26 @@
}
private IToken token(int i) {
+ if (isInSymbol) {
+ if ((i == Tokens.tAREF) || (i == Tokens.tASET) || (i == Tokens.tIDENTIFIER)
+ || (i == Tokens.tIVAR) || (i == Tokens.tCVAR) || (i == Tokens.tMINUS)
+ || (i == Tokens.tPLUS) || (i == Tokens.tPIPE) || (i == Tokens.tCARET)
+ || (i == Tokens.tLT) || (i == Tokens.tGT) || (i == Tokens.tAMPER)
+ || (i == Tokens.tSTAR2) || (i == Tokens.tDIVIDE) || (i == Tokens.tPERCENT)
+ || (i == Tokens.tBACK_REF2) || (i == Tokens.tTILDE)) {
+ isInSymbol = false;
+ return getToken(IRubyColorConstants.RUBY_SYMBOL);
+ }
+ if (i == Tokens.tASSOC || i == 44 /* ',' */) {
+ isInSymbol = false;
+ return getToken(IRubyColorConstants.RUBY_DEFAULT);
+ }
+ }
if (i >= 257 && i <= 303)
return getToken(IRubyColorConstants.RUBY_KEYWORD);
switch (i) {
case Tokens.tSYMBEG:
+ isInSymbol = true;
return getToken(IRubyColorConstants.RUBY_SYMBOL);
case Tokens.tGVAR:
return getToken(IRubyColorConstants.RUBY_GLOBAL);
@@ -199,6 +214,7 @@
if (offset == 0) {
isInRegexp = false;
isInString = false;
+ isInSymbol = false;
}
try {
contents = document.get(offset, length);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|