protected int guessContextInformationPosition(ContentAssistInvocationContext context) { return context.getInvocationOffset(); }
protected int guessContextInformationPosition(ContentAssistInvocationContext context) { return context.getInvocationOffset(); }
protected int guessContextInformationPosition(ContentAssistInvocationContext context) { return context.getInvocationOffset(); }
@Override public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { if (context instanceof JavaContentAssistInvocationContext) { JavaContentAssistInvocationContext javaContext= (JavaContentAssistInvocationContext) context; return internalComputeCompletionProposals(context.getInvocationOffset(), javaContext); } return Collections.emptyList(); }
@Override public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { if (context instanceof JavaContentAssistInvocationContext) { JavaContentAssistInvocationContext javaContext= (JavaContentAssistInvocationContext) context; return internalComputeCompletionProposals(context.getInvocationOffset(), javaContext); } return Collections.emptyList(); }
public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { if (context instanceof JavaContentAssistInvocationContext) { JavaContentAssistInvocationContext javaContext= (JavaContentAssistInvocationContext) context; return internalComputeCompletionProposals(context.getInvocationOffset(), javaContext, monitor); } return Collections.EMPTY_LIST; }
@Override public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { return Arrays.asList(fProcessor.computeCompletionProposals(context.getViewer(), context.getInvocationOffset())); }
@Override public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) { return Arrays.asList(fProcessor.computeContextInformation(context.getViewer(), context.getInvocationOffset())); }
public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { return Arrays.asList(fProcessor.computeCompletionProposals(context.getViewer(), context.getInvocationOffset())); }
public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) { return Arrays.asList(fProcessor.computeContextInformation(context.getViewer(), context.getInvocationOffset())); }
@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; }
@Override public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { return Arrays.asList(fProcessor.computeCompletionProposals(context.getViewer(), context.getInvocationOffset())); }
@Override public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) { return Arrays.asList(fProcessor.computeContextInformation(context.getViewer(), context.getInvocationOffset())); }
@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; }
/** * Computes the identifier (as specified by {@link Character#isJavaIdentifierPart(char)}) that * immediately precedes the invocation offset. * * @return the prefix preceding the content assist invocation offset, <code>null</code> if * there is no document * @throws BadLocationException if accessing the document fails */ public CharSequence computeIdentifierPrefix() throws BadLocationException { if (fPrefix == null) { IDocument document= getDocument(); if (document == null) return null; int end= getInvocationOffset(); int start= end; while (--start >= 0) { if (!Character.isJavaIdentifierPart(document.getChar(start))) break; } start++; fPrefix= document.get(start, end - start); } return fPrefix; }
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; }
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; }
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 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 super.guessContextInformationPosition(context); } }
private MockMethodCompletionProposal createMockMethodProposal(final ContentAssistInvocationContext context, final ITypeBinding paramType, final ICompilationUnit cunit, final String prefix, final IMethodBinding meth, final String methodName) throws JavaModelException { String params = getParameters(meth); StyledString displayName = new StyledString(methodName + "(" + params + ") : " + meth.getReturnType().getName() ); String desc = meth.isConstructor() ? "constructor" : "method"; displayName.append(" - Mock " + desc + " of '" + paramType.getName() +"'", QUALIFIER_STYLER); String completionProposal = meth.getReturnType().getName() + " " + methodName; MockMethodCompletionProposal proposal = new MockMethodCompletionProposal(cunit, meth, context.getInvocationOffset()-prefix.length(), prefix.length(), displayName, completionProposal); return proposal; }
@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); }