private IToken evaluateToken() { try { final String token= getDocument().get(getTokenOffset(), getTokenLength()) + "."; //$NON-NLS-1$ int offset= 0; char character= token.charAt(++offset); if (character == '/') character= token.charAt(++offset); while (Character.isWhitespace(character)) character= token.charAt(++offset); while (Character.isLetterOrDigit(character)) character= token.charAt(++offset); while (Character.isWhitespace(character)) character= token.charAt(++offset); if (offset >= 2 && token.charAt(offset) == fEndSequence[0]) return fToken; } catch (BadLocationException exception) { // Do nothing } return getToken(IJavaColorConstants.JAVADOC_DEFAULT); }
final IToken token= getToken(IJavaColorConstants.JAVADOC_KEYWORD); WordMatcher matcher= new CombinedWordRule.WordMatcher() { public IToken evaluate(ICharacterScanner scanner, CharacterBuffer word) {
/** * Adapts the behavior of the contained components to the change * encoded in the given event. * * @param event the event to which to adapt * @since 2.0 * @deprecated As of 3.0, no replacement */ @Deprecated protected void adaptToPreferenceChange(PropertyChangeEvent event) { if (fCodeScanner.affectsBehavior(event)) fCodeScanner.adaptToPreferenceChange(event); if (fMultilineCommentScanner.affectsBehavior(event)) fMultilineCommentScanner.adaptToPreferenceChange(event); if (fSinglelineCommentScanner.affectsBehavior(event)) fSinglelineCommentScanner.adaptToPreferenceChange(event); if (fStringScanner.affectsBehavior(event)) fStringScanner.adaptToPreferenceChange(event); if (fJavaDocScanner.affectsBehavior(event)) fJavaDocScanner.adaptToPreferenceChange(event); }
/** * Creates a new Java text tools collection. * * @param store the preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. In general <code>PreferenceConstants. * getPreferenceStore()</code> should be used to initialize the text tools. * @param coreStore optional preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. * @param autoDisposeOnDisplayDispose if <code>true</code> the color manager * automatically disposes all managed colors when the current display gets disposed * and all calls to {@link org.eclipse.jface.text.source.ISharedTextColors#dispose()} are ignored. * @see org.eclipse.jdt.ui.PreferenceConstants#getPreferenceStore() * @since 2.1 */ public JavaTextTools(IPreferenceStore store, Preferences coreStore, boolean autoDisposeOnDisplayDispose) { fPreferenceStore= store; fPreferenceStore.addPropertyChangeListener(fPreferenceListener); fCorePreferenceStore= coreStore; if (fCorePreferenceStore != null) fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener); fColorManager= new JavaColorManager(autoDisposeOnDisplayDispose); fCodeScanner= new JavaCodeScanner(fColorManager, store); fMultilineCommentScanner= new JavaCommentScanner(fColorManager, store, coreStore, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT); fSinglelineCommentScanner= new JavaCommentScanner(fColorManager, store, coreStore, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT); fStringScanner= new SingleTokenJavaScanner(fColorManager, store, IJavaColorConstants.JAVA_STRING); fJavaDocScanner= new JavaDocScanner(fColorManager, store, coreStore); }
/** * Determines whether the preference change encoded by the given event * changes the behavior of one its contained components. * * @param event the event to be investigated * @return <code>true</code> if event causes a behavioral change * @since 2.0 * @deprecated As of 3.0, replaced by {@link org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration#affectsTextPresentation(PropertyChangeEvent)} */ @Deprecated public boolean affectsBehavior(PropertyChangeEvent event) { return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event) || fSinglelineCommentScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event) || fJavaDocScanner.affectsBehavior(event); }
/** * Adapts the behavior of the contained components to the change * encoded in the given event. * * @param event the event to which to adapt * @since 2.0 * @deprecated As of 3.0, no replacement */ @Deprecated protected void adaptToPreferenceChange(PropertyChangeEvent event) { if (fCodeScanner.affectsBehavior(event)) fCodeScanner.adaptToPreferenceChange(event); if (fMultilineCommentScanner.affectsBehavior(event)) fMultilineCommentScanner.adaptToPreferenceChange(event); if (fSinglelineCommentScanner.affectsBehavior(event)) fSinglelineCommentScanner.adaptToPreferenceChange(event); if (fStringScanner.affectsBehavior(event)) fStringScanner.adaptToPreferenceChange(event); if (fJavaDocScanner.affectsBehavior(event)) fJavaDocScanner.adaptToPreferenceChange(event); }
/** * Creates a new Java text tools collection. * * @param store the preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. In general <code>PreferenceConstants. * getPreferenceStore()</code> should be used to initialize the text tools. * @param coreStore optional preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. * @param autoDisposeOnDisplayDispose if <code>true</code> the color manager * automatically disposes all managed colors when the current display gets disposed * and all calls to {@link org.eclipse.jface.text.source.ISharedTextColors#dispose()} are ignored. * @see org.eclipse.jdt.ui.PreferenceConstants#getPreferenceStore() * @since 2.1 */ public JavaTextTools(IPreferenceStore store, Preferences coreStore, boolean autoDisposeOnDisplayDispose) { fPreferenceStore= store; fPreferenceStore.addPropertyChangeListener(fPreferenceListener); fCorePreferenceStore= coreStore; if (fCorePreferenceStore != null) fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener); fColorManager= new JavaColorManager(autoDisposeOnDisplayDispose); fCodeScanner= new JavaCodeScanner(fColorManager, store); fMultilineCommentScanner= new JavaCommentScanner(fColorManager, store, coreStore, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT); fSinglelineCommentScanner= new JavaCommentScanner(fColorManager, store, coreStore, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT); fStringScanner= new SingleTokenJavaScanner(fColorManager, store, IJavaColorConstants.JAVA_STRING); fJavaDocScanner= new JavaDocScanner(fColorManager, store, coreStore); }
/** * Determines whether the preference change encoded by the given event * changes the behavior of one its contained components. * * @param event the event to be investigated * @return <code>true</code> if event causes a behavioral change * @since 2.0 * @deprecated As of 3.0, replaced by {@link org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration#affectsTextPresentation(PropertyChangeEvent)} */ @Deprecated public boolean affectsBehavior(PropertyChangeEvent event) { return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event) || fSinglelineCommentScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event) || fJavaDocScanner.affectsBehavior(event); }
private IToken evaluateToken() { try { final String token= getDocument().get(getTokenOffset(), getTokenLength()) + "."; //$NON-NLS-1$ int offset= 0; char character= token.charAt(++offset); if (character == '/') character= token.charAt(++offset); while (Character.isWhitespace(character)) character= token.charAt(++offset); while (Character.isLetterOrDigit(character)) character= token.charAt(++offset); while (Character.isWhitespace(character)) character= token.charAt(++offset); if (offset >= 2 && token.charAt(offset) == fEndSequence[0]) return fToken; } catch (BadLocationException exception) { // Do nothing } return getToken(IJavaColorConstants.JAVADOC_DEFAULT); }
/** * Adapts the behavior of the contained components to the change * encoded in the given event. * * @param event the event to which to adapt * @since 2.0 * @deprecated As of 3.0, no replacement */ protected void adaptToPreferenceChange(PropertyChangeEvent event) { if (fCodeScanner.affectsBehavior(event)) fCodeScanner.adaptToPreferenceChange(event); if (fMultilineCommentScanner.affectsBehavior(event)) fMultilineCommentScanner.adaptToPreferenceChange(event); if (fSinglelineCommentScanner.affectsBehavior(event)) fSinglelineCommentScanner.adaptToPreferenceChange(event); if (fStringScanner.affectsBehavior(event)) fStringScanner.adaptToPreferenceChange(event); if (fJavaDocScanner.affectsBehavior(event)) fJavaDocScanner.adaptToPreferenceChange(event); }
/** * Creates a new Java text tools collection. * * @param store the preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. In general <code>PreferenceConstants. * getPreferenceStore()</code> should be used to initialize the text tools. * @param coreStore optional preference store to initialize the text tools. The text tool * instance installs a listener on the passed preference store to adapt itself to * changes in the preference store. * @param autoDisposeOnDisplayDispose if <code>true</code> the color manager * automatically disposes all managed colors when the current display gets disposed * and all calls to {@link org.eclipse.jface.text.source.ISharedTextColors#dispose()} are ignored. * @see org.eclipse.jdt.ui.PreferenceConstants#getPreferenceStore() * @since 2.1 */ public JavaTextTools(IPreferenceStore store, Preferences coreStore, boolean autoDisposeOnDisplayDispose) { fPreferenceStore= store; fPreferenceStore.addPropertyChangeListener(fPreferenceListener); fCorePreferenceStore= coreStore; if (fCorePreferenceStore != null) fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener); fColorManager= new JavaColorManager(autoDisposeOnDisplayDispose); fCodeScanner= new JavaCodeScanner(fColorManager, store); fMultilineCommentScanner= new JavaCommentScanner(fColorManager, store, coreStore, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT); fSinglelineCommentScanner= new JavaCommentScanner(fColorManager, store, coreStore, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT); fStringScanner= new SingleTokenJavaScanner(fColorManager, store, IJavaColorConstants.JAVA_STRING); fJavaDocScanner= new JavaDocScanner(fColorManager, store, coreStore); }
final IToken token= getToken(IJavaColorConstants.JAVADOC_KEYWORD); WordMatcher matcher= new CombinedWordRule.WordMatcher() { @Override
/** * Determines whether the preference change encoded by the given event * changes the behavior of one its contained components. * * @param event the event to be investigated * @return <code>true</code> if event causes a behavioral change * @since 2.0 * @deprecated As of 3.0, replaced by {@link org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration#affectsTextPresentation(PropertyChangeEvent)} */ public boolean affectsBehavior(PropertyChangeEvent event) { return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event) || fSinglelineCommentScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event) || fJavaDocScanner.affectsBehavior(event); }
private IToken evaluateToken() { try { final String token= getDocument().get(getTokenOffset(), getTokenLength()) + "."; //$NON-NLS-1$ int offset= 0; char character= token.charAt(++offset); if (character == '/') character= token.charAt(++offset); while (Character.isWhitespace(character)) character= token.charAt(++offset); while (Character.isLetterOrDigit(character)) character= token.charAt(++offset); while (Character.isWhitespace(character)) character= token.charAt(++offset); if (offset >= 2 && token.charAt(offset) == fEndSequence[0]) return fToken; } catch (BadLocationException exception) { // Do nothing } return getToken(IJavaColorConstants.JAVADOC_DEFAULT); }
/** * Initializes the scanners. * * @since 3.0 */ private void initializeScanners() { Assert.isTrue(isNewSetup()); fCodeScanner= new JavaCodeScanner(getColorManager(), fPreferenceStore); fMultilineCommentScanner= new JavaCommentScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT); fSinglelineCommentScanner= new JavaCommentScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT); fStringScanner= new SingleTokenJavaScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_STRING); fJavaDocScanner= new JavaDocScanner(getColorManager(), fPreferenceStore); }
final IToken token= getToken(IJavaColorConstants.JAVADOC_KEYWORD); WordMatcher matcher= new CombinedWordRule.WordMatcher() { @Override
/** * Initializes the scanners. * * @since 3.0 */ private void initializeScanners() { Assert.isTrue(isNewSetup()); fCodeScanner= new JavaCodeScanner(getColorManager(), fPreferenceStore); fMultilineCommentScanner= new JavaCommentScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT); fSinglelineCommentScanner= new JavaCommentScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT); fStringScanner= new SingleTokenJavaScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_STRING); fJavaDocScanner= new JavaDocScanner(getColorManager(), fPreferenceStore); }
@Override protected List<IRule> createRules() { List<IRule> list= new ArrayList<>(); // Add rule for tags Token token= getToken(IJavaColorConstants.JAVADOC_TAG); list.add(new TagRule(token)); // Add rule for HTML comments WordRule wordRule= new WordRule(new HTMLCommentDetector(), token); wordRule.addWord("<!--", token); //$NON-NLS-1$ wordRule.addWord("--!>", token); //$NON-NLS-1$ list.add(wordRule); // Add rules for links token= getToken(IJavaColorConstants.JAVADOC_LINK); list.add(new MultiLineRule("{@link", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ list.add(new MultiLineRule("{@value", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ list.add(new MultiLineRule("{@inheritDoc", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ // Add rules for @code and @literals token= getToken(IJavaColorConstants.JAVADOC_DEFAULT); list.add(new MultiLineRule("{@code", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ list.add(new MultiLineRule("{@literal", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ // Add generic whitespace rule token= getToken(IJavaColorConstants.JAVADOC_DEFAULT); list.add(new WhitespaceRule(new JavaWhitespaceDetector(), token)); list.addAll(super.createRules()); return list; }
/** * Initializes the scanners. * * @param isModuleInfo <code>true</code> if used for module-info code * * @since 3.0 */ private void initializeScanners(boolean isModuleInfo) { Assert.isTrue(isNewSetup()); fCodeScanner= new JavaCodeScanner(getColorManager(), fPreferenceStore, isModuleInfo); fMultilineCommentScanner= new JavaCommentScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_MULTI_LINE_COMMENT); fSinglelineCommentScanner= new JavaCommentScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_SINGLE_LINE_COMMENT); fStringScanner= new SingleTokenJavaScanner(getColorManager(), fPreferenceStore, IJavaColorConstants.JAVA_STRING); fJavaDocScanner= new JavaDocScanner(getColorManager(), fPreferenceStore); }
@Override protected List<IRule> createRules() { List<IRule> list= new ArrayList<>(); // Add rule for tags Token token= getToken(IJavaColorConstants.JAVADOC_TAG); list.add(new TagRule(token)); // Add rule for HTML comments WordRule wordRule= new WordRule(new HTMLCommentDetector(), token); wordRule.addWord("<!--", token); //$NON-NLS-1$ wordRule.addWord("--!>", token); //$NON-NLS-1$ list.add(wordRule); // Add rules for links token= getToken(IJavaColorConstants.JAVADOC_LINK); list.add(new MultiLineRule("{@link", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ list.add(new MultiLineRule("{@value", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ list.add(new MultiLineRule("{@inheritDoc", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ // Add rules for @code and @literals token= getToken(IJavaColorConstants.JAVADOC_DEFAULT); list.add(new MultiLineRule("{@code", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ list.add(new MultiLineRule("{@literal", "}", token)); //$NON-NLS-2$ //$NON-NLS-1$ // Add generic whitespace rule token= getToken(IJavaColorConstants.JAVADOC_DEFAULT); list.add(new WhitespaceRule(new JavaWhitespaceDetector(), token)); list.addAll(super.createRules()); return list; }