本文整理汇总了Java中org.eclipse.jdt.core.ITypeRoot.codeComplete方法的典型用法代码示例。如果您正苦于以下问题:Java ITypeRoot.codeComplete方法的具体用法?Java ITypeRoot.codeComplete怎么用?Java ITypeRoot.codeComplete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.ITypeRoot
的用法示例。
在下文中一共展示了ITypeRoot.codeComplete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Autocomplete
import org.eclipse.jdt.core.ITypeRoot; //导入方法依赖的package包/类
private List<AutocompleteResponse.Completion> Autocomplete(ITypeRoot cu, int cursorPosition) throws JavaModelException
{
final List<AutocompleteResponse.Completion> proposals = new ArrayList<AutocompleteResponse.Completion>();
cu.codeComplete(cursorPosition, new CompletionRequestor()
{
@Override
public void accept(CompletionProposal proposal) {
try
{
System.out.println(proposal.toString());
proposals.add(translateToCompletion(proposal));
}
catch(Exception e)
{
e.printStackTrace();
}
}
});
return proposals;
}
示例2: ParamHelp
import org.eclipse.jdt.core.ITypeRoot; //导入方法依赖的package包/类
private List<ParamHelpResponse.Signature> ParamHelp(ITypeRoot cu, int cursorPosition) throws JavaModelException
{
final List<ParamHelpResponse.Signature> proposals = new ArrayList<ParamHelpResponse.Signature>();
cu.codeComplete(cursorPosition, new CompletionRequestor()
{
@Override
public void accept(CompletionProposal proposal)
{
try
{
System.out.println(proposal.toString());
if (proposal.getKind() == CompletionProposal.METHOD_REF)
{
char[] javaSig = proposal.getSignature();
ParamHelpResponse.Signature.Builder sig = ParamHelpResponse.Signature.newBuilder()
.setName(new String(proposal.getName()))
.setReturnValue(new String(Signature.toCharArray(Signature.getReturnType(javaSig))));
char[][] javaParamTypes = Signature.getParameterTypes(javaSig);
for(char[] javaParamType: javaParamTypes)
{
sig.addParameters(ParamHelpResponse.Parameter.newBuilder()
.setName(new String(Signature.toCharArray(javaParamType)))
.build());
}
proposals.add(sig.build());
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
});
return proposals;
}