本文整理汇总了Java中org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext类的典型用法代码示例。如果您正苦于以下问题:Java ContentAssistInvocationContext类的具体用法?Java ContentAssistInvocationContext怎么用?Java ContentAssistInvocationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentAssistInvocationContext类属于org.eclipse.jdt.ui.text.java包,在下文中一共展示了ContentAssistInvocationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeCompletionProposals
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入依赖的package包/类
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
List<ICompletionProposal> propList = new ArrayList<ICompletionProposal>();
List<ICompletionProposal> newpropList = new ArrayList<ICompletionProposal>();
List<IContextInformation> propList2 = new ArrayList<IContextInformation>();
ICompletionProposal first;
DataManager datamanger = new DataManager(context,monitor);
Activator.applyoperationlist.add(new ApplyOperation(ConsoleOperationListener2.ope.getStart(), ConsoleOperationListener2.ope.getAuthor(), ConsoleOperationListener2.ope.getFilePath(), propList));
List<String> list = new ArrayList();
CompletionProposal proposal;
propList = datamanger.JavaDefaultProposal();
propList2 = datamanger.ContextInformation();
ApplyOperation ao = new ApplyOperation(ConsoleOperationListener2.ope.getStart(), ConsoleOperationListener2.ope.getAuthor(), ConsoleOperationListener2.ope.getFilePath(), propList);
System.out.println(ao.toString());
return newpropList;
}
示例2: createContext
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入依赖的package包/类
@Override
protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset)
{
ICompilationUnit compilationUnit = ((SourceViewer) viewer).getCompilatioUnit();
if (compilationUnit != null) {
CompletionProposalCollector completionProposalCollector = new CompletionProposalCollector(compilationUnit);
JavaContentAssistInvocationContext invocContext = new JavaContentAssistInvocationContext(viewer, offset,
new NullEditorPart());
completionProposalCollector.setInvocationContext(invocContext);
return invocContext;
} else {
return null;
}
}
示例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;
}
示例4: 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;
}
示例5: collectProposals
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入依赖的package包/类
/**
* Collects the proposals.
*
* @param viewer the text viewer
* @param offset the offset
* @param monitor the progress monitor
* @param context the code assist invocation context
* @return the list of proposals
*/
private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) {
boolean needsSortingAfterFiltering= false;
List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>();
List<CompletionProposalCategory> providers= getCategories();
for (CompletionProposalCategory cat : providers) {
List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1));
proposals.addAll(computed);
needsSortingAfterFiltering= needsSortingAfterFiltering || (cat.isSortingAfterFilteringNeeded() && !computed.isEmpty());
if (fErrorMessage == null)
fErrorMessage= cat.getErrorMessage();
}
if (fNeedsSortingAfterFiltering && !needsSortingAfterFiltering)
fAssistant.setSorter(null);
fNeedsSortingAfterFiltering= needsSortingAfterFiltering;
return proposals;
}
示例6: 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
示例7: computeCompletionProposals
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入依赖的package包/类
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
if (!(context instanceof JavadocContentAssistInvocationContext))
return Collections.emptyList();
JavadocContentAssistInvocationContext docContext= (JavadocContentAssistInvocationContext) context;
int flags= docContext.getFlags();
fCurrentPos= docContext.getInvocationOffset();
fCurrentLength= docContext.getSelectionLength();
fRestrictToMatchingCase= (flags & IJavadocCompletionProcessor.RESTRICT_TO_MATCHING_CASE) != 0;
ICompilationUnit cu= docContext.getCompilationUnit();
if (cu == null)
return Collections.emptyList();
fDocument= docContext.getDocument();
if (fDocument == null) {
return Collections.emptyList();
}
try {
fResult= new ArrayList<ICompletionProposal>(100);
evalProposals();
return fResult;
} finally {
fResult= null;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:HTMLTagCompletionProposalComputer.java
示例8: collectProposals
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入依赖的package包/类
/**
* Collects the proposals.
*
* @param viewer the text viewer
* @param offset the offset
* @param monitor the progress monitor
* @param context the code assist invocation context
* @return the list of proposals
*/
private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) {
boolean needsSortingAfterFiltering= false;
List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>();
List<CompletionProposalCategory> providers= getCategories();
for (Iterator<CompletionProposalCategory> it= providers.iterator(); it.hasNext();) {
CompletionProposalCategory cat= it.next();
List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1));
proposals.addAll(computed);
needsSortingAfterFiltering= needsSortingAfterFiltering || (cat.isSortingAfterFilteringNeeded() && !computed.isEmpty());
if (fErrorMessage == null)
fErrorMessage= cat.getErrorMessage();
}
if (fNeedsSortingAfterFiltering && !needsSortingAfterFiltering)
fAssistant.setSorter(null);
fNeedsSortingAfterFiltering= needsSortingAfterFiltering;
return proposals;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:27,代码来源:ContentAssistProcessor.java
示例9: 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
示例10: 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);
}
示例11: 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;
}
示例12: computeContextInformation
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入依赖的package包/类
public List<IContextInformation> computeContextInformation(
ContentAssistInvocationContext context, IProgressMonitor monitor) {
if (context instanceof JavaContentAssistInvocationContext) {
JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;
int contextInformationPosition = guessContextInformationPosition(javaContext);
List<IContextInformation> result =
addContextInformations(javaContext, contextInformationPosition);
return result;
}
return Collections.emptyList();
}
示例13: computeCompletionProposals
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入依赖的package包/类
public List<ICompletionProposal> computeCompletionProposals(
ContentAssistInvocationContext context, IProgressMonitor monitor) {
if (context instanceof JavaContentAssistInvocationContext) {
JavaContentAssistInvocationContext javaContext = (JavaContentAssistInvocationContext) context;
return internalComputeCompletionProposals(context.getInvocationOffset(), javaContext);
}
return Collections.emptyList();
}
示例14: 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);
}
示例15: computeCompletionProposals
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; //导入依赖的package包/类
public final ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
long start= DEBUG ? System.currentTimeMillis() : 0;
clearState();
IProgressMonitor monitor= createProgressMonitor();
monitor.beginTask(JavaTextMessages.ContentAssistProcessor_computing_proposals, fCategories.size() + 1);
ContentAssistInvocationContext context= createContext(viewer, offset);
long setup= DEBUG ? System.currentTimeMillis() : 0;
monitor.subTask(JavaTextMessages.ContentAssistProcessor_collecting_proposals);
List<ICompletionProposal> proposals= collectProposals(viewer, offset, monitor, context);
long collect= DEBUG ? System.currentTimeMillis() : 0;
monitor.subTask(JavaTextMessages.ContentAssistProcessor_sorting_proposals);
if (fNeedsSortingAfterFiltering)
setContentAssistSorter();
else
proposals= sortProposals(proposals, monitor, context);
fNumberOfComputedResults= proposals.size();
long filter= DEBUG ? System.currentTimeMillis() : 0;
ICompletionProposal[] result= proposals.toArray(new ICompletionProposal[proposals.size()]);
monitor.done();
if (DEBUG) {
System.err.println("Code Assist Stats (" + result.length + " proposals)"); //$NON-NLS-1$ //$NON-NLS-2$
System.err.println("Code Assist (setup):\t" + (setup - start) ); //$NON-NLS-1$
System.err.println("Code Assist (collect):\t" + (collect - setup) ); //$NON-NLS-1$
System.err.println("Code Assist (sort):\t" + (filter - collect) ); //$NON-NLS-1$
}
return result;
}