List of usage examples for org.eclipse.jdt.core IType codeComplete
void codeComplete(char[] snippet, int insertion, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic, CompletionRequestor requestor) throws JavaModelException;
From source file:com.google.gwt.eclipse.core.editors.java.contentassist.JsniCompletionProcessor.java
License:Open Source License
/** * Collects the proposals generated at the end of the specified snippet of * Java code, scoped to the specific type. *//* w w w .j ava2s. c om*/ private IJavaCompletionProposal[] codeComplete(String qualifiedTypeName, String snippet, CompletionProposalCollector requestor) throws JavaModelException { IJavaCompletionProposal[] proposals = new IJavaCompletionProposal[0]; IType type = cu.getJavaProject().findType(qualifiedTypeName); if (type != null) { // This can always be false, since the set of available completions // (static vs. instance) depends on the JSNI ref itself, not the modifiers // on the method in which it is defined. boolean isStatic = false; // Have the JDT generate completions in the context of the type, but at // an unspecified location (source offset -1), since the real position // is inside a Java comment block, which is not allowed by codeComplete. type.codeComplete(snippet.toCharArray(), -1, snippet.length(), new char[0][0], new char[0][0], new int[0], isStatic, requestor); proposals = requestor.getJavaCompletionProposals(); } return proposals; }
From source file:org.eclipse.stardust.modeling.validation.util.TypeFinder.java
License:Open Source License
private List codeComplete(IType type, final char[] snippet) { final List methods = new ArrayList(); try {/*from w w w . j a va 2 s . co m*/ type.codeComplete(snippet, -1, snippet.length, new char[0][0], new char[0][0], new int[0], false, new CompletionRequestor() { public void accept(CompletionProposal proposal) { if (proposal.getKind() == CompletionProposal.METHOD_REF) { MethodInfo info = new MethodInfo(snippet.length > 0, proposal.getName(), proposal.getSignature(), Flags.isPublic(proposal.getFlags())); if (methodFilter == null || methodFilter.accept(info)) { methods.add(info); } } } }); } catch (JavaModelException e) { log(e.getJavaModelStatus()); } return methods; }
From source file:org.hibernate.eclipse.mapper.extractor.FieldPropertyHandler.java
License:Open Source License
public ICompletionProposal[] attributeCompletionProposals(IJavaProject project, Node node, String attributeName, String start, int offset) { // TODO: should also try to find properties getXXX() if (project != null) { Node parentNode = node.getParentNode(); String typename = null;// w w w .ja va 2 s .c o m typename = this.extractor.getNearestType(project, parentNode); if (typename == null) { return new IJavaCompletionProposal[0]; // could not locate type } HibernateResultCollector rc = null; try { IType type = project.findType(typename); if (type == null) return new ICompletionProposal[0]; //nothing to look for then rc = new HibernateResultCollector(project); rc.acceptContext(new CompletionContext()); rc.setAccepts(false, false, false, false, true, false); // TODO: only handle properties ? //rc.reset(offset, javaProject, null); type.codeComplete(start.toCharArray(), -1, start.length(), new char[0][0], new char[0][0], new int[0], false, rc); } catch (JavaModelException jme) { // TODO: report } IJavaCompletionProposal[] results = rc.getJavaCompletionProposals(); CompletionHelper.transpose(start, offset, results); return results; } return new ICompletionProposal[0]; }
From source file:org.python.pydev.editor.codecompletion.revisited.javaintegration.JavaModuleInProject.java
License:Open Source License
/** * Tries to get completions for a given element. *///from w w w.j ava2s .c o m private void getCompletionsForType(String contents, String filterCompletionName, IType type, final List<Tuple<IJavaElement, CompletionProposal>> ret) throws JavaModelException { ICompilationUnit unit = type.getCompilationUnit(); if (unit == null) { return; } CompletionProposalCollector collector = createCollector(filterCompletionName, ret, unit); type.codeComplete(StringUtils.format(contents, name).toCharArray(), -1, 0, new char[0][0], new char[0][0], new int[0], false, collector); }