當前位置: 首頁>>代碼示例>>Java>>正文


Java IWordDetector類代碼示例

本文整理匯總了Java中org.eclipse.jface.text.rules.IWordDetector的典型用法代碼示例。如果您正苦於以下問題:Java IWordDetector類的具體用法?Java IWordDetector怎麽用?Java IWordDetector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IWordDetector類屬於org.eclipse.jface.text.rules包,在下文中一共展示了IWordDetector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getWord

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:ninneko,項目名稱:velocity-edit,代碼行數:30,代碼來源:EditorsUtil.java

示例2: getRegionExpandedBackwards

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:37,代碼來源:DocumentHelper.java

示例3: getRegionExpandedForwards

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:37,代碼來源:DocumentHelper.java

示例4: createWordRule

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
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);
}
 
開發者ID:Johnnei,項目名稱:GLSL-Eclipse,代碼行數:15,代碼來源:GlslScanners.java

示例5: createKeywordRule

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
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;
}
 
開發者ID:yinonavraham,項目名稱:myLOGO4Eclipse,代碼行數:14,代碼來源:LogoScriptSourceViewerConfiguration.java

示例6: PyWordRule

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:27,代碼來源:PyWordRule.java

示例7: ExactWordPatternRule

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
public ExactWordPatternRule(IWordDetector detector, String exactWord, IToken token) {
	this(detector,exactWord,token,true);
}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:4,代碼來源:ExactWordPatternRule.java

示例8: VariableDefKeyWordPatternRule

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
public VariableDefKeyWordPatternRule(IWordDetector detector, String exactWord, IToken token) {
	this(detector,exactWord,token,true);
}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:4,代碼來源:VariableDefKeyWordPatternRule.java

示例9: ExactWordPatternRule

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
public ExactWordPatternRule(IWordDetector detector, String exactWord, IToken token) {
	super(detector, exactWord, null, token);
	toStringValue=getClass().getSimpleName()+":"+exactWord;
}
 
開發者ID:de-jcup,項目名稱:egradle,代碼行數:5,代碼來源:ExactWordPatternRule.java

示例10: buildWordRules

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
protected void buildWordRules(List<IPredicateRule> rules, IToken token, DocumentKeyWord[] values,
		IWordDetector wordDetector) {
	for (DocumentKeyWord keyWord : values) {
		rules.add(new ExactWordPatternRule(wordDetector, createWordStart(keyWord), token));
	}
}
 
開發者ID:de-jcup,項目名稱:egradle,代碼行數:7,代碼來源:AbstractGroovyBasedDocumentPartitionScanner.java

示例11: getDefaultWordDetector

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
/**
 * Factory method for the word detector
 */
public static IWordDetector getDefaultWordDetector()
{
    return new TLAWordDetector();
}
 
開發者ID:tlaplus,項目名稱:tlaplus,代碼行數:8,代碼來源:DocumentHelper.java

示例12: BTSTextTokenRule

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
public BTSTextTokenRule(IWordDetector detector, String startSequence, String endSequence, IToken token)
{
	super(detector, startSequence, endSequence, token);
	// TODO Auto-generated constructor stub
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:6,代碼來源:BTSTextTokenRule.java

示例13: VendorPropertyWordRule

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
private VendorPropertyWordRule(IWordDetector detector, IToken defaultToken, boolean ignoreCase)
{
	super(detector, defaultToken, ignoreCase);
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:5,代碼來源:CSSCodeScannerRuleBased.java

示例14: promptForNewElements

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
/**
 * 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()]));
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:64,代碼來源:AddRemoveList.java

示例15: TagStartRule

import org.eclipse.jface.text.rules.IWordDetector; //導入依賴的package包/類
private TagStartRule(IWordDetector detector, IToken defaultToken, boolean ignoreCase)
{
	super(detector, defaultToken, ignoreCase);
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:5,代碼來源:HTMLDoctypeScanner.java


注:本文中的org.eclipse.jface.text.rules.IWordDetector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。