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


Java ContentAssistInvocationContext.getInvocationOffset方法代码示例

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


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

示例1: guessMethodContextInformationPosition

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
protected final int guessMethodContextInformationPosition(
    ContentAssistInvocationContext context) {
  final int contextPosition = context.getInvocationOffset();

  IDocument document = context.getDocument();
  JavaHeuristicScanner scanner = new JavaHeuristicScanner(document);
  int bound = Math.max(-1, contextPosition - 2000);

  // try the innermost scope of parentheses that looks like a method call
  int pos = contextPosition - 1;
  do {
    int paren = scanner.findOpeningPeer(pos, bound, '(', ')');
    if (paren == JavaHeuristicScanner.NOT_FOUND) break;
    int token = scanner.previousToken(paren - 1, bound);
    // next token must be a method name (identifier) or the closing angle of a
    // constructor call of a parameterized type.
    if (token == Symbols.TokenIDENT || token == Symbols.TokenGREATERTHAN) return paren + 1;
    pos = paren - 1;
  } while (true);

  return contextPosition;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:JavaCompletionProposalComputer.java

示例2: guessMethodContextInformationPosition

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
protected final int guessMethodContextInformationPosition(ContentAssistInvocationContext context) {
	final int contextPosition= context.getInvocationOffset();

	IDocument document= context.getDocument();
	JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
	int bound= Math.max(-1, contextPosition - 2000);

	// try the innermost scope of parentheses that looks like a method call
	int pos= contextPosition - 1;
	do {
		int paren= scanner.findOpeningPeer(pos, bound, '(', ')');
		if (paren == JavaHeuristicScanner.NOT_FOUND)
			break;
		int token= scanner.previousToken(paren - 1, bound);
		// next token must be a method name (identifier) or the closing angle of a
		// constructor call of a parameterized type.
		if (token == Symbols.TokenIDENT || token == Symbols.TokenGREATERTHAN)
			return paren + 1;
		pos= paren - 1;
	} while (true);

	return contextPosition;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:JavaCompletionProposalComputer.java

示例3: guessMethodContextInformationPosition

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
protected final int guessMethodContextInformationPosition(ContentAssistInvocationContext context) {
	final int contextPosition= context.getInvocationOffset();

	IDocument document= context.getDocument();
	JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
	int bound= Math.max(-1, contextPosition - 200);

	// try the innermost scope of parentheses that looks like a method call
	int pos= contextPosition - 1;
	do {
		int paren= scanner.findOpeningPeer(pos, bound, '(', ')');
		if (paren == JavaHeuristicScanner.NOT_FOUND)
			break;
		int token= scanner.previousToken(paren - 1, bound);
		// next token must be a method name (identifier) or the closing angle of a
		// constructor call of a parameterized type.
		if (token == Symbols.TokenIDENT || token == Symbols.TokenGREATERTHAN)
			return paren + 1;
		pos= paren - 1;
	} while (true);

	return contextPosition;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:24,代码来源:JavaCompletionProposalComputer.java

示例4: computeCompletionProposals

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的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

示例5: guessContextInformationPosition

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
@Override
protected int guessContextInformationPosition(ContentAssistInvocationContext context) {
  int invocationOffset = context.getInvocationOffset();
  int typeContext = super.guessContextInformationPosition(context);
  int methodContext = guessMethodContextInformationPosition(context);
  if (typeContext != invocationOffset && typeContext > methodContext) return typeContext;
  else if (methodContext != invocationOffset) return methodContext;
  else return invocationOffset;
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:JavaAllCompletionProposalComputer.java

示例6: guessContextInformationPosition

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
@Override
protected int guessContextInformationPosition(ContentAssistInvocationContext context) {
  final int contextPosition = context.getInvocationOffset();

  IDocument document = context.getDocument();
  JavaHeuristicScanner scanner = new JavaHeuristicScanner(document);
  int bound = Math.max(-1, contextPosition - 200);

  // try the innermost scope of angle brackets that looks like a generic type argument list
  try {
    int pos = contextPosition - 1;
    do {
      int angle = scanner.findOpeningPeer(pos, bound, '<', '>');
      if (angle == JavaHeuristicScanner.NOT_FOUND) break;
      int token = scanner.previousToken(angle - 1, bound);
      // next token must be a method name that is a generic type
      if (token == Symbols.TokenIDENT) {
        int off = scanner.getPosition() + 1;
        int end = angle;
        String ident = document.get(off, end - off).trim();
        if (JavaHeuristicScanner.isGenericStarter(ident)) return angle + 1;
      }
      pos = angle - 1;
    } while (true);
  } catch (BadLocationException x) {
  }

  return super.guessContextInformationPosition(context);
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:JavaTypeCompletionProposalComputer.java

示例7: guessContextInformationPosition

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
@Override
protected int guessContextInformationPosition(ContentAssistInvocationContext context) {
	int invocationOffset= context.getInvocationOffset();
	int typeContext= super.guessContextInformationPosition(context);
	int methodContext= guessMethodContextInformationPosition(context);
	if (typeContext != invocationOffset && typeContext > methodContext)
		return typeContext;
	else if (methodContext != invocationOffset)
		return methodContext;
	else
		return invocationOffset;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:JavaAllCompletionProposalComputer.java

示例8: guessContextInformationPosition

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
@Override
protected int guessContextInformationPosition(ContentAssistInvocationContext context) {
	final int contextPosition= context.getInvocationOffset();

	IDocument document= context.getDocument();
	JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
	int bound= Math.max(-1, contextPosition - 200);

	// try the innermost scope of angle brackets that looks like a generic type argument list
	try {
		int pos= contextPosition - 1;
		do {
			int angle= scanner.findOpeningPeer(pos, bound, '<', '>');
			if (angle == JavaHeuristicScanner.NOT_FOUND)
				break;
			int token= scanner.previousToken(angle - 1, bound);
			// next token must be a method name that is a generic type
			if (token == Symbols.TokenIDENT) {
				int off= scanner.getPosition() + 1;
				int end= angle;
				String ident= document.get(off, end - off).trim();
				if (JavaHeuristicScanner.isGenericStarter(ident))
					return angle + 1;
			}
			pos= angle - 1;
		} while (true);
	} catch (BadLocationException x) {
	}

	return super.guessContextInformationPosition(context);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:JavaTypeCompletionProposalComputer.java

示例9: guessContextInformationPosition

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
protected int guessContextInformationPosition(ContentAssistInvocationContext context) {
  return context.getInvocationOffset();
}
 
开发者ID:eclipse,项目名称:che,代码行数:4,代码来源:JavaCompletionProposalComputer.java

示例10: guessContextInformationPosition

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
protected int guessContextInformationPosition(ContentAssistInvocationContext context) {
	return context.getInvocationOffset();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:4,代码来源:JavaCompletionProposalComputer.java

示例11: computeCompletionProposals

import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
	if (contributes()) {
		try {
			IDocument document= context.getDocument();
			final int offset= context.getInvocationOffset();

			final IRegion region= document.getLineInformationOfOffset(offset);
			final String content= document.get(region.getOffset(), region.getLength());

			int index= offset - region.getOffset() - 1;
			while (index >= 0 && Character.isLetter(content.charAt(index)))
				index--;

			final int start= region.getOffset() + index + 1;
			final String candidate= content.substring(index + 1, offset - region.getOffset());

			if (candidate.length() > 0) {

				final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
				final ISpellChecker checker= engine.getSpellChecker();

				if (checker != null) {

					final List<RankedWordProposal> proposals= new ArrayList<RankedWordProposal>(checker.getProposals(candidate, Character.isUpperCase(candidate.charAt(0))));
					final List<ICompletionProposal> result= new ArrayList<ICompletionProposal>(proposals.size());

					for (Iterator<RankedWordProposal> it= proposals.iterator(); it.hasNext();) {
						RankedWordProposal word= it.next();
						String text= word.getText();
						if (text.startsWith(candidate))
							word.setRank(word.getRank() + PREFIX_RANK_SHIFT);

						result.add(new JavaCompletionProposal(text, start, candidate.length(), JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_RENAME), text, word.getRank()) {
							/*
							 * @see org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
							 */
							@Override
							public boolean validate(IDocument doc, int validate_offset, DocumentEvent event) {
								return offset == validate_offset;
							}
						});
					}

					return result;
				}
			}
		} catch (BadLocationException exception) {
			// log & ignore
			JavaPlugin.log(exception);
		}
	}
	return Collections.emptyList();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:54,代码来源:WordCompletionProposalComputer.java


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