org.eclipse.jface.text.rules.ITokenScanner Java Examples
The following examples show how to use
org.eclipse.jface.text.rules.ITokenScanner.
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: TagStyleConfigurator.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #2
Source File: TagStyleConfigurator.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #3
Source File: TagStyleConfigurator.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #4
Source File: TagStyleConfigurator.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #5
Source File: TagStyleConfigurator.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #6
Source File: InactiveCodeRule.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
@Override public IToken evaluate(ICharacterScanner scanner, boolean resume) { if (scanner instanceof ITokenScanner) { if (isShowInactiveCode && !CollectionUtils.isEmpty(inactiveCodeRegions)) { ITokenScanner tokenScanner = (ITokenScanner) scanner; ITextRegion reg = findInactiveCodeRegion(tokenScanner.getTokenOffset()); if (reg != null) { for (int i = tokenScanner.getTokenOffset(); i < reg.getOffset() + reg.getLength(); i++) { scanner.read(); } return ModulaPartitionTokens.DISABLED_CODE; } } } return Token.UNDEFINED; }
Example #7
Source File: TextUMLSourceViewerConfiguration.java From textuml with Eclipse Public License 1.0 | 6 votes |
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; }
Example #8
Source File: TagStyleConfigurator.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #9
Source File: TagStyleConfigurator.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #10
Source File: DSLSourceViewerConfiguration.java From dsl-compiler-client with BSD 3-Clause "New" or "Revised" License | 6 votes |
@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; }
Example #11
Source File: TagStyleConfigurator.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
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); } } }
Example #12
Source File: TagStyleConfigurator.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #13
Source File: TLAEditorActivator.java From tlaplus with MIT License | 5 votes |
public ITokenScanner getPCALCodeScanner() { if (pcalCodeScanner== null) { pcalCodeScanner = new PCALCodeScanner(); } return pcalCodeScanner; }
Example #14
Source File: PresentationRepairer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public PresentationRepairer(ITokenScanner scanner, ISegmentViewer viewer) { Assert.isNotNull(scanner); fViewer = viewer; fScanner = scanner; fDefaultTextStyle = new TextStyle(); }
Example #15
Source File: TLAEditorActivator.java From tlaplus with MIT License | 5 votes |
/** * @return */ public ITokenScanner getTLACodeScanner() { if (tlaCodeScanner== null) { tlaCodeScanner = new TLACodeScanner(); } return tlaCodeScanner; }
Example #16
Source File: PresentationRepairer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public PresentationRepairer(ITokenScanner scanner, CellEditorTextViewer viewer) { Assert.isNotNull(scanner); this.viewer = viewer; fScanner = scanner; fDefaultTextStyle = new TextStyle(); }
Example #17
Source File: PresentationRepairer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public PresentationRepairer(ITokenScanner scanner, ISegmentViewer viewer) { Assert.isNotNull(scanner); fViewer = viewer; fScanner = scanner; fDefaultTextStyle = new TextStyle(); }
Example #18
Source File: SVGSourceConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * getPreProcessorScanner * * @return */ private ITokenScanner getPreProcessorScanner() { XMLTagScanner preProcessorScanner = new XMLTagScanner(); preProcessorScanner.setDefaultReturnToken(getToken("meta.tag.preprocessor.xml.svg")); //$NON-NLS-1$ return preProcessorScanner; }
Example #19
Source File: CompositeSourceViewerConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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; }
Example #20
Source File: QueuedRuleBasedScanner.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public Entry(ITokenScanner tokenScanner, IToken token, int offset, int length) { this.tokenScanner = tokenScanner; this.token = token; this.offset = offset; this.length = length; }
Example #21
Source File: ThemeingDamagerRepairer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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() }); }
Example #22
Source File: HTMLParser.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
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); } }
Example #23
Source File: SyntaxHighlighter.java From textuml with Eclipse Public License 1.0 | 5 votes |
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; }
Example #24
Source File: CSSSourceConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private ITokenScanner getCommentScanner() { return new CommentScanner(getToken(ICSSConstants.CSS_COMMENT_BLOCK_SCOPE)); }
Example #25
Source File: HTMLSourceConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private ITokenScanner getHTMLScanner() { return new HTMLScanner(); }
Example #26
Source File: HTMLSourceConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private ITokenScanner getHTMLCommentScanner() { return new CommentScanner(getToken("comment.block.html")); //$NON-NLS-1$ }
Example #27
Source File: CSSSourceConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private ITokenScanner getStringScanner() { return new SingleTokenScanner(getToken(ICSSConstants.CSS_STRING_SCOPE)); }
Example #28
Source File: DTDSourceConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private ITokenScanner getCommentScanner() { return new CommentScanner(getToken("comment.block.dtd")); //$NON-NLS-1$ }
Example #29
Source File: N4JSUiModule.java From n4js with Eclipse Public License 1.0 | 4 votes |
@Override public Class<? extends ITokenScanner> bindITokenScanner() { return TemplateAwareTokenScanner.class; }
Example #30
Source File: DTDSourceConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private ITokenScanner getPIScanner() { DTDTagScanner piScanner = new DTDTagScanner(); piScanner.setDefaultReturnToken(getToken("meta.tag.preprocessor.xml")); //$NON-NLS-1$ return piScanner; }