public IToken evaluate(ICharacterScanner scanner, CombinedWordRule.CharacterBuffer word) { IToken token= super.evaluate(scanner, word); if (fIsVersionMatch || token.isUndefined()) return token; return fDefaultToken; } }
/** * Returns a content type encoded in the given token. If the token's * data is not <code>null</code> and a string it is assumed that * it is the encoded content type. * * @param token the token whose content type is to be determined * @return the token's content type */ protected String getTokenContentType(IToken token) { Object data= token.getData(); if (data instanceof String) return (String) data; return null; }
rule= (IPredicateRule) fRules[i]; token= rule.getSuccessToken(); if (fContentType.equals(token.getData())) { token= rule.evaluate(this, resume); if (!token.isUndefined()) { fContentType= null; return token;
public void createPresentation(TextPresentation presentation, ITypedRegion region) { int start= region.getOffset(); int length= 0; boolean firstToken= true; TextAttribute attribute = getTokenTextAttribute(Token.UNDEFINED); scanner.setRange(document,start,region.getLength()); while (true) { IToken resultToken = scanner.nextToken(); if (resultToken.isEOF()) { break; } if(resultToken.equals(Token.UNDEFINED)) { continue; } if (!firstToken) { addRange(presentation,start,length,attribute,true); } firstToken = false; attribute = getTokenTextAttribute(resultToken); start = scanner.getTokenOffset(); length = scanner.getTokenLength(); } addRange(presentation,start,length,attribute,true); }
rule= (IPredicateRule) fRules[i]; token= rule.getSuccessToken(); if (fContentType.equals(token.getData())) { token= rule.evaluate(this, resume); if (!token.isUndefined()) { fContentType= null; return token;
/** * Performs the initial partitioning of the partitioner's document. */ protected void initialize() { fScanner.setRange(fDocument, 0, fDocument.getLength()); try { IToken token= fScanner.nextToken(); while (!token.isEOF()) { String contentType= getTokenContentType(token); if (isSupportedContentType(contentType)) { TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType); fDocument.addPosition(fPositionCategory, p); } token= fScanner.nextToken(); } } catch (BadLocationException x) { // cannot happen as offsets come from scanner } catch (BadPositionCategoryException x) { // cannot happen if document has been connected before } }
@Override public IToken evaluate(ICharacterScanner scanner, CombinedWordRule.CharacterBuffer word) { IToken token= super.evaluate(scanner, word); if (fIsVersionMatch || token.isUndefined()) return token; return fDefaultToken; } }
rule= (IPredicateRule) fRule; token= rule.getSuccessToken(); if (fContentType.equals(token.getData())) { token= rule.evaluate(this, resume); if (!token.isUndefined()) { fContentType= null; return token;
/** * Performs the initial partitioning of the partitioner's document. */ protected void initialize() { fScanner.setRange(fDocument, 0, fDocument.getLength()); try { IToken token= fScanner.nextToken(); while (!token.isEOF()) { String contentType= getTokenContentType(token); if (isSupportedContentType(contentType)) { TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType); fDocument.addPosition(fPositionCategory, p); } token= fScanner.nextToken(); } } catch (BadLocationException x) { // cannot happen as offsets come from scanner } catch (BadPositionCategoryException x) { // cannot happen if document has been connected before } }
/** * Returns a content type encoded in the given token. If the token's * data is not <code>null</code> and a string it is assumed that * it is the encoded content type. * * @param token the token whose content type is to be determined * @return the token's content type */ protected String getTokenContentType(IToken token) { Object data= token.getData(); if (data instanceof String) return (String) data; return null; }
public IToken evaluate(ICharacterScanner scanner, CombinedWordRule.CharacterBuffer word) { IToken token= super.evaluate(scanner, word); if (fIsVersionMatch || token.isUndefined()) return token; return fDefaultToken; } }
rule= (IPredicateRule) fRules[i]; token= rule.getSuccessToken(); if (fContentType.equals(token.getData())) { token= rule.evaluate(this, resume); if (!token.isUndefined()) { fContentType= null; return token;
/** * Performs the initial partitioning of the partitioner's document. */ protected void initialize() { fIsInitialized= true; fScanner.setRange(fDocument, 0, fDocument.getLength()); try { IToken token= fScanner.nextToken(); while (!token.isEOF()) { String contentType= getTokenContentType(token); if (isSupportedContentType(contentType)) { TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType); fDocument.addPosition(fPositionCategory, p); } token= fScanner.nextToken(); } } catch (BadLocationException x) { // cannot happen as offsets come from scanner } catch (BadPositionCategoryException x) { // cannot happen if document has been connected before } }
/** * Returns a content type encoded in the given token. If the token's * data is not <code>null</code> and a string it is assumed that * it is the encoded content type. * * @param token the token whose content type is to be determined * @return the token's content type */ protected String getTokenContentType(IToken token) { Object data= token.getData(); if (data instanceof String) return (String) data; return null; }
@Override public IToken evaluate(ICharacterScanner scanner, CombinedWordRule.CharacterBuffer word) { IToken token= super.evaluate(scanner, word); if (fIsVersionMatch || token.isUndefined()) return token; return fDefaultToken; } }
/** * Performs the initial partitioning of the partitioner's document. */ protected void initialize() { fIsInitialized= true; fScanner.setRange(fDocument, 0, fDocument.getLength()); try { IToken token= fScanner.nextToken(); while (!token.isEOF()) { String contentType= getTokenContentType(token); if (isSupportedContentType(contentType)) { TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType); fDocument.addPosition(fPositionCategory, p); } token= fScanner.nextToken(); } } catch (BadLocationException x) { // cannot happen as offsets come from scanner } catch (BadPositionCategoryException x) { // cannot happen if document has been connected before } }
/** * Returns a content type encoded in the given token. If the token's * data is not <code>null</code> and a string it is assumed that * it is the encoded content type. * * @param token the token whose content type is to be determined * @return the token's content type */ protected String getTokenContentType(IToken token) { Object data= token.getData(); if (data instanceof String) return (String) data; return null; }
public IToken nextToken() { fTokenOffset= fOffset; fColumn= UNDEFINED; if (fRules != null) { for (int i= 0; i < fRules.length; i++) { IToken token= (fRules[i].evaluate(this)); if (!token.isUndefined()) return token; } } if (read() == EOF) return Token.EOF; return fDefaultReturnToken; }
/** * Performs the initial partitioning of the partitioner's document. * <p> * May be extended by subclasses. * </p> */ protected void initialize() { fIsInitialized= true; clearPositionCache(); fScanner.setRange(fDocument, 0, fDocument.getLength()); try { IToken token= fScanner.nextToken(); while (!token.isEOF()) { String contentType= getTokenContentType(token); if (isSupportedContentType(contentType)) { TypedPosition p= new TypedPosition(fScanner.getTokenOffset(), fScanner.getTokenLength(), contentType); fDocument.addPosition(fPositionCategory, p); } token= fScanner.nextToken(); } } catch (BadLocationException x) { // cannot happen as offsets come from scanner } catch (BadPositionCategoryException x) { // cannot happen if document has been connected before } }
/** * Returns a text attribute encoded in the given token. If the token's * data is not <code>null</code> and a text attribute it is assumed that * it is the encoded text attribute. It returns the default text attribute * if there is no encoded text attribute found. * * @param token the token whose text attribute is to be determined * @return the token's text attribute */ protected TextAttribute getTokenTextAttribute(IToken token) { Object data= token.getData(); if (data instanceof TextAttribute) return (TextAttribute) data; return fDefaultTextAttribute; }