当前位置: 首页>>代码示例>>Java>>正文


Java IDocument.getChar方法代码示例

本文整理汇总了Java中org.eclipse.jface.text.IDocument.getChar方法的典型用法代码示例。如果您正苦于以下问题:Java IDocument.getChar方法的具体用法?Java IDocument.getChar怎么用?Java IDocument.getChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.text.IDocument的用法示例。


在下文中一共展示了IDocument.getChar方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractPrefix

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
protected String extractPrefix(ITextViewer viewer, int offset) {
    int i = offset;
    IDocument document = viewer.getDocument();
    if (i > document.getLength()) {
        return ""; //$NON-NLS-1$
    }
    try {
        while (i > 0) {
            char ch = document.getChar(i - 1);
            if (!PgDiffUtils.isValidIdChar(ch)) {
                break;
            }
            i--;
        }
        if (i > 0) {
            int j = i;
            if (document.getChar(j - 1) == '<') {
                i--;
            }
        }
        return document.get(i, offset - i);
    } catch (BadLocationException e) {
        return ""; //$NON-NLS-1$
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:27,代码来源:SQLEditorTemplateAssistProcessor.java

示例2: findCharReverse

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
private int findCharReverse(char c, IDocument doc, int offset) {
	try {
		while (offset-- > 0) {
			char current = doc.getChar(offset);
			if (current == c)
				return offset;
		}
		return -1;
	} catch (BadLocationException e) {
		// TODO Auto-generated catch block
		return -1;
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:14,代码来源:CtfCompletionProposalsComputer.java

示例3: computeCompletionProposals

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
		IProgressMonitor monitor) {
	String prefix = "";
	try {
		if (context != null) {
			prefix = context.computeIdentifierPrefix().toString();

			String tmpPrefix = "";
			IDocument doc = context.getDocument();
			if ((!prefix.equals("")) || (doc.get().length() == 0)) {
				tmpPrefix = prefix;
			} else {
				int offset = context.getInvocationOffset();
				if (doc.getChar(offset - 1) == '.') {
					tmpPrefix = ".";
					if (offset >= CONTEXT_PREFIX.length()
							&& doc.get(offset - CONTEXT_PREFIX.length(), CONTEXT_PREFIX.length()).equals(
									CONTEXT_PREFIX)) {
						tmpPrefix = CONTEXT_PREFIX;
					}
				}
			}
			prefix = tmpPrefix;

		}
	} catch (BadLocationException e) {
		throw new RuntimeException(e);
	}

	return computeCompletionProposals(context.getViewer(), prefix, context.getInvocationOffset(), monitor);
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:33,代码来源:HydrographCompletionProposalComputer.java

示例4: isInsertClosingBracket

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public boolean isInsertClosingBracket(IDocument doc, int offset) throws BadLocationException {
	if (doc.getLength() <= offset)
		return true;
	char charAtOffset = doc.getChar(offset);
	boolean result = !Character.isDigit(charAtOffset);
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:9,代码来源:IntStrategyPredicate.java

示例5: computeCompletionProposals

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
	final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
	try {
		final IDocument document = viewer.getDocument();
		Character c = document.getChar(offset - 1);
		int temp = offset - 1;
		String s = "";

		if (Character.isAlphabetic(c)) {
			while (Character.isAlphabetic(c)) {
				s += c;
				temp--;
				c = document.getChar(temp);
			}
			s = new StringBuilder(s).reverse().toString();

			for (int i = 0; i < FormulasScanner.formulasKeywords.length; i++) {
				if (FormulasScanner.formulasKeywords[i].startsWith(s)) {
					proposals.add(new CompletionProposal(FormulasScanner.formulasKeywords[i], temp + 1, s.length(),
							FormulasScanner.formulasKeywords[i].length()));
				}
			}
		} else if (c == '(') {
			document.replace(temp, 1, "()");
		} else if (c == '[') {
			document.replace(temp, 1, "[]");
		}

		if (proposals.isEmpty() && s == "") {
			for (int i = 0; i < FormulasScanner.formulasKeywords.length; i++) {
				proposals.add(new CompletionProposal(FormulasScanner.formulasKeywords[i], temp + 1, s.length(),
						FormulasScanner.formulasKeywords[i].length()));
			}
		}

	} catch (final BadLocationException e) {
		e.printStackTrace();
	}
	final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
	proposals.toArray(result);
	return result;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:44,代码来源:CodeCompletionProcessor.java

示例6: computeCompletionProposals

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
    final int offset) {

  final List<ICompletionProposal> proposals = new ArrayList<>();
  try {
    final IDocument document = viewer.getDocument();

    // we try to find the prefix of keyword which is edited in text.
    // we look from last to first offset, if the 'c' is non-alphabetic then stop.
    // Ex: if user write "{on" we take "on" then search the keywords which are acceptable for this
    // prefix.
    Character c = document.getChar(offset - 1);
    int temp = offset - 1;
    String s = "";

    if (Character.isAlphabetic(c)) {
      while (Character.isAlphabetic(c)) {
        s += c;
        temp--;
        c = document.getChar(temp);
      }
      s = new StringBuilder(s).reverse().toString();

      for (int i = 0; i < SentencesScanner.keywords.length; i++) {
        if (SentencesScanner.keywords[i].startsWith(s)) {
          proposals.add(new CompletionProposal(SentencesScanner.keywords[i], temp + 1, s.length(),
              SentencesScanner.keywords[i].length()));
        }
      }

      for (final String relationName : ValidationEditor.getRelationNames()) {
        if (relationName.toLowerCase().startsWith(s.toLowerCase())) {
          proposals.add(
              new CompletionProposal(relationName, temp + 1, s.length(), relationName.length()));
        }
      }

      for (final String atomName : ValidationEditor.getAtomNames()) {
        if (atomName.toLowerCase().startsWith(s.toLowerCase())) {
          proposals
              .add(new CompletionProposal(atomName, temp + 1, s.length(), atomName.length()));
        }
      }
    }

    // proposals list is still empty, ok then give all keywords like java does.
    if (proposals.isEmpty()) {
      for (int i = 0; i < SentencesScanner.keywords.length; i++) {
        proposals.add(new CompletionProposal(SentencesScanner.keywords[i], temp + 1, s.length(),
            SentencesScanner.keywords[i].length()));
      }
    }
  } catch (final BadLocationException e) {
    e.printStackTrace();
  }
  final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
  proposals.toArray(result);
  return result;

}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:62,代码来源:DefaultCompletionProcessor.java

示例7: computeCompletionProposals

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
    final int offset) {
  final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
  try {
    final IDocument document = viewer.getDocument();
    Character c = document.getChar(offset - 1);
    int temp = offset - 1;
    String s = "";

    if (Character.isAlphabetic(c)) {
      while (Character.isAlphabetic(c)) {
        s += c;
        temp--;
        c = document.getChar(temp);
      }
      s = new StringBuilder(s).reverse().toString();

      for (int i = 0; i < CodeScanner.keywords.length; i++) {
        if (CodeScanner.keywords[i].startsWith(s)) {
          proposals.add(new CompletionProposal(CodeScanner.keywords[i], temp + 1, s.length(),
              CodeScanner.keywords[i].length()));
        }
      }
    } else if (c == '(') {
      document.replace(temp, 1, "()");
    } else if (c == '{') {
      document.replace(temp, 1, "{\n\n}");
    }

    if (proposals.isEmpty() && s == "") {
      for (int i = 0; i < CodeScanner.keywords.length; i++) {
        proposals.add(new CompletionProposal(CodeScanner.keywords[i], temp + 1, s.length(),
            CodeScanner.keywords[i].length()));
      }
    }

  } catch (final BadLocationException e) {
    e.printStackTrace();
  }
  final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
  proposals.toArray(result);
  return result;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:45,代码来源:CodeCompletionProcessor.java

示例8: computeCompletionProposals

import org.eclipse.jface.text.IDocument; //导入方法依赖的package包/类
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer,
    final int offset) {
  final List<ICompletionProposal> proposals = new ArrayList<>();
  try {
    final IDocument document = viewer.getDocument();

    // we try to find the prefix of keyword which is edited in text.
    // we look from last to first offset, if the 'c' is non-alphabetic then stop.
    // Ex: if user write "{on" we take "on" then search the keywords which are acceptable for this
    // prefix.
    Character c = document.getChar(offset - 1);
    int temp = offset - 1;
    StringBuilder builder = new StringBuilder();

    if (Character.isAlphabetic(c)) {
      while (Character.isAlphabetic(c)) {
        builder.append(c);
        temp--;
        c = document.getChar(temp);
      }
      builder = builder.reverse();

      for (int i = 0; i < DefaultScanner.keywords.length; i++) {
        if (DefaultScanner.keywords[i].startsWith(builder.toString())) {
          proposals.add(new CompletionProposal(DefaultScanner.keywords[i], temp + 1,
              builder.length(), DefaultScanner.keywords[i].length()));
        }
      }
    } else {
      // if the last edited char is non-alphabetic then may be user wants the relation list.
      for (int i = 0; i < this.activationChars.length; i++) {
        if (this.activationChars[i] == c) {
          for (final String rel : AlloyParserForMetamodel.getRels()) {
            proposals.add(new CompletionProposal(rel, temp + 1, builder.length(), rel.length()));
          }
          break;
        }
      }
    }
  } catch (final BadLocationException e) {
    e.printStackTrace();
  }
  final ICompletionProposal[] result = new ICompletionProposal[proposals.size()];
  proposals.toArray(result);
  return result;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:48,代码来源:DefaultCompletionProcessor.java


注:本文中的org.eclipse.jface.text.IDocument.getChar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。