Java Code Examples for org.eclipse.jface.text.rules.ICharacterScanner#EOF
The following examples show how to use
org.eclipse.jface.text.rules.ICharacterScanner#EOF .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoScanner.java From goclipse with Eclipse Public License 1.0 | 6 votes |
@Override public IToken evaluate(ICharacterScanner scanner) { int read = scanner.read(); if(read == ICharacterScanner.EOF) { return Token.UNDEFINED; } switch (read) { case ':': case ';': case '.': case '(': case ')': case '[': case ']': case '{': case '}': return getSuccessToken(); default: scanner.unread(); return Token.UNDEFINED; } }
Example 2
Source File: JsniScanner.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@Override protected boolean endSequenceDetected(ICharacterScanner scanner) { int c = 0, readCount = 1; while ((c = scanner.read()) != ICharacterScanner.EOF) { if (!isValidJavaRefCharacter((char) c)) { scanner.unread(); return true; } readCount++; } while (--readCount > 0) { scanner.unread(); } return super.endSequenceDetected(scanner); }
Example 3
Source File: CaseInsensitiveMultiLineRule.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
@Override protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) { for (int i= 1; i < sequence.length; i++) { int c= scanner.read(); if (c == ICharacterScanner.EOF && eofAllowed) { return true; } else if (Character.toLowerCase(c) != Character.toLowerCase(sequence[i])) { // Non-matching character detected, rewind the scanner back to the start. // Do not unread the first character. scanner.unread(); for (int j= i-1; j > 0; j--) scanner.unread(); return false; } } return true; }
Example 4
Source File: JavaCodeScanner.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private boolean readInterface(ICharacterScanner scanner) { int ch= scanner.read(); int i= 0; while (i < INTERFACE.length() && INTERFACE.charAt(i) == ch) { i++; ch= scanner.read(); } if (i < INTERFACE.length()) return false; if (fWordDetector.isWordPart((char) ch)) return false; if (ch != ICharacterScanner.EOF) scanner.unread(); return true; }
Example 5
Source File: DocTypeRule.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
protected boolean endSequenceDetected(ICharacterScanner scanner) { int c; while ((c = scanner.read()) != ICharacterScanner.EOF) { if (c == fEscapeCharacter) { // Skip the escaped character. scanner.read(); } else if (c == '<') { fEmbeddedStart++; } else if (c == '>') { if (fEmbeddedStart == 0) { return true; } fEmbeddedStart--; } } return true; }
Example 6
Source File: SuffixedWordRule.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
public IToken evaluate(ICharacterScanner scanner) { int c = scanner.read(); if ((c != ICharacterScanner.EOF) && wordDetector.isWordStart((char)c)) { readLength = 1; do { c = scanner.read(); readLength++; } while ((c != ICharacterScanner.EOF) && wordDetector.isWordPart((char)c)); if (c == endCharacter) { return successToken; } while (readLength > 1) { readLength--; scanner.unread(); } } scanner.unread(); return Token.UNDEFINED; }
Example 7
Source File: FullPatternRule_Test.java From goclipse with Eclipse Public License 1.0 | 6 votes |
protected void runRuleTest(String text, Integer[] tokenIndexes, Integer[] tokenLen) { StringCharacterScanner scanner = new StringCharacterScanner(text); FullPatternRule fpRule = new FullPatternRule(new Token(null), sequences, new SampleJavaWordDetector()); while (scanner.peekNext() != ICharacterScanner.EOF) { int beginOffset = scanner.textOffset; IToken token = fpRule.evaluate(scanner); if(token.isUndefined()) { assertTrue(scanner.textOffset == beginOffset); assertTrue(ArrayUtil.contains(tokenIndexes, beginOffset) == false); scanner.read(); // advance } else { int indexOf = ArrayUtil.indexOf(tokenIndexes, beginOffset); assertTrue(indexOf != -1); assertTrue(scanner.textOffset == beginOffset + tokenLen[indexOf]); } } }
Example 8
Source File: MultiSuffixedWordRule.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
public IToken evaluate(ICharacterScanner scanner) { int c = scanner.read(); if ((c != ICharacterScanner.EOF) && wordDetector.isWordStart((char)c)) { readLength = 1; do { c = scanner.read(); readLength++; } while ((c != ICharacterScanner.EOF) && wordDetector.isWordPart((char)c)); for (char ch: endCharacters) { if (c == ch) { return successToken; } } while (readLength > 1) { readLength--; scanner.unread(); } } scanner.unread(); return Token.UNDEFINED; }
Example 9
Source File: JavaRegExpRule.java From LogViewer with Eclipse Public License 2.0 | 5 votes |
private String returnNextCompleteLine(ICharacterScanner scanner) { char[][] lineDelimiters= scanner.getLegalLineDelimiters(); int c; StringBuffer buffer = new StringBuffer(); while((c = scanner.read()) != ICharacterScanner.EOF) { if(isEOLCharacter(c,lineDelimiters)) { return buffer.toString(); } buffer.append((char)c); } return null; }
Example 10
Source File: XMLTextPredicateRule.java From http4e with Apache License 2.0 | 5 votes |
public IToken evaluate( ICharacterScanner scanner){ reinit(); int c = 0; // carry on reading until we find a bad char // int chars = 0; while (isOK(c = read(scanner), scanner)) { // add character to buffer if (c == ICharacterScanner.EOF) { return Token.UNDEFINED; } whiteSpaceOnly = whiteSpaceOnly && (Character.isWhitespace((char) c)); } unread(scanner); // if we have only read whitespace characters, go back to where evaluation // started and return undefined token if (whiteSpaceOnly) { rewind(scanner, charsRead); return Token.UNDEFINED; } return token; }
Example 11
Source File: CollectingCharacterScanner.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public int read() { int c = baseCharacterScanner.read(); if (c != ICharacterScanner.EOF) { contents.append((char)c); } return c; }
Example 12
Source File: CharSetRule.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public IToken evaluate(ICharacterScanner scanner) { int c = scanner.read(); if (charSet.contains((char)c)) { do { c = scanner.read(); } while ((c != ICharacterScanner.EOF) && charSet.contains((char)c)); scanner.unread(); return successToken; } scanner.unread(); return Token.UNDEFINED; }
Example 13
Source File: TexEnvironmentRule.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * Returns whether the end sequence was detected. * * * @param scanner the character scanner to be used * @return <code>true</code> if the end sequence has been detected */ protected boolean endSequenceDetected(ICharacterScanner scanner) { int c; int readChar = 1; while ((c = scanner.read()) != ICharacterScanner.EOF) { readChar++; if (fEndSequence.length > 0 && c == fEndSequence[0]) { // Check if the specified end sequence has been found. if (sequenceDetected(scanner, fEndSequence)) return true; } } unReadScanner(scanner, readChar); return false; }
Example 14
Source File: FastLaTeXPartitionScanner.java From texlipse with Eclipse Public License 1.0 | 5 votes |
private IToken scanBracket(int openChar, int closeChar, int type, int currentOffset) { int ch; int offsetEnd = currentOffset; int stack = 0; while (true) { ch = fScanner.read(); offsetEnd++; if (ch == closeChar) { stack--; if (stack < 0) { fTokenLength = offsetEnd - fTokenOffset; return fTokens[type]; } } else if (ch == openChar) { stack++; } else if (ch == '%') { offsetEnd += ignoreComment(); } else if (ch == '\\') { ch = fScanner.read(); offsetEnd++; } else if (ch == ICharacterScanner.EOF) { fTokenLength = offsetEnd - fTokenOffset - 1; return fTokens[type]; } } }
Example 15
Source File: JakartaRegExpRule.java From LogViewer with Eclipse Public License 2.0 | 5 votes |
private String returnNextCompleteLine(ICharacterScanner scanner) { char[][] lineDelimiters= scanner.getLegalLineDelimiters(); int c; StringBuffer buffer = new StringBuffer(); while((c = scanner.read()) != ICharacterScanner.EOF) { if(isEOLCharacter(c,lineDelimiters)) { return buffer.toString(); } buffer.append((char)c); } return null; }
Example 16
Source File: GoScanner.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public IToken evaluate(ICharacterScanner scanner) { int read = scanner.read(); if(read == ICharacterScanner.EOF) { return Token.UNDEFINED; } switch (read) { case '+': return currentOr('=', '+', scanner); case '-': return currentOr('=', '-', scanner); case '*': return currentOr('=', scanner); case '/': return currentOr('=', scanner); case '^': return currentOr('=', scanner); case '!': return currentOr('=', scanner); case '=': return currentOr('=', scanner); case '%': return currentOr('=', scanner); case '|': return currentOr('=', '|', scanner); case '&': if(consume('^', scanner)) { return currentOr('=', scanner); } return currentOr('=', '&', scanner); case '<': if(consume('<', scanner)) { return currentOr('=', scanner); } return currentOr('=', '-', scanner); case '>': if(consume('>', scanner)) { return currentOr('=', scanner); // ">>" , ">>=" } return currentOr('=', scanner); case ':': if(consume('=', scanner)) { return getSuccessToken(); // ":=" } // fall-through default: scanner.unread(); return Token.UNDEFINED; } }
Example 17
Source File: FastLaTeXPartitionScanner.java From texlipse with Eclipse Public License 1.0 | 4 votes |
private IToken checkForTikz() { boolean single = true; int offsetEnd = fTokenOffset + 2; int o = checkForCommand(TIKZCOMMAND, 1); if (o > 0) { offsetEnd += o; int ob = checkForCommand(TIKZPICTURE_BEGIN, 4); if (ob > 0) { single = false; offsetEnd += ob; } } else { fTokenLength += 2; return fTokens[TEX]; } int ch = fScanner.read(); offsetEnd++; // Skip optional arguments at beginning of environment if (ch == '[') { boolean skip = true; while (skip) { ch = fScanner.read(); offsetEnd++; if (ch == '\\') { ch = fScanner.read(); offsetEnd++; } else if (ch == ']') { ch = fScanner.read(); offsetEnd++; skip = false; } else if (ch == '%') { offsetEnd += ignoreComment(); } else if (ch == ICharacterScanner.EOF) { // Something got screwed up when setting optional arguments // for the environment - mark everything as plain latex fTokenLength = offsetEnd - fTokenOffset - 1; return fTokens[TEX]; } } } while (true) { ch = fScanner.read(); offsetEnd++; if (single && ch == ';') { fTokenLength = offsetEnd - fTokenOffset; return fTokens[TIKZPIC]; } else if (ch == '%') { offsetEnd += ignoreComment(); } else if (ch == '\\') { ch = fScanner.read(); offsetEnd++; if (!single && ch == 'e') { o = checkForCommand(TIKZPICTURE_END, 1); if (o > 0) { fTokenLength = offsetEnd + o - fTokenOffset; return fTokens[TIKZPIC]; } } } else if (ch == ICharacterScanner.EOF) { fTokenLength = offsetEnd - fTokenOffset - 1; return fTokens[TIKZPIC]; } } }
Example 18
Source File: SQLKeywordRule.java From birt with Eclipse Public License 1.0 | 4 votes |
public IToken evaluate( ICharacterScanner scanner, boolean resume ) { int column = scanner.getColumn( ); int iCh = ' ';//Default it to space. This will be checked if the column // is zero //First check whether we are at the first column if ( column > 0 ) { //if not unread and read the character scanner.unread( ); iCh = scanner.read( ); } IToken tokenToReturn = Token.UNDEFINED; buf.setLength( 0 ); //We should only apply this rule if we have a valid preceding character if ( isValidPrecedingCharacter( iCh ) ) { do { //Read the character iCh = scanner.read( ); //append it to the buffer buf.append( Character.toLowerCase( (char) iCh ) ); } while ( isKeywordStart( buf.toString( ) ) && iCh != ICharacterScanner.EOF ); } //Check whether there is anything in the buffer if ( buf.length( ) > 0 ) { //System.out.println("buffer contains " + buf.toString()); //Check whether the last character read was the EOF character //or a space character if ( isValidTerminatingCharacter( iCh ) ) { //If the length of the buffer is greater than 1 if ( buf.length( ) > 1 ) { //Strip out the last character String sToCompare = buf.substring( 0, buf.length( ) - 1 ); //System.out.println("String is " + sToCompare); //Now check whether it is a keyword if ( isKeyword( sToCompare ) ) { scanner.unread( ); tokenToReturn = token; } } } if ( tokenToReturn.isUndefined( ) ) { //if the token is undefined //then just unread the buffer unreadBuffer( scanner ); } } return tokenToReturn; }
Example 19
Source File: FullPatternRule_Test.java From goclipse with Eclipse Public License 1.0 | 4 votes |
@Override public boolean isWordPart(char ch) { return Character.isJavaIdentifierPart(ch) || ch == (char) ICharacterScanner.EOF; }
Example 20
Source File: JavaCodeScanner.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public int read() { int ch= fDelegate.read(); if (ch != ICharacterScanner.EOF) fReadCount++; return ch; }