public static void evaluateProposals(IType type, String prefix, int offset, int length, int relevance, Set<String> suggestedMethods, Collection<IJavaCompletionProposal> result) throws CoreException { IMethod[] methods= type.getMethods(); if (!type.isInterface()) { String constructorName= type.getElementName(); if (constructorName.length() > 0 && constructorName.startsWith(prefix) && !hasMethod(methods, constructorName) && suggestedMethods.add(constructorName)) { result.add(new MethodDeclarationCompletionProposal(type, constructorName, null, offset, length, relevance + 500)); } } if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix) && suggestedMethods.add(prefix)) { //$NON-NLS-1$ if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR)) result.add(new MethodDeclarationCompletionProposal(type, prefix, Signature.SIG_VOID, offset, length, relevance)); } }
public MethodDeclarationCompletionProposal(IType type, String methodName, String returnTypeSig, int start, int length, int relevance) { super("", type.getCompilationUnit(), start, length, null, getDisplayName(methodName, returnTypeSig), relevance); //$NON-NLS-1$ Assert.isNotNull(type); Assert.isNotNull(methodName); fType= type; fMethodName= methodName; fReturnTypeSig= returnTypeSig; if (returnTypeSig == null) { setProposalInfo(new ProposalInfo(type)); ImageDescriptor desc= new JavaElementImageDescriptor(JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE); setImage(JavaPlugin.getImageDescriptorRegistry().get(desc)); } else { setImage(JavaPluginImages.get(JavaPluginImages.IMG_MISC_PRIVATE)); } }
IRegion region= document.getLineInformationOfOffset(getReplacementOffset()); int lineStart= region.getOffset(); int indent= Strings.computeIndentUnits(document.get(lineStart, getReplacementOffset() - lineStart), settings.tabWidth, settings.indentWidth); setReplacementString(Strings.trimLeadingTabsAndSpaces(replacement)); return true;
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); } }
@Override public IProcessableProposal newMethodDeclarationCompletionProposal(CompletionProposal coreProposal, MethodDeclarationCompletionProposal uiProposal, JavaContentAssistInvocationContext context) { try { IType type = (IType) context.getCoreContext().getEnclosingElement(); if (type != null) return postConstruct(ProcessableMethodDeclarationCompletionProposal.newProposal(coreProposal, type, uiProposal.getRelevance())); } catch (CoreException e) { throw Throwables.propagate(e); } throw Throws.throwIllegalArgumentException("no type found"); }
IRegion region= document.getLineInformationOfOffset(getReplacementOffset()); int lineStart= region.getOffset(); int indent= Strings.computeIndentUnits(document.get(lineStart, getReplacementOffset() - lineStart), settings.tabWidth, settings.indentWidth); setReplacementString(Strings.trimLeadingTabsAndSpaces(replacement)); return true;
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); } }
public MethodDeclarationCompletionProposal(IType type, String methodName, String returnTypeSig, int start, int length, int relevance) { super("", type.getCompilationUnit(), start, length, null, getDisplayName(methodName, returnTypeSig), relevance); //$NON-NLS-1$ Assert.isNotNull(type); Assert.isNotNull(methodName); fType= type; fMethodName= methodName; fReturnTypeSig= returnTypeSig; if (returnTypeSig == null) { setProposalInfo(new ProposalInfo(type)); ImageDescriptor desc= new JavaElementImageDescriptor(JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE); setImage(JavaPlugin.getImageDescriptorRegistry().get(desc)); } else { setImage(JavaPluginImages.get(JavaPluginImages.IMG_MISC_PRIVATE)); } }
public static void evaluateProposals(IType type, String prefix, int offset, int length, int relevance, Set<String> suggestedMethods, Collection<IJavaCompletionProposal> result) throws CoreException { IMethod[] methods= type.getMethods(); if (!type.isInterface()) { String constructorName= type.getElementName(); if (constructorName.length() > 0 && constructorName.startsWith(prefix) && !hasMethod(methods, constructorName) && suggestedMethods.add(constructorName)) { result.add(new MethodDeclarationCompletionProposal(type, constructorName, null, offset, length, relevance + 500)); } } if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix) && suggestedMethods.add(prefix)) { //$NON-NLS-1$ if (!JavaConventionsUtil.validateMethodName(prefix, type).matches(IStatus.ERROR)) result.add(new MethodDeclarationCompletionProposal(type, prefix, Signature.SIG_VOID, offset, length, relevance)); } }
IRegion region= document.getLineInformationOfOffset(getReplacementOffset()); int lineStart= region.getOffset(); int indent= Strings.computeIndentUnits(document.get(lineStart, getReplacementOffset() - lineStart), settings.tabWidth, settings.indentWidth); setReplacementString(Strings.trimLeadingTabsAndSpaces(replacement)); return true;
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); } }
public MethodDeclarationCompletionProposal(IType type, String methodName, String returnTypeSig, int start, int length, int relevance) { super("", type.getCompilationUnit(), start, length, null, getDisplayName(methodName, returnTypeSig), relevance); //$NON-NLS-1$ Assert.isNotNull(type); Assert.isNotNull(methodName); fType= type; fMethodName= methodName; fReturnTypeSig= returnTypeSig; if (returnTypeSig == null) { setProposalInfo(new ProposalInfo(type)); ImageDescriptor desc= new JavaElementImageDescriptor(JavaPluginImages.DESC_MISC_PUBLIC, JavaElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE); setImage(JavaPlugin.getImageDescriptorRegistry().get(desc)); } else { setImage(JavaPluginImages.get(JavaPluginImages.IMG_MISC_PRIVATE)); } }
public static void evaluateProposals(IType type, String prefix, int offset, int length, int relevance, Set suggestedMethods, Collection result) throws CoreException { IMethod[] methods= type.getMethods(); if (!type.isInterface()) { String constructorName= type.getElementName(); if (constructorName.length() > 0 && constructorName.startsWith(prefix) && !hasMethod(methods, constructorName) && suggestedMethods.add(constructorName)) { result.add(new MethodDeclarationCompletionProposal(type, constructorName, null, offset, length, relevance + 500)); } } if (prefix.length() > 0 && !"main".equals(prefix) && !hasMethod(methods, prefix) && suggestedMethods.add(prefix)) { //$NON-NLS-1$ if (!JavaConventions.validateMethodName(prefix).matches(IStatus.ERROR)) { result.add(new MethodDeclarationCompletionProposal(type, prefix, Signature.SIG_VOID, offset, length, relevance)); } } }