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); } } }
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; }
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; }
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; }
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; }
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; }
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); }
@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; }
/** * @return */ public ITokenScanner getTLACodeScanner() { if (tlaCodeScanner== null) { tlaCodeScanner = new TLACodeScanner(); } return tlaCodeScanner; }
public ITokenScanner getPCALCodeScanner() { if (pcalCodeScanner== null) { pcalCodeScanner = new PCALCodeScanner(); } return pcalCodeScanner; }
/** * getPreProcessorScanner * * @return */ private ITokenScanner getPreProcessorScanner() { XMLTagScanner preProcessorScanner = new XMLTagScanner(); preProcessorScanner.setDefaultReturnToken(getToken("meta.tag.preprocessor.xml.svg")); //$NON-NLS-1$ return preProcessorScanner; }
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); } }
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() }); }
public Entry(ITokenScanner tokenScanner, IToken token, int offset, int length) { this.tokenScanner = tokenScanner; this.token = token; this.offset = offset; this.length = length; }
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; }
public PresentationRepairer(ITokenScanner scanner, ISegmentViewer viewer) { Assert.isNotNull(scanner); fViewer = viewer; fScanner = scanner; fDefaultTextStyle = new TextStyle(); }
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; }
@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}}); }
@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}}); }
@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; }
public PresentationRepairer(ITokenScanner scanner, CellEditorTextViewer viewer) { Assert.isNotNull(scanner); this.viewer = viewer; fScanner = scanner; fDefaultTextStyle = new TextStyle(); }
/** * 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); }
@Override public Class<? extends ITokenScanner> bindITokenScanner() { return TemplateAwareTokenScanner.class; }
private void setRepairer(PresentationReconciler reconciler, ITokenScanner scanner, String contentType) { DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner); reconciler.setDamager(dr, contentType); reconciler.setRepairer(dr, contentType); }
private void setDamagerRepairer(PresentationReconciler pr, ITokenScanner scanner, String tokenType) { DefaultDamagerRepairer damagerRepairer = new DefaultDamagerRepairer(scanner); pr.setDamager(damagerRepairer, tokenType); pr.setRepairer(damagerRepairer, tokenType); }
protected ITokenScanner getScanner() { if (tokenScanner == null) { tokenScanner = new de.darwinspl.preferences.resource.dwprofile.ui.DwprofileUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager); } return tokenScanner; }
protected ITokenScanner getScanner() { if (tokenScanner == null) { tokenScanner = new eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager); } return tokenScanner; }
protected ITokenScanner getScanner() { if (tokenScanner == null) { tokenScanner = new eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager); } return tokenScanner; }
protected ITokenScanner getScanner() { if (tokenScanner == null) { tokenScanner = new eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager); } return tokenScanner; }
protected ITokenScanner getScanner() { if (tokenScanner == null) { tokenScanner = new eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager); } return tokenScanner; }
protected ITokenScanner getScanner() { if (tokenScanner == null) { tokenScanner = new eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager); } return tokenScanner; }
protected ITokenScanner getScanner() { if (tokenScanner == null) { tokenScanner = new eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestUIMetaInformation().createTokenScanner(resourceProvider.getResource(), colorManager); } return tokenScanner; }
public FtcDamagerRepairer(SyntaxColoring coloring, ITokenScanner scanner) { super(scanner); this.coloring = coloring; }
public Class<? extends ITokenScanner> bindITokenScanner() { return TokenScanner.class; }