List of usage examples for org.eclipse.jdt.core.dom TypeDeclaration NAME_PROPERTY
ChildPropertyDescriptor NAME_PROPERTY
To view the source code for org.eclipse.jdt.core.dom TypeDeclaration NAME_PROPERTY.
Click Source Link
From source file:de.ovgu.cide.language.jdt.SimplePrintVisitor.java
License:Open Source License
public boolean visit(IASTNode node) { if (node instanceof ASTStringNode) { printToken(((ASTStringNode) node).getValue()); return false; }/*from ww w .j a va 2 s . c o m*/ if (node instanceof ASTTextNode) { printToken(((ASTTextNode) node).getValue()); return false; } if (node instanceof UnifiedASTNode) { UnifiedASTNode unode = (UnifiedASTNode) node; if (unode.getEclipseASTNodeClass().equals("AnnotationTypeDeclaration")) { accept(node, AnnotationTypeDeclaration.JAVADOC_PROPERTY.getId()); } if (unode.getEclipseASTNodeClass().equals(CompilationUnit.class.getSimpleName())) { accept(unode, CompilationUnit.PACKAGE_PROPERTY.getId()); accept(unode, CompilationUnit.IMPORTS_PROPERTY.getId()); accept(unode, CompilationUnit.TYPES_PROPERTY.getId()); } if (unode.getEclipseASTNodeClass().equals(TypeDeclaration.class.getSimpleName())) { accept(node, TypeDeclaration.JAVADOC_PROPERTY.getId()); accept(node, TypeDeclaration.MODIFIERS2_PROPERTY.getId()); accept(node, TypeDeclaration.INTERFACE_PROPERTY.getId()); accept(node, TypeDeclaration.NAME_PROPERTY.getId()); accept(node, TypeDeclaration.TYPE_PARAMETERS_PROPERTY.getId(), "<", ",", ">", true); // this.buffer.append(" ");//$NON-NLS-1$ accept(node, TypeDeclaration.SUPERCLASS_TYPE_PROPERTY.getId(), "extends", "", "", false); accept(node, TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY.getId(), "implements", ",", "", false); printToken("{"); hintNewLine(); hintIncIndent(); accept(node, TypeDeclaration.BODY_DECLARATIONS_PROPERTY.getId()); hintDecIndent(); printToken("}"); hintNewLine(); } printToken(unode.getEclipseASTNodeClass()); } return false; }
From source file:org.eclipse.wb.internal.core.utils.ast.AstNodeUtils.java
License:Open Source License
/** * @param typeName// ww w . ja va 2 s . c o m * the fully qualified type name. * * @return the {@link TypeDeclaration} with given fully qualified name, or <code>null</code> if * not found. */ public static TypeDeclaration getTypeByQualifiedName(CompilationUnit compilationUnit, final String typeName) { Assert.isNotNull(compilationUnit); Assert.isNotNull(typeName); final TypeDeclaration[] typeDeclaration = new TypeDeclaration[1]; compilationUnit.accept(new ASTVisitor() { @Override public void postVisit(ASTNode node) { if (typeDeclaration[0] == null) { if (node.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY && ((ClassInstanceCreation) node.getParent()).getAnonymousClassDeclaration() != null) { ClassInstanceCreation creation = (ClassInstanceCreation) node.getParent(); String _typeName = getFullyQualifiedName(creation, true); if (_typeName.equals(typeName)) { AnonymousClassDeclaration anonymousClassDeclaration = creation .getAnonymousClassDeclaration(); typeDeclaration[0] = AnonymousTypeDeclaration.create(anonymousClassDeclaration); } } } } @Override public boolean visit(SimpleName node) { if (typeDeclaration[0] == null) { if (node.getLocationInParent() == TypeDeclaration.NAME_PROPERTY) { String _typeName = getFullyQualifiedName(node, true); if (_typeName.equals(typeName)) { typeDeclaration[0] = (TypeDeclaration) node.getParent(); } } } return typeDeclaration[0] == null; } }); // OK, return found TypeDeclaration return typeDeclaration[0]; }
From source file:org.eclipse.wb.internal.core.utils.ast.AstNodeUtils.java
License:Open Source License
/** * @return <code>true</code> if given {@link ASTNode} is single variable {@link SimpleName} or * {@link FieldAccess} like "this.fieldName". *//*from w ww. ja v a 2 s . c o m*/ public static boolean isVariable(ASTNode variable) { // FieldAccess if (variable instanceof FieldAccess) { FieldAccess fieldAccess = (FieldAccess) variable; return fieldAccess.getExpression() instanceof ThisExpression; } // SimpleName if (variable instanceof SimpleName) { StructuralPropertyDescriptor locationInParent = variable.getLocationInParent(); if (locationInParent == MethodInvocation.NAME_PROPERTY || locationInParent == SimpleType.NAME_PROPERTY || locationInParent == FieldAccess.NAME_PROPERTY || locationInParent == QualifiedName.NAME_PROPERTY || locationInParent == MethodDeclaration.NAME_PROPERTY || locationInParent == TypeDeclaration.NAME_PROPERTY) { return false; } // variable has binding return getVariableBinding(variable) != null; } // unknown ASTNode return false; }
From source file:org.moe.natjgen.ClassEditor.java
License:Apache License
public String getClassName() { SimpleName property = (SimpleName) getRewrite().get(classDecl, TypeDeclaration.NAME_PROPERTY); if (property == null) { return null; }/*from w ww .ja va 2s . c o m*/ return property.getIdentifier(); }
From source file:org.moe.natjgen.ClassEditor.java
License:Apache License
public void setClassName(String className) throws GeneratorException { editLock();//from w w w. jav a 2 s.c o m SimpleName property = (SimpleName) getRewrite().get(classDecl, TypeDeclaration.NAME_PROPERTY); if (property == null || !property.getFullyQualifiedName().equals(className)) { getRewrite().set(classDecl, TypeDeclaration.NAME_PROPERTY, getAST().newName(className), getEditGroup()); } }