/** * Returns the {@link CompletionContext core completion context} if available, <code>null</code> * otherwise. * <p> * <strong>Note:</strong> This method may run * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete} * on the compilation unit. * </p> * * @return the core completion context if available, <code>null</code> otherwise */ public CompletionContext getCoreContext() { if (fCoreContext == null) { // use the context from the existing collector if it exists, retrieve one ourselves otherwise if (fCollector != null) fCoreContext= fCollector.getContext(); if (fCoreContext == null) computeKeywordsAndContext(); } return fCoreContext; }
/** * Returns the {@link CompletionContext core completion context} if available, <code>null</code> * otherwise. * <p> * <strong>Note:</strong> This method may run * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete} * on the compilation unit. * </p> * * @return the core completion context if available, <code>null</code> otherwise */ public CompletionContext getCoreContext() { if (fCollector != null) { CompletionContext context= fCollector.getContext(); if (context != null) { if (fCoreContext == null) fCoreContext= context; return context; } } if (fCoreContext == null) computeKeywordsAndContext(); // Retrieve the context ourselves return fCoreContext; }
/** * Returns the {@link CompletionContext core completion context} if available, <code>null</code> * otherwise. * <p> * <strong>Note:</strong> This method may run * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete} * on the compilation unit. * </p> * * @return the core completion context if available, <code>null</code> otherwise */ public CompletionContext getCoreContext() { if (fCollector != null) { CompletionContext context= fCollector.getContext(); if (context != null) { if (fCoreContext == null) fCoreContext= context; return context; } } if (fCoreContext == null) computeKeywordsAndContext(); // Retrieve the context ourselves return fCoreContext; }
/** * Returns the keyword proposals that are available in this context, possibly none. * <p> * <strong>Note:</strong> This method may run * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete} * on the compilation unit. * </p> * * @return the available keyword proposals */ public IJavaCompletionProposal[] getKeywordProposals() { if (fKeywordProposals == null) { if (fCollector != null && !fCollector.isIgnored(CompletionProposal.KEYWORD) && fCollector.getContext() != null) { // use the existing collector if it exists, collects keywords, and has already been invoked fKeywordProposals= fCollector.getKeywordCompletionProposals(); } else { // otherwise, retrieve keywords ourselves computeKeywordsAndContext(); } } return fKeywordProposals; }
/** * Returns the keyword proposals that are available in this context, possibly none. * <p> * <strong>Note:</strong> This method may run * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete} * on the compilation unit. * </p> * * @return the available keyword proposals */ public IJavaCompletionProposal[] getKeywordProposals() { if (fKeywordProposals == null) { if (fCollector != null && !fCollector.isIgnored(CompletionProposal.KEYWORD) && fCollector.getContext() != null) { // use the existing collector if it exists, collects keywords, and has already been invoked fKeywordProposals= fCollector.getKeywordCompletionProposals(); } else { // otherwise, retrieve keywords ourselves computeKeywordsAndContext(); } } return fKeywordProposals; }
/** * Returns the keyword proposals that are available in this context, possibly none. * <p> * <strong>Note:</strong> This method may run * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete} * on the compilation unit. * </p> * * @return the available keyword proposals */ public IJavaCompletionProposal[] getKeywordProposals() { if (fKeywordProposals == null) { if (fCollector != null && !fCollector.isIgnored(CompletionProposal.KEYWORD) && fCollector.getContext() != null) { // use the existing collector if it exists, collects keywords, and has already been invoked fKeywordProposals= fCollector.getKeywordCompletionProposals(); } else { // otherwise, retrieve keywords ourselves computeKeywordsAndContext(); } } return fKeywordProposals; }
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) { try { IJavaElement enclosingElement= null; if (getContext().isExtended()) { enclosingElement= getContext().getEnclosingElement(); } else if (fCompilationUnit != null) { // kept for backward compatibility: CU is not reconciled at this moment, information is missing (bug 70005) enclosingElement= fCompilationUnit.getElementAt(proposal.getCompletionLocation() + 1); } if (enclosingElement == null) return; IType type= (IType) enclosingElement.getAncestor(IJavaElement.TYPE); if (type != null) { String prefix= String.valueOf(proposal.getName()); int completionStart= proposal.getReplaceStart(); int completionEnd= proposal.getReplaceEnd(); int relevance= computeRelevance(proposal); GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance + 2, fSuggestedMethodNames, fJavaProposals); MethodDeclarationCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, fSuggestedMethodNames, fJavaProposals); } } catch (CoreException e) { JavaPlugin.log(e); } }
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) { try { IJavaElement enclosingElement= null; if (getContext().isExtended()) { enclosingElement= getContext().getEnclosingElement(); } else if (fCompilationUnit != null) { // kept for backward compatibility: CU is not reconciled at this moment, information is missing (bug 70005) enclosingElement= fCompilationUnit.getElementAt(proposal.getCompletionLocation() + 1); } if (enclosingElement == null) return; IType type= (IType) enclosingElement.getAncestor(IJavaElement.TYPE); if (type != null) { String prefix= String.valueOf(proposal.getName()); int completionStart= proposal.getReplaceStart(); int completionEnd= proposal.getReplaceEnd(); int relevance= computeRelevance(proposal); GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance + 2, fSuggestedMethodNames, fJavaProposals); MethodDeclarationCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, fSuggestedMethodNames, fJavaProposals); } } catch (CoreException e) { JavaPlugin.log(e); } }
private IJavaCompletionProposal createFieldProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); int start= proposal.getReplaceStart(); int length= getLength(proposal); StyledString label= fLabelProvider.createStyledLabel(proposal); Image image= getImage(fLabelProvider.createFieldImageDescriptor(proposal)); int relevance= computeRelevance(proposal); JavaCompletionProposal javaProposal= new JavaCompletionProposal(completion, start, length, image, label, relevance, getContext().isInJavadoc(), getInvocationContext()); if (fJavaProject != null) javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal)); javaProposal.setTriggerCharacters(VAR_TRIGGER); return javaProposal; }
private IJavaCompletionProposal createFieldProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); int start= proposal.getReplaceStart(); int length= getLength(proposal); String label= fLabelProvider.createLabel(proposal); Image image= getImage(fLabelProvider.createFieldImageDescriptor(proposal)); int relevance= computeRelevance(proposal); JavaCompletionProposal javaProposal= new JavaCompletionProposal(completion, start, length, image, label, relevance, getContext().isInJavadoc(), getInvocationContext()); if (fJavaProject != null) javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal)); javaProposal.setTriggerCharacters(VAR_TRIGGER); return javaProposal; }
private IJavaCompletionProposal createFieldProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); int start= proposal.getReplaceStart(); int length= getLength(proposal); StyledString label= fLabelProvider.createStyledLabel(proposal); Image image= getImage(fLabelProvider.createFieldImageDescriptor(proposal)); int relevance= computeRelevance(proposal); JavaCompletionProposal javaProposal= new JavaCompletionProposal(completion, start, length, image, label, relevance, getContext().isInJavadoc(), getInvocationContext()); if (fJavaProject != null) javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal)); javaProposal.setTriggerCharacters(VAR_TRIGGER); return javaProposal; }
/** * Creates the Java completion proposal for the JDT Core * {@link CompletionProposal#FIELD_REF_WITH_CASTED_RECEIVER} proposal. * * @param proposal the JDT Core proposal * @return the Java completion proposal * @since 3.4 */ private IJavaCompletionProposal createFieldWithCastedReceiverProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); completion= CodeFormatterUtil.format(CodeFormatter.K_EXPRESSION, completion, 0, "\n", fJavaProject); //$NON-NLS-1$ int start= proposal.getReplaceStart(); int length= getLength(proposal); StyledString label= fLabelProvider.createStyledLabel(proposal); Image image= getImage(fLabelProvider.createFieldImageDescriptor(proposal)); int relevance= computeRelevance(proposal); JavaCompletionProposal javaProposal= new JavaFieldWithCastedReceiverCompletionProposal(completion, start, length, image, label, relevance, getContext().isInJavadoc(), getInvocationContext(), proposal); if (fJavaProject != null) javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal)); javaProposal.setTriggerCharacters(VAR_TRIGGER); return javaProposal; }
/** * Creates the Java completion proposal for the JDT Core * {@link CompletionProposal#FIELD_REF_WITH_CASTED_RECEIVER} proposal. * * @param proposal the JDT Core proposal * @return the Java completion proposal * @since 3.4 */ private IJavaCompletionProposal createFieldWithCastedReceiverProposal(CompletionProposal proposal) { String completion= String.valueOf(proposal.getCompletion()); completion= CodeFormatterUtil.format(CodeFormatter.K_EXPRESSION, completion, 0, "\n", FormatterProfileManager.getProjectSettings(fJavaProject)); //$NON-NLS-1$ int start= proposal.getReplaceStart(); int length= getLength(proposal); StyledString label= fLabelProvider.createStyledLabel(proposal); Image image= getImage(fLabelProvider.createFieldImageDescriptor(proposal)); int relevance= computeRelevance(proposal); JavaCompletionProposal javaProposal= new JavaFieldWithCastedReceiverCompletionProposal(completion, start, length, image, label, relevance, getContext().isInJavadoc(), getInvocationContext(), proposal); if (fJavaProject != null) javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal)); javaProposal.setTriggerCharacters(VAR_TRIGGER); return javaProposal; }
cu.codeComplete(getInvocationOffset(), collector); if (fCoreContext == null) fCoreContext= collector.getContext(); if (fKeywordProposals == null) fKeywordProposals= collector.getKeywordCompletionProposals();
cu.codeComplete(getInvocationOffset(), collector); if (fCoreContext == null) fCoreContext= collector.getContext(); if (fKeywordProposals == null) fKeywordProposals= collector.getKeywordCompletionProposals();
cu.codeComplete(getInvocationOffset(), collector); if (fCoreContext == null) fCoreContext= collector.getContext(); if (fKeywordProposals == null) fKeywordProposals= collector.getKeywordCompletionProposals();