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

项目:velocity-edit    文件:EditorsUtil.java   
/**
 * DOCUMENT ME!
 * 
 * @param detector
 *            DOCUMENT ME!
 * @param scanner
 *            DOCUMENT ME!
 * 
 * @return DOCUMENT ME!
 */
public static String getWord(IWordDetector detector, ICharacterScanner scanner)
{
    StringBuffer ret = new StringBuffer();
    int c = scanner.read();
    if (detector.isWordStart((char) c))
    {
        ret.append((char) c);
        for (c = scanner.read(); c != -1; c = scanner.read())
        {
            if (!detector.isWordPart((char) c))
            {
                break;
            }
            ret.append((char) c);
        }
    }
    scanner.unread();
    return ret.toString();
}
项目:tlaplus    文件:DocumentHelper.java   
/**
 * At a given position in text retrieves the region marking the word, starting before and ending on current position 
 * @param document document
 * @param documentOffset offset (position of the cursor)
 * @param detector for identification of words 
 * @return a region expanded backwards
 */
public static IRegion getRegionExpandedBackwards(IDocument document, int documentOffset, IWordDetector detector)
{

    // Use string buffer to collect characters
    int charCounter = 0;
    while (true)
    {
        try
        {

            // Read character backwards
            char c = document.getChar(--documentOffset);

            // This was the start of a word
            if (!detector.isWordPart(c))
                break;

            // Count character
            charCounter++;

        } catch (BadLocationException e)
        {

            // Document start reached, no word
            break;
        }
    }
    return new Region(documentOffset + 1, charCounter);
}
项目:tlaplus    文件:DocumentHelper.java   
/**
 * At a given position in text retrieves the region marking the word, starting at and ending after the current position 
 * @param document document
 * @param documentOffset offset (position of the cursor)
 * @param detector for identification of words 
 * @return a region expanded forward
 */
public static IRegion getRegionExpandedForwards(IDocument document, int documentOffset, IWordDetector detector)
{

    // Use string buffer to collect characters
    int charCounter = 0;
    while (true)
    {
        try
        {
            // Read character forward
            char c = document.getChar(++documentOffset);

            // This was the start of a word
            if (!detector.isWordPart(c))
                break;

            // Count character
            charCounter++;

        } catch (BadLocationException e)
        {

            // Document end reached, no word
            break;
        }
    }

    return new Region(documentOffset - charCounter, charCounter + 1);
}
项目:GLSL-Eclipse    文件:GlslScanners.java   
public static final WordRule createWordRule() {
    return new WordRule(new IWordDetector() {

        @Override
        public boolean isWordStart(char c) {
            return c != ' ' && Character.isJavaIdentifierStart(c);
        }

        @Override
        public boolean isWordPart(char arg0) {
            return Character.isJavaIdentifierPart(arg0);
        }
    }, Token.WHITESPACE);
}
项目:myLOGO4Eclipse    文件:LogoScriptSourceViewerConfiguration.java   
private IRule createKeywordRule(IToken token) {
    IWordDetector detector = createNameDetector();
    WordRule rule = new WordRule(detector, Token.UNDEFINED, true);
    // Add all predefined keywords
    rule.addWord("ed", token);
    rule.addWord("end", token);
    // Add all predefined actions
    ActionsRegistry registry = new ActionsRegistry();
    for (ActionDefinition actionDefinition : registry.getActionDefinitions()) {
        rule.addWord(actionDefinition.getName(), token);
    };
    return rule;
}
项目:Pydev    文件:PyWordRule.java   
/**
 * Creates a rule which, with the help of a word detector, will return the token
 * associated with the detected word. If no token has been associated, the
 * specified default token will be returned.
 *
 * @param detector the word detector to be used by this rule, may not be <code>null</code>
 * @param defaultToken the default token to be returned on success
 *      if nothing else is specified, may not be <code>null</code>
 * @param funcNameToken 
 * @param classNameToken 
 *
 * @see #addWord(String, IToken)
 */
public PyWordRule(IWordDetector detector, IToken defaultToken, IToken classNameToken, IToken funcNameToken,
        IToken parensToken, IToken operatorsToken) {

    Assert.isNotNull(detector);
    Assert.isNotNull(defaultToken);

    fDetector = detector;
    fDefaultToken = defaultToken;
    this.classNameToken = classNameToken;
    this.funcNameToken = funcNameToken;
    this.parensToken = parensToken;
    this.operatorsToken = operatorsToken;
}
项目:eclipse-batch-editor    文件:ExactWordPatternRule.java   
public ExactWordPatternRule(IWordDetector detector, String exactWord, IToken token) {
    this(detector,exactWord,token,true);
}
项目:eclipse-batch-editor    文件:ExactWordPatternRule.java   
public ExactWordPatternRule(IWordDetector detector, String exactWord, IToken token, boolean breaksOnEOF) {
    super(detector, exactWord, null, token);
    toStringValue=getClass().getSimpleName()+":"+exactWord;
    this.fBreaksOnEOF=breaksOnEOF;
}
项目:eclipse-batch-editor    文件:VariableDefKeyWordPatternRule.java   
public VariableDefKeyWordPatternRule(IWordDetector detector, String exactWord, IToken token) {
    this(detector,exactWord,token,true);
}
项目:eclipse-batch-editor    文件:VariableDefKeyWordPatternRule.java   
public VariableDefKeyWordPatternRule(IWordDetector detector, String exactWord, IToken token, boolean breaksOnEOF) {
    super(detector, exactWord, null, token);
    toStringValue=getClass().getSimpleName()+":"+exactWord+"=";
    this.fBreaksOnEOF=breaksOnEOF;
}
项目:eclipse-bash-editor    文件:ExactWordPatternRule.java   
public ExactWordPatternRule(IWordDetector detector, String exactWord, IToken token) {
    this(detector,exactWord,token,true);
}
项目:eclipse-bash-editor    文件:ExactWordPatternRule.java   
public ExactWordPatternRule(IWordDetector detector, String exactWord, IToken token, boolean breaksOnEOF) {
    super(detector, exactWord, null, token);
    toStringValue=getClass().getSimpleName()+":"+exactWord;
    this.fBreaksOnEOF=breaksOnEOF;
}
项目:eclipse-bash-editor    文件:VariableDefKeyWordPatternRule.java   
public VariableDefKeyWordPatternRule(IWordDetector detector, String exactWord, IToken token) {
    this(detector,exactWord,token,true);
}
项目:eclipse-bash-editor    文件:VariableDefKeyWordPatternRule.java   
public VariableDefKeyWordPatternRule(IWordDetector detector, String exactWord, IToken token, boolean breaksOnEOF) {
    super(detector, exactWord, null, token);
    toStringValue=getClass().getSimpleName()+":"+exactWord+"=";
    this.fBreaksOnEOF=breaksOnEOF;
}
项目:egradle    文件:ExactWordPatternRule.java   
public ExactWordPatternRule(IWordDetector detector, String exactWord, IToken token) {
    super(detector, exactWord, null, token);
    toStringValue=getClass().getSimpleName()+":"+exactWord;
}
项目:egradle    文件:AbstractGroovyBasedDocumentPartitionScanner.java   
protected void buildWordRules(List<IPredicateRule> rules, IToken token, DocumentKeyWord[] values,
        IWordDetector wordDetector) {
    for (DocumentKeyWord keyWord : values) {
        rules.add(new ExactWordPatternRule(wordDetector, createWordStart(keyWord), token));
    }
}
项目:tlaplus    文件:DocumentHelper.java   
/**
 * Factory method for the word detector
 */
public static IWordDetector getDefaultWordDetector()
{
    return new TLAWordDetector();
}
项目:bts    文件:BTSTextTokenRule.java   
public BTSTextTokenRule(IWordDetector detector, String startSequence, String endSequence, IToken token)
{
    super(detector, startSequence, endSequence, token);
    // TODO Auto-generated constructor stub
}
项目:APICloud-Studio    文件:CSSCodeScannerRuleBased.java   
private VendorPropertyWordRule(IWordDetector detector, IToken defaultToken, boolean ignoreCase)
{
    super(detector, defaultToken, ignoreCase);
}
项目:APICloud-Studio    文件:AddRemoveList.java   
/**
 * Display a prompt to allow adding new elements.
 */
protected void promptForNewElements()
{
    IInputValidator inputValidator = new IInputValidator()
    {
        public String isValid(String newText)
        {
            IWordDetector dtdDetector = new DTDNameDetector();
            String[] inputWords = newText.split(" |,"); //$NON-NLS-1$
            for (String word : inputWords)
            {
                // Only letters, digits, spaces and commas are valid here.
                int length = word.length();
                for (int i = 0; i < length; i++)
                {
                    char c = word.charAt(i);
                    if (i == 0)
                    {
                        if (!dtdDetector.isWordStart(c))
                        {
                            return NLS.bind(Messages.AddRemoveList_invalidBeginTagChar, word);
                        }
                    }
                    else if (!dtdDetector.isWordPart(c))
                    {
                        return NLS.bind(Messages.AddRemoveList_invalidCharInTag, word);
                    }
                }
            }
            return null;
        }
    };
    InputDialog dialog = new InputDialog(listViewer.getList().getShell(), Messages.AddRemoveList_inputMessageTitle,
            Messages.AddRemoveList_inputMessageText, "", inputValidator); //$NON-NLS-1$
    if (dialog.open() == Window.OK)
    {
        String value = dialog.getValue().trim();
        if (value.length() == 0)
        {
            return;
        }
        // At this point we know that the elements have been validated by the input-validator.
        value = value.replaceAll(",", " "); //$NON-NLS-1$ //$NON-NLS-2$
        String[] values = value.split(" "); //$NON-NLS-1$
        // Filter out any duplicates that we might have before setting the input.
        Set<Object> elementsSet = new TreeSet<Object>();
        Object[] existingElements = contentProvider.getElements(null);
        for (Object o : existingElements)
        {
            elementsSet.add(o);
        }
        for (String v : values)
        {
            if (v.trim().length() != 0)
            {
                elementsSet.add(v.toLowerCase());
            }
        }
        listViewer.setInput(elementsSet.toArray(new Object[elementsSet.size()]));
    }
}
项目:APICloud-Studio    文件:HTMLDoctypeScanner.java   
private TagStartRule(IWordDetector detector, IToken defaultToken, boolean ignoreCase)
{
    super(detector, defaultToken, ignoreCase);
}
项目:translationstudio8    文件:InnerTagRule.java   
public InnerTagRule(IWordDetector detector) {
    super(detector);
}
项目:translationstudio8    文件:InnerTagRule.java   
public InnerTagRule(int ruleType, IWordDetector detector) {
    super(detector);
    this.ruleType = ruleType;
}
项目:myLOGO4Eclipse    文件:LogoScriptSourceViewerConfiguration.java   
private IRule createNameRule(IToken token) {
    IWordDetector detector = createNameDetector();
    WordRule rule = new WordRule(detector, token, true);
    return rule;
}
项目:tmxeditor8    文件:InnerTagRule.java   
public InnerTagRule(IWordDetector detector) {
    super(detector);
}
项目:tmxeditor8    文件:InnerTagRule.java   
public InnerTagRule(IWordDetector detector) {
    super(detector);
}
项目:tmxeditor8    文件:InnerTagRule.java   
public InnerTagRule(int ruleType, IWordDetector detector) {
    super(detector);
    this.ruleType = ruleType;
}
项目:birt    文件:PredicateWrodRule.java   
public PredicateWordRule(IWordDetector detector, IToken defaultToken) {
    super(detector, defaultToken);
}
项目:byteman-editor    文件:BytemanWordRule.java   
public BytemanWordRule(IWordDetector detector, boolean headOfLine) {
    super(detector);
    this.headOfLine = headOfLine;
}
项目:goclipse    文件:FullPatternRule.java   
public FullPatternRule(IToken token, String[] possibleSequences, IWordDetector ruleCancelWordDetector) {
    this.token = token;
    this.ruleCancelWordDetector = ruleCancelWordDetector;
    this.possibleSequences = ArrayUtil.map(possibleSequences, STRING_to_CHAR_ARRAY, char[].class);
}
项目:tlaplus    文件:DocumentHelper.java   
/**
 * Combines the effect of backwards and forwards region expansion
 * @param document
 * @param offset
 * @param defaultWordDetector
 * @return
 */
public static IRegion getRegionExpandedBoth(IDocument document, int documentOffset, IWordDetector detector)
{
    IRegion backwards = getRegionExpandedBackwards(document, documentOffset, detector);
    IRegion forwards = getRegionExpandedForwards(document, documentOffset, detector);
    return new Region(backwards.getOffset(), backwards.getLength() + forwards.getLength());
}
项目:Eclipse-Postfix-Code-Completion    文件:CombinedWordRule.java   
/**
 * Creates a rule which, with the help of an word detector, will return the token
 * associated with the detected word. If no token has been associated, the
 * specified default token will be returned.
 *
 * @param detector the word detector to be used by this rule, may not be <code>null</code>
 * @param matcher the initial word matcher
 * @param defaultToken the default token to be returned on success
 *      if nothing else is specified, may not be <code>null</code>
 *
 * @see WordMatcher#addWord(String, IToken)
 */
public CombinedWordRule(IWordDetector detector, WordMatcher matcher, IToken defaultToken) {

    Assert.isNotNull(detector);
    Assert.isNotNull(defaultToken);

    fDetector= detector;
    fDefaultToken= defaultToken;
    if (matcher != null)
        addWordMatcher(matcher);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CombinedWordRule.java   
/**
 * Creates a rule which, with the help of an word detector, will return the token
 * associated with the detected word. If no token has been associated, the
 * specified default token will be returned.
 *
 * @param detector the word detector to be used by this rule, may not be <code>null</code>
 * @param matcher the initial word matcher
 * @param defaultToken the default token to be returned on success
 *      if nothing else is specified, may not be <code>null</code>
 *
 * @see WordMatcher#addWord(String, IToken)
 */
public CombinedWordRule(IWordDetector detector, WordMatcher matcher, IToken defaultToken) {

    Assert.isNotNull(detector);
    Assert.isNotNull(defaultToken);

    fDetector= detector;
    fDefaultToken= defaultToken;
    if (matcher != null)
        addWordMatcher(matcher);
}
项目:egradle    文件:AbstractGroovyBasedDocumentPartitionScanner.java   
private void buildAnnotationRules(List<IPredicateRule> rules, IToken token, IWordDetector wordDetector) {
    rules.add(new WordPatternRule(wordDetector, "@", "", token));

}
项目:APICloud-Studio    文件:TagWordRule.java   
/**
 * @param detector
 * @param defaultToken
 * @param ignoreCase
 */
public TagWordRule(IWordDetector detector, IToken defaultToken, boolean ignoreCase)
{
    super(detector, defaultToken, ignoreCase);
}
项目:APICloud-Studio    文件:ExtendedWordRule.java   
/**
 * Creates a rule which, with the help of a word detector, will return the
 * token associated with the detected word. If no token has been associated,
 * the specified default token will be returned.
 * 
 * @param detector
 *            the word detector to be used by this rule, may not be
 *            <code>null</code>
 * @param defaultToken
 *            the default token to be returned on success if nothing else is
 *            specified, may not be <code>null</code>
 * @param ignoreCase
 *            the case sensitivity associated with this rule
 * @see #addWord(String, IToken)
 */
protected ExtendedWordRule(IWordDetector detector, IToken defaultToken, boolean ignoreCase) {
    super(detector, defaultToken, ignoreCase);
    this.ignoreCase = ignoreCase;
}
项目:Eclipse-Postfix-Code-Completion    文件:CombinedWordRule.java   
/**
 * Creates a rule which, with the help of an word detector, will return the token
 * associated with the detected word. If no token has been associated, the scanner
 * will be rolled back and an undefined token will be returned in order to allow
 * any subsequent rules to analyze the characters.
 *
 * @param detector the word detector to be used by this rule, may not be <code>null</code>
 *
 * @see WordMatcher#addWord(String, IToken)
 */
public CombinedWordRule(IWordDetector detector) {
    this(detector, null, Token.UNDEFINED);
}
项目:Eclipse-Postfix-Code-Completion    文件:CombinedWordRule.java   
/**
 * Creates a rule which, with the help of an word detector, will return the token
 * associated with the detected word. If no token has been associated, the
 * specified default token will be returned.
 *
 * @param detector the word detector to be used by this rule, may not be <code>null</code>
 * @param defaultToken the default token to be returned on success
 *      if nothing else is specified, may not be <code>null</code>
 *
 * @see WordMatcher#addWord(String, IToken)
 */
public CombinedWordRule(IWordDetector detector, IToken defaultToken) {
    this(detector, null, defaultToken);
}
项目:Eclipse-Postfix-Code-Completion    文件:CombinedWordRule.java   
/**
 * Creates a rule which, with the help of an word detector, will return the token
 * associated with the detected word. If no token has been associated, the scanner
 * will be rolled back and an undefined token will be returned in order to allow
 * any subsequent rules to analyze the characters.
 *
 * @param detector the word detector to be used by this rule, may not be <code>null</code>
 * @param matcher the initial word matcher
 *
 * @see WordMatcher#addWord(String, IToken)
 */
public CombinedWordRule(IWordDetector detector, WordMatcher matcher) {
    this(detector, matcher, Token.UNDEFINED);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CombinedWordRule.java   
/**
 * Creates a rule which, with the help of an word detector, will return the token
 * associated with the detected word. If no token has been associated, the scanner
 * will be rolled back and an undefined token will be returned in order to allow
 * any subsequent rules to analyze the characters.
 *
 * @param detector the word detector to be used by this rule, may not be <code>null</code>
 *
 * @see WordMatcher#addWord(String, IToken)
 */
public CombinedWordRule(IWordDetector detector) {
    this(detector, null, Token.UNDEFINED);
}