/** * Returns the replacement length of a given completion proposal. The * replacement length is usually the difference between the return values of * <code>proposal.getReplaceEnd</code> and * <code>proposal.getReplaceStart</code>, but this behavior may be * overridden by calling {@link #setReplacementLength(int)}. * * @param proposal the completion proposal to get the replacement length for * @return the replacement length for <code>proposal</code> */ protected final int getLength(CompletionProposal proposal) { int start= proposal.getReplaceStart(); int end= proposal.getReplaceEnd(); int length; if (fUserReplacementLength == -1) { length= end - start; } else { length= fUserReplacementLength; // extend length to begin at start int behindCompletion= proposal.getCompletionLocation() + 1; if (start < behindCompletion) { length+= behindCompletion - start; } } return length; }
/** * Returns the replacement length of a given completion proposal. The * replacement length is usually the difference between the return values of * <code>proposal.getReplaceEnd</code> and * <code>proposal.getReplaceStart</code>, but this behavior may be * overridden by calling {@link #setReplacementLength(int)}. * * @param proposal the completion proposal to get the replacement length for * @return the replacement length for <code>proposal</code> */ protected final int getLength(CompletionProposal proposal) { int start= proposal.getReplaceStart(); int end= proposal.getReplaceEnd(); int length; if (fUserReplacementLength == -1) { length= end - start; } else { length= fUserReplacementLength; // extend length to begin at start int behindCompletion= proposal.getCompletionLocation() + 1; if (start < behindCompletion) { length+= behindCompletion - start; } } return length; }
/** * Returns the replacement length of a given completion proposal. The * replacement length is usually the difference between the return values of * <code>proposal.getReplaceEnd</code> and * <code>proposal.getReplaceStart</code>, but this behavior may be * overridden by calling {@link #setReplacementLength(int)}. * * @param proposal the completion proposal to get the replacement length for * @return the replacement length for <code>proposal</code> */ protected final int getLength(CompletionProposal proposal) { int start= proposal.getReplaceStart(); int end= proposal.getReplaceEnd(); int length; if (fUserReplacementLength == -1) { length= end - start; } else { length= fUserReplacementLength; // extend length to begin at start int behindCompletion= proposal.getCompletionLocation() + 1; if (start < behindCompletion) { length+= behindCompletion - start; } } return length; }
buffer.append("\tCompletionLocation[").append(proposal.getCompletionLocation()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$ int start = proposal.getReplaceStart(); int end = proposal.getReplaceEnd();
buffer.append("\tCompletionLocation[").append(proposal.getCompletionLocation()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$ int start = proposal.getReplaceStart(); int end = proposal.getReplaceEnd();
buffer.append("\tCompletionLocation[").append(proposal.getCompletionLocation()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$ int start = proposal.getReplaceStart(); int end = proposal.getReplaceEnd();
buffer.append("\tCompletionLocation[").append(proposal.getCompletionLocation()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$ int start = proposal.getReplaceStart(); int end = proposal.getReplaceEnd();
buffer.append("\tCompletionLocation[").append(proposal.getCompletionLocation()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$ int start = proposal.getReplaceStart(); int end = proposal.getReplaceEnd();
buffer.append("\tCompletionLocation[").append(proposal.getCompletionLocation()).append("]\n"); //$NON-NLS-1$ //$NON-NLS-2$ int start = proposal.getReplaceStart(); int end = proposal.getReplaceEnd();
JavaModelUtil.reconcile(cu); String[][] parameterTypes= getParameterSignatures(); ParameterGuesser guesser= new ParameterGuesser(fProposal.getCompletionLocation() + 1, cu);
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) { if (fCompilationUnit == null) return; String prefix= String.valueOf(proposal.getName()); int completionStart= proposal.getReplaceStart(); int completionEnd= proposal.getReplaceEnd(); int relevance= computeRelevance(proposal); try { IJavaElement element= fCompilationUnit.getElementAt(proposal.getCompletionLocation() + 1); if (element != null) { IType type= (IType) element.getAncestor(IJavaElement.TYPE); if (type != null) { GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance + 1, fSuggestedMethodNames, fJavaProposals); MethodDeclarationCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, fSuggestedMethodNames, fJavaProposals); } } } catch (CoreException e) { JavaPlugin.log(e); } }
/** * Creates a new context information. * * @param proposal the JDT Core completion proposal */ public ProposalContextInformation(CompletionProposal proposal) { // don't cache the core proposal because the ContentAssistant might // hang on to the context info. CompletionProposalLabelProvider labelProvider= new CompletionProposalLabelProvider(); fInformationDisplayString= labelProvider.createParameterList(proposal); ImageDescriptor descriptor= labelProvider.createImageDescriptor(proposal); if (descriptor != null) fImage= JavaPlugin.getImageDescriptorRegistry().get(descriptor); else fImage= null; if (proposal.getCompletion().length == 0) fPosition= proposal.getCompletionLocation() + 1; else fPosition= -1; fContextDisplayString= labelProvider.createLabel(proposal); }
/** * Creates a new context information. */ public ProposalContextInformation(CompletionProposal proposal) { // don't cache the core proposal because the ContentAssistant might // hang on to the context info. CompletionProposalLabelProvider labelProvider= new CompletionProposalLabelProvider(); fInformationDisplayString= labelProvider.createParameterList(proposal); ImageDescriptor descriptor= labelProvider.createImageDescriptor(proposal); if (descriptor != null) fImage= JavaPlugin.getImageDescriptorRegistry().get(descriptor); else fImage= null; if (proposal.getCompletion().length == 0) fPosition= proposal.getCompletionLocation() + 1; else fPosition= -1; fContextDisplayString= labelProvider.createLabel(proposal); }
/** * Creates a new context information. * * @param proposal the JDT Core completion proposal */ public ProposalContextInformation(CompletionProposal proposal) { // don't cache the core proposal because the ContentAssistant might // hang on to the context info. CompletionProposalLabelProvider labelProvider= new CompletionProposalLabelProvider(); fInformationDisplayString= labelProvider.createParameterList(proposal); ImageDescriptor descriptor= labelProvider.createImageDescriptor(proposal); if (descriptor != null) fImage= JavaPlugin.getImageDescriptorRegistry().get(descriptor); else fImage= null; if (proposal.getCompletion().length == 0) fPosition= proposal.getCompletionLocation() + 1; else fPosition= -1; fContextDisplayString= labelProvider.createLabel(proposal); }
private void acceptPotentialMethodDeclaration(CompletionProposal proposal) { try { IJavaElement enclosingElement = null; if (response.getContext().isExtended()) { enclosingElement = response.getContext().getEnclosingElement(); } else if (unit != null) { // kept for backward compatibility: CU is not reconciled at this moment, information is missing (bug 70005) enclosingElement = unit.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 = proposal.getRelevance() + 6; GetterSetterCompletionProposal.evaluateProposals(type, prefix, completionStart, completionEnd - completionStart, relevance, proposals); } } catch (CoreException e) { JavaLanguageServerPlugin.logException("Accept potential method declaration failed for completion ", 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 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); } }