Java 类org.eclipse.jface.text.rules.ITokenScanner 实例源码

项目:translationstudio8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
}
项目:translationstudio8    文件:TagStyleConfigurator.java   
private static ITokenScanner getRecipeScanner(final IDocument doc) {
//      IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        final InnerTagScanner scanner = new InnerTagScanner();
//      store.addPropertyChangeListener(new IPropertyChangeListener() {
//
//          public void propertyChange(PropertyChangeEvent event) {
//              String property = event.getProperty();
//              if (IPreferenceConstants.TAG_FOREGROUND.equals(property)
//                      || IPreferenceConstants.TAG_BACKGROUND.equals(property)) {
//                  scanner.updateToken(IPreferenceConstants.TAG_FOREGROUND, IPreferenceConstants.TAG_BACKGROUND);
//
//                  if (doc != null) { // 刷新
//                      try {
//                          doc.replace(doc.getLength(), 0, "");
//                      } catch (BadLocationException e) {
//                          e.printStackTrace();
//                      }
//                  }
//              }
//          }
//      });
        return scanner;
    }
项目:translationstudio8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
    scanner = null;
    doc = null;
}
项目:translationstudio8    文件:TagStyleConfigurator.java   
private static ITokenScanner getRecipeScanner(final IDocument doc) {
        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        /*final*/ InnerTagScanner scanner = new InnerTagScanner(store, IColorPreferenceConstant.TAG_FG_COLOR,
                IColorPreferenceConstant.TAG_BG_COLOR);
//      store.addPropertyChangeListener(new IPropertyChangeListener() {
//
//          public void propertyChange(PropertyChangeEvent event) {
//              String property = event.getProperty();
//              if (IColorPreferenceConstant.TAG_FG_COLOR.equals(property)
//                      || IColorPreferenceConstant.TAG_BG_COLOR.equals(property)) {
//                  scanner.updateToken(IColorPreferenceConstant.TAG_FG_COLOR, IColorPreferenceConstant.TAG_BG_COLOR);
//
//                  if (doc != null) { // 刷新
//                      try {
//                          doc.replace(doc.getLength(), 0, "");
//                      } catch (BadLocationException e) {
//                          e.printStackTrace();
//                      }
//                  }
//              }
//          }
//      });
        return scanner;
    }
项目:textuml    文件:TextUMLSourceViewerConfiguration.java   
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    final PresentationReconciler reconciler = new PresentationReconciler();
    reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    final SyntaxHighlighter scanner = new SyntaxHighlighter(
            com.abstratt.mdd.frontend.textuml.core.TextUMLConstants.KEYWORDS);
    final DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);
    reconciler.setDamager(dr, ContentTypes.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(dr, ContentTypes.DEFAULT_CONTENT_TYPE);

    // fix bug 2127735 --multiline comment is broken
    final ITokenScanner commentScanner = scanner.getCommentScanner();
    final DefaultDamagerRepairer commentDamagerRepairer = new DefaultDamagerRepairer(commentScanner);
    reconciler.setDamager(commentDamagerRepairer, ContentTypes.COMMENT_CONTENT_TYPE);
    reconciler.setRepairer(commentDamagerRepairer, ContentTypes.COMMENT_CONTENT_TYPE);

    return reconciler;
}
项目:tmxeditor8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
}
项目:tmxeditor8    文件:TagStyleConfigurator.java   
private static ITokenScanner getRecipeScanner(final IDocument doc) {
//      IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        InnerTagScanner scanner = new InnerTagScanner();
//      store.addPropertyChangeListener(new IPropertyChangeListener() {
//
//          public void propertyChange(PropertyChangeEvent event) {
//              String property = event.getProperty();
//              if (IPreferenceConstants.TAG_FOREGROUND.equals(property)
//                      || IPreferenceConstants.TAG_BACKGROUND.equals(property)) {
//                  scanner.updateToken(IPreferenceConstants.TAG_FOREGROUND, IPreferenceConstants.TAG_BACKGROUND);
//
//                  if (doc != null) { // 刷新
//                      try {
//                          doc.replace(doc.getLength(), 0, "");
//                      } catch (BadLocationException e) {
//                          e.printStackTrace();
//                      }
//                  }
//              }
//          }
//      });
        return scanner;
    }
项目:tmxeditor8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
}
项目:tmxeditor8    文件:TagStyleConfigurator.java   
private static ITokenScanner getRecipeScanner(final IDocument doc) {
//      IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        final InnerTagScanner scanner = new InnerTagScanner();
//      store.addPropertyChangeListener(new IPropertyChangeListener() {
//
//          public void propertyChange(PropertyChangeEvent event) {
//              String property = event.getProperty();
//              if (IPreferenceConstants.TAG_FOREGROUND.equals(property)
//                      || IPreferenceConstants.TAG_BACKGROUND.equals(property)) {
//                  scanner.updateToken(IPreferenceConstants.TAG_FOREGROUND, IPreferenceConstants.TAG_BACKGROUND);
//
//                  if (doc != null) { // 刷新
//                      try {
//                          doc.replace(doc.getLength(), 0, "");
//                      } catch (BadLocationException e) {
//                          e.printStackTrace();
//                      }
//                  }
//              }
//          }
//      });
        return scanner;
    }
项目:tmxeditor8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
    scanner = null;
    doc = null;
}
项目:tmxeditor8    文件:TagStyleConfigurator.java   
private static ITokenScanner getRecipeScanner(final IDocument doc) {
        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        /*final*/ InnerTagScanner scanner = new InnerTagScanner(store, IColorPreferenceConstant.TAG_FG_COLOR,
                IColorPreferenceConstant.TAG_BG_COLOR);
//      store.addPropertyChangeListener(new IPropertyChangeListener() {
//
//          public void propertyChange(PropertyChangeEvent event) {
//              String property = event.getProperty();
//              if (IColorPreferenceConstant.TAG_FG_COLOR.equals(property)
//                      || IColorPreferenceConstant.TAG_BG_COLOR.equals(property)) {
//                  scanner.updateToken(IColorPreferenceConstant.TAG_FG_COLOR, IColorPreferenceConstant.TAG_BG_COLOR);
//
//                  if (doc != null) { // 刷新
//                      try {
//                          doc.replace(doc.getLength(), 0, "");
//                      } catch (BadLocationException e) {
//                          e.printStackTrace();
//                      }
//                  }
//              }
//          }
//      });
        return scanner;
    }
项目:Pydev    文件:TestUtils.java   
public static String scan(ITokenScanner scanner, IDocument document) {
    scanner.setRange(document, 0, document.getLength());

    ArrayList<String> found = new ArrayList<String>();
    FastStringBuffer buf = new FastStringBuffer();
    IToken token = scanner.nextToken();
    while (!token.isEOF()) {
        Object data = token.getData();
        if (data != null) {
            buf.clear();
            buf.append(data.toString()).append(":");
            buf.append(scanner.getTokenOffset()).append(":");
            buf.append(scanner.getTokenLength());
            found.add(buf.toString());
        } else {
            buf.clear();
            buf.append("null").append(":");
            buf.append(scanner.getTokenOffset()).append(":");
            buf.append(scanner.getTokenLength());
            found.add(buf.toString());
        }
        token = scanner.nextToken();
    }
    return listToExpected(found);
}
项目:dsl-compiler-client    文件:DSLSourceViewerConfiguration.java   
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {

    DSLPresentationReconciler reconciler = new DSLPresentationReconciler(sourceViewer);
    ITokenScanner scanner = new TokenScanner();
    String contentType = IDocument.DEFAULT_CONTENT_TYPE;
    // TODO preference store
    long delay = 300;
    DefaultDamagerRepairer dr = new DelayedDamagerRepairer(scanner, reconciler, delay);
    reconciler.setDamager(dr, contentType);
    reconciler.setRepairer(dr, contentType);

    // IResource file = this.extractResource(this.editor);

    return reconciler;
}
项目:tlaplus    文件:TLAEditorActivator.java   
/**
 * @return
 */
public ITokenScanner getTLACodeScanner()
{
    if (tlaCodeScanner== null) 
    {
        tlaCodeScanner = new TLACodeScanner();
    }
    return tlaCodeScanner; 
}
项目:tlaplus    文件:TLAEditorActivator.java   
public ITokenScanner getPCALCodeScanner()
{
    if (pcalCodeScanner== null) 
    {
        pcalCodeScanner = new PCALCodeScanner();
    }
    return pcalCodeScanner; 
}
项目:APICloud-Studio    文件:SVGSourceConfiguration.java   
/**
 * getPreProcessorScanner
 * 
 * @return
 */
private ITokenScanner getPreProcessorScanner()
{
    XMLTagScanner preProcessorScanner = new XMLTagScanner();

    preProcessorScanner.setDefaultReturnToken(getToken("meta.tag.preprocessor.xml.svg")); //$NON-NLS-1$

    return preProcessorScanner;
}
项目:APICloud-Studio    文件:HTMLParser.java   
protected void processLanguage(String language, short endToken) throws IOException, Exception
{
    ITokenScanner tokenScanner = fScanner.getTokenScanner().getPrimaryTokenScanner();
    if (tokenScanner instanceof HTMLTokenScanner)
    {
        ((HTMLTokenScanner) tokenScanner).setInsideSpecialTag(true);
    }

    Symbol startTag = fCurrentSymbol;
    advance();

    int start = fCurrentSymbol.getStart();
    int end = start - 1;
    short id = fCurrentSymbol.getId();
    while (id != endToken && id != HTMLTokens.EOF)
    {
        end = fCurrentSymbol.getEnd();
        advance();
        id = fCurrentSymbol.getId();
    }

    if (tokenScanner instanceof HTMLTokenScanner)
    {
        ((HTMLTokenScanner) tokenScanner).setInsideSpecialTag(false);
    }

    IParseNode[] nested = getParseResult(language, start, end);
    if (fCurrentElement != null)
    {
        HTMLSpecialNode node = new HTMLSpecialNode(startTag, nested, startTag.getStart(), fCurrentSymbol.getEnd());
        node.setEndNode(fCurrentSymbol.getStart(), fCurrentSymbol.getEnd());
        parseAttribute(node, startTag);
        fCurrentElement.addChild(node);
    }
}
项目:APICloud-Studio    文件:ThemeingDamagerRepairer.java   
public ThemeingDamagerRepairer(ITokenScanner scanner)
{
    super(scanner);
    maxLinesToColor = Platform.getPreferencesService().getInt(CommonEditorPlugin.PLUGIN_ID,
            IPreferenceConstants.EDITOR_MAX_COLORED_COLUMNS,
            IPreferenceConstants.EDITOR_MAX_COLORED_COLUMNS_DEFAULT,
            new IScopeContext[] { EclipseUtil.instanceScope(), EclipseUtil.defaultScope() });
}
项目:APICloud-Studio    文件:QueuedRuleBasedScanner.java   
public Entry(ITokenScanner tokenScanner, IToken token, int offset, int length)
{
    this.tokenScanner = tokenScanner;
    this.token = token;
    this.offset = offset;
    this.length = length;
}
项目:APICloud-Studio    文件:CompositeSourceViewerConfiguration.java   
private ITokenScanner getStartEndTokenScanner() {
    if (startEndTokenScanner == null) {
        RuleBasedScanner ts = new RuleBasedScanner();
        IToken seqToken = new Token(getStartEndTokenType());
        List<IRule> rules = new ArrayList<IRule>();
        for (String[] pair : getPartitionerSwitchStrategy().getSwitchTagPairs()) {
            rules.add(new SingleTagRule(pair[0], seqToken));
            rules.add(new SingleTagRule(pair[1], seqToken));
        }
        ts.setRules(rules.toArray(new IRule[rules.size()]));
        ts.setDefaultReturnToken(new Token("text")); //$NON-NLS-1$
        startEndTokenScanner = ts;
    }
    return startEndTokenScanner;
}
项目:translationstudio8    文件:PresentationRepairer.java   
public PresentationRepairer(ITokenScanner scanner, ISegmentViewer viewer) {
    Assert.isNotNull(scanner);

    fViewer = viewer;
    fScanner = scanner;
    fDefaultTextStyle = new TextStyle();
}
项目:textuml    文件:SyntaxHighlighter.java   
ITokenScanner getCommentScanner() {
    // lazy init
    if (this.commentScanner == null) {
        final Token comment = new Token(new TextAttribute(JFaceResources.getColorRegistry().get(COMMENT_COLOR)));
        // no rules needed, because this will apply to comment partition
        // only
        final RuleBasedScanner ruleBasedScanner = new RuleBasedScanner();
        // this will apply the syntax
        ruleBasedScanner.setDefaultReturnToken(comment);
        this.commentScanner = ruleBasedScanner;
    }
    return commentScanner;
}
项目:eclipsensis    文件:NSISSourceViewerConfiguration.java   
@Override
public IPresentationReconciler getPresentationReconciler(
        ISourceViewer sourceViewer)
{
    return NSISSourceViewerConfigurationTools.createPresentationReconciler(sourceViewer,
                                        new ITokenScanner[] {new NSISCodeScanner(mPreferenceStore),
                                                            new NSISCommentScanner(mPreferenceStore),
                                                            new NSISStringScanner(mPreferenceStore)},
                                        new String[][] {{IDocument.DEFAULT_CONTENT_TYPE},
                                                        {NSISPartitionScanner.NSIS_SINGLELINE_COMMENT,
                                                         NSISPartitionScanner.NSIS_MULTILINE_COMMENT},
                                                        {NSISPartitionScanner.NSIS_STRING}});
}
项目:eclipsensis    文件:NSISTemplateSourceViewerConfiguration.java   
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
{
    return NSISSourceViewerConfigurationTools.createPresentationReconciler(sourceViewer,
            new ITokenScanner[] {new NSISTemplateCodeScanner(mPreferenceStore),
                                new NSISCommentScanner(mPreferenceStore),
                                new NSISStringScanner(mPreferenceStore)},
            new String[][] {{IDocument.DEFAULT_CONTENT_TYPE},
                            {NSISPartitionScanner.NSIS_SINGLELINE_COMMENT,
                             NSISPartitionScanner.NSIS_MULTILINE_COMMENT},
                            {NSISPartitionScanner.NSIS_STRING}});
}
项目:myLOGO4Eclipse    文件:LogoScriptSourceViewerConfiguration.java   
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    PresentationReconciler reconciler = new PresentationReconciler();
    ITokenScanner tokenScanner = createTokenScanner();
    DefaultDamagerRepairer defaultDamagerRepairer = new DefaultDamagerRepairer(tokenScanner);
    reconciler.setDamager(defaultDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(defaultDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);
    return reconciler;
}
项目:tmxeditor8    文件:PresentationRepairer.java   
public PresentationRepairer(ITokenScanner scanner, CellEditorTextViewer viewer) {
    Assert.isNotNull(scanner);

    this.viewer = viewer;
    fScanner = scanner;
    fDefaultTextStyle = new TextStyle();
}
项目:tmxeditor8    文件:PresentationRepairer.java   
public PresentationRepairer(ITokenScanner scanner, ISegmentViewer viewer) {
    Assert.isNotNull(scanner);

    fViewer = viewer;
    fScanner = scanner;
    fDefaultTextStyle = new TextStyle();
}
项目:Pydev    文件:IndexApi.java   
/**
 * We index based on what we want to search later on!
 *
 * We have to index giving the path for the file (workspace-relative path).
 *
 * The project is not expected to be passed because the idea is having one index
 * for each project.
 *
 * The scanner and the mapper work together: the scanner generates the tokens
 * and the mapper maps the token from the scanner to the mapping used for indexing.
 */
public void index(Path filepath, long modifiedTime, ITokenScanner tokenScanner, IFields mapper)
        throws IOException {
    if (this.writer == null) {
        return;
    }
    IContentsScanner contentsScanner = (IContentsScanner) tokenScanner;
    Document doc = createDocument(filepath, modifiedTime, null);

    FastStringBuffer buf = new FastStringBuffer();
    IToken nextToken = tokenScanner.nextToken();
    while (!nextToken.isEOF()) {
        if (!nextToken.isUndefined() && !nextToken.isWhitespace()) {
            int offset = tokenScanner.getTokenOffset();
            int length = tokenScanner.getTokenLength();
            contentsScanner.getContents(offset, length, buf.clear());
            String fieldName = mapper.getTokenFieldName(nextToken);
            if (fieldName != null) {
                //Note: TextField should be analyzed/normalized in Analyzer.createComponents(String)
                doc.add(new TextField(fieldName, buf.toString(), Field.Store.NO));
            }
        }
        nextToken = tokenScanner.nextToken();
    }

    this.writer.addDocument(doc);
}
项目:n4js    文件:N4JSUiModule.java   
@Override
public Class<? extends ITokenScanner> bindITokenScanner() {
    return TemplateAwareTokenScanner.class;
}
项目:vertigo-chroma-kspplugin    文件:KspSourceViewerConfiguration.java   
private void setRepairer(PresentationReconciler reconciler, ITokenScanner scanner, String contentType) {
    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);
    reconciler.setDamager(dr, contentType);
    reconciler.setRepairer(dr, contentType);
}
项目:GradleEditor    文件:NodeSourceViewerConfiguration.java   
private void setDamagerRepairer(PresentationReconciler pr, ITokenScanner scanner, String tokenType) {
    DefaultDamagerRepairer damagerRepairer = new DefaultDamagerRepairer(scanner);
    pr.setDamager(damagerRepairer, tokenType);
    pr.setRepairer(damagerRepairer, tokenType);
}
项目:DarwinSPL    文件:DwprofileSourceViewerConfiguration.java   
protected ITokenScanner getScanner() {
    if (tokenScanner == null) {
        tokenScanner = new de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager);
    }
    return tokenScanner;
}
项目:DarwinSPL    文件:HyexpressionSourceViewerConfiguration.java   
protected ITokenScanner getScanner() {
    if (tokenScanner == null) {
        tokenScanner = new eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager);
    }
    return tokenScanner;
}
项目:DarwinSPL    文件:HyvalidityformulaSourceViewerConfiguration.java   
protected ITokenScanner getScanner() {
    if (tokenScanner == null) {
        tokenScanner = new eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager);
    }
    return tokenScanner;
}
项目:DarwinSPL    文件:HydatavalueSourceViewerConfiguration.java   
protected ITokenScanner getScanner() {
    if (tokenScanner == null) {
        tokenScanner = new eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager);
    }
    return tokenScanner;
}
项目:DarwinSPL    文件:HymappingSourceViewerConfiguration.java   
protected ITokenScanner getScanner() {
    if (tokenScanner == null) {
        tokenScanner = new eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager);
    }
    return tokenScanner;
}
项目:DarwinSPL    文件:HyconstraintsSourceViewerConfiguration.java   
protected ITokenScanner getScanner() {
    if (tokenScanner == null) {
        tokenScanner = new eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager);
    }
    return tokenScanner;
}
项目:DarwinSPL    文件:HymanifestSourceViewerConfiguration.java   
protected ITokenScanner getScanner() {
    if (tokenScanner == null) {
        tokenScanner = new eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager);
    }
    return tokenScanner;
}
项目:ftc    文件:FtcDamagerRepairer.java   
public FtcDamagerRepairer(SyntaxColoring coloring, ITokenScanner scanner) {
    super(scanner);
    this.coloring = coloring;
}
项目:bts    文件:DefaultUiModule.java   
public Class<? extends ITokenScanner> bindITokenScanner() {
    return TokenScanner.class;
}