List of usage examples for org.eclipse.jdt.core.dom VariableDeclaration getStructuralProperty
public final Object getStructuralProperty(StructuralPropertyDescriptor property)
From source file:org.fastcode.util.SourceUtil.java
License:Open Source License
/** * @param compilationUnit/*from ww w .j ava 2 s . c o m*/ * @return * @throws Exception */ public static List<FastCodeReturn> getLocalVarFromCompUnit(final ICompilationUnit compilationUnit, final IEditorPart editorPart) throws Exception { final ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setSource(compilationUnit); parser.setResolveBindings(true); final IJavaElement currentMethod = findSelectedJavaElement(compilationUnit, editorPart); if (currentMethod == null) { return new ArrayList<FastCodeReturn>(); } final CompilationUnit parse = (CompilationUnit) parser.createAST(null); final FastCodeVisitor methodVisitor = new FastCodeVisitor(currentMethod.getElementName(), compilationUnit); parse.accept(methodVisitor); final Shell parentShell = MessageUtil.getParentShell(); final List<FastCodeReturn> variablesList = methodVisitor.getFastCodeReturns(); for (final Object obj : methodVisitor.getMethodDecln().parameters()) { final VariableDeclaration variableDeclaration = (VariableDeclaration) obj; final String type = variableDeclaration.getStructuralProperty(SingleVariableDeclaration.TYPE_PROPERTY) .toString(); final FastCodeReturn fastCodeReturn = new FastCodeReturn(variableDeclaration.getName().toString(), new FastCodeType(getFQNameFromFieldTypeName(type.toString(), compilationUnit))); variablesList.add(fastCodeReturn); } return variablesList; }