本文整理汇总了Java中org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java ContentAssistInvocationContext.getDocument方法的具体用法?Java ContentAssistInvocationContext.getDocument怎么用?Java ContentAssistInvocationContext.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext
的用法示例。
在下文中一共展示了ContentAssistInvocationContext.getDocument方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: computeCompletionProposals
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入方法依赖的package包/类
@Override
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
ArrayList<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
System.out.println(context);
if (context instanceof JavaContentAssistInvocationContext) {
JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;
try {
if (UmletPluginUtils.hasUmletNature(javaContext.getProject())) {
IDocument document = context.getDocument();
if (document != null) {
computeCompletionProposals(javaContext, document, proposals);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return proposals;
}
示例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 - 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
示例4: 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
示例5: 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);
}
示例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);
}
示例7: 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
示例8: 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