|
From: Christopher W. <caw...@us...> - 2006-01-27 16:28:12
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28338/src/org/rubypeople/rdt/internal/ui/text Modified Files: HereDocPatternRule.java IRubyColorConstants.java Log Message: Add support for coloring global variables and instance/class variables uniquely Index: IRubyColorConstants.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/IRubyColorConstants.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IRubyColorConstants.java 2 Dec 2005 16:18:11 -0000 1.6 --- IRubyColorConstants.java 27 Jan 2006 16:27:55 -0000 1.7 *************** *** 11,14 **** --- 11,16 ---- public static final String RUBY_CHARACTER = RUBY_COLOR_PREFIX + "character"; public static final String RUBY_SYMBOL = RUBY_COLOR_PREFIX + "symbol"; + public static final String RUBY_INSTANCE_VARIABLE = RUBY_COLOR_PREFIX + "instance_variable"; + public static final String RUBY_GLOBAL = RUBY_COLOR_PREFIX + "global"; public static final String RUBY_MULTI_LINE_COMMENT = RUBY_COLOR_PREFIX + "multiline_comment"; *************** *** 16,20 **** public static final String TASK_TAG = RUBY_COLOR_PREFIX + "task"; ! public static final String RUBY_CONTENT_ASSISTANT_BACKGROUND = RUBY_COLOR_PREFIX + "content_assistant_background"; } --- 18,22 ---- public static final String TASK_TAG = RUBY_COLOR_PREFIX + "task"; ! public static final String RUBY_CONTENT_ASSISTANT_BACKGROUND = RUBY_COLOR_PREFIX + "content_assistant_background"; } Index: HereDocPatternRule.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/HereDocPatternRule.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HereDocPatternRule.java 3 Oct 2005 11:31:34 -0000 1.2 --- HereDocPatternRule.java 27 Jan 2006 16:27:55 -0000 1.3 *************** *** 3,63 **** import org.eclipse.jface.text.rules.ICharacterScanner; import org.eclipse.jface.text.rules.IToken; ! public class HereDocPatternRule extends org.eclipse.jface.text.rules.PatternRule { ! public HereDocPatternRule(IToken token) { ! // TODO: escape char OK? ! super("<<", "", token, (char)-1, false, false); ! } ! ! protected boolean endSequenceDetected(ICharacterScanner scanner) { ! ! char firstChar = (char) scanner.read() ; ! ! if (Character.isWhitespace(firstChar)) { ! return false ; ! } ! ! if (firstChar == '-') { ! firstChar = (char) scanner.read() ; ! } ! boolean isQuoted = false ; ! char quote = ' ' ; ! if (firstChar == '\'' || firstChar == '"') { ! isQuoted = true ; ! quote = firstChar ; ! firstChar = (char) scanner.read() ; ! } ! String keyword = "" ; ! char c = firstChar ; ! do { ! if ((byte) c == ICharacterScanner.EOF || Character.isWhitespace(c)) { ! break ; ! } ! keyword += c ; ! c = (char) scanner.read() ; ! } while ( true ) ; ! if (keyword.length() == 0) { ! return false ; ! } ! if (isQuoted && !(keyword.charAt(keyword.length() -1) == quote) ) { ! return false ; ! } ! if (isQuoted) { ! fEndSequence = keyword.substring(0, keyword.length() - 1).toCharArray() ; ! } ! else { ! fEndSequence = keyword.toCharArray() ; ! } ! boolean result = super.endSequenceDetected(scanner) ; ! if (!result) { ! return false ; ! } ! // the keyword must be at the beginning of the line ! return scanner.getColumn() == fEndSequence.length ; ! } } --- 3,60 ---- import org.eclipse.jface.text.rules.ICharacterScanner; import org.eclipse.jface.text.rules.IToken; + import org.eclipse.jface.text.rules.PatternRule; + public class HereDocPatternRule extends PatternRule { + public HereDocPatternRule(IToken token) { + // TODO: escape char OK? + // FIXME We need to only handle exact cases, not <<= + + // Correct cases: + // (http://www.zenspider.com/Languages/Ruby/QuickRef.html#8) + // <<identifier - interpolated, goes until identifier + // <<"identifier" - same thing + // <<'identifier' - no interpolation + // <<-identifier - you can indent the identifier by using "-" in front + super("<<", "", token, (char) -1, false, false); + } ! protected boolean endSequenceDetected(ICharacterScanner scanner) { ! char firstChar = (char) scanner.read(); ! if (Character.isWhitespace(firstChar)) { return false; } ! ! if (firstChar == '-') { ! firstChar = (char) scanner.read(); ! } ! boolean isQuoted = false; ! char quote = ' '; ! if (firstChar == '\'' || firstChar == '"') { ! isQuoted = true; ! quote = firstChar; ! firstChar = (char) scanner.read(); ! } ! String keyword = ""; ! char c = firstChar; ! do { ! if ((byte) c == ICharacterScanner.EOF || Character.isWhitespace(c)) { ! break; ! } ! keyword += c; ! c = (char) scanner.read(); ! } while (true); ! if (keyword.length() == 0) { return false; } ! if (isQuoted && !(keyword.charAt(keyword.length() - 1) == quote)) { return false; } ! if (isQuoted) { ! fEndSequence = keyword.substring(0, keyword.length() - 1).toCharArray(); ! } else { ! fEndSequence = keyword.toCharArray(); ! } ! boolean result = super.endSequenceDetected(scanner); ! if (!result) { return false; } ! // the keyword must be at the beginning of the line ! return scanner.getColumn() == fEndSequence.length; ! } } |