/** * Returns the type binding of the node's type context or null if the node is inside * an annotation, type parameter, super type declaration, or Javadoc of a top level type. * The result of this method is equal to the result of {@link #getBindingOfParentType(ASTNode)} for nodes in the type's body. * * @param node an AST node * @return the type binding of the node's parent type context, or <code>null</code> */ public static ITypeBinding getBindingOfParentTypeContext(ASTNode node) { StructuralPropertyDescriptor lastLocation= null; while (node != null) { if (node instanceof AbstractTypeDeclaration) { AbstractTypeDeclaration decl= (AbstractTypeDeclaration) node; if (lastLocation == decl.getBodyDeclarationsProperty() || lastLocation == decl.getJavadocProperty()) { return decl.resolveBinding(); } else if (decl instanceof EnumDeclaration && lastLocation == EnumDeclaration.ENUM_CONSTANTS_PROPERTY) { return decl.resolveBinding(); } } else if (node instanceof AnonymousClassDeclaration) { return ((AnonymousClassDeclaration) node).resolveBinding(); } lastLocation= node.getLocationInParent(); node= node.getParent(); } return null; }
@Override public String getAdditionalInfo() { if (fTypeNode instanceof EnumDeclaration) { return CorrectionMessages.UnimplementedMethodsCorrectionProposal_enum_info; } IMethodBinding[] methodsToOverride = getMethodsToImplement(); StringBuffer buf = new StringBuffer(); buf.append("<b>"); //$NON-NLS-1$ if (methodsToOverride.length == 1) { buf.append(CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_singular); } else { buf.append(Messages.format(CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_plural, String.valueOf(methodsToOverride.length))); } buf.append("</b><ul>"); //$NON-NLS-1$ for (int i = 0; i < methodsToOverride.length; i++) { buf.append("<li>"); //$NON-NLS-1$ buf.append(BindingLabelProvider.getBindingLabel(methodsToOverride[i], JavaElementLabels.ALL_FULLY_QUALIFIED)); buf.append("</li>"); //$NON-NLS-1$s } buf.append("</ul>"); //$NON-NLS-1$ return buf.toString(); }
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) { SimpleName node= fOriginalNode; ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding); if (newTypeDecl == null) { astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } if (newTypeDecl != null) { AST ast= newTypeDecl.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration(); constDecl.setName(ast.newSimpleName(node.getIdentifier())); ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY); listRewriter.insertLast(constDecl, null); return rewrite; } return null; }
/** * Returns the type binding of the node's type context or null if the node is inside an * annotation, type parameter, super type declaration, or Javadoc of a top level type. The result * of this method is equal to the result of {@link #getBindingOfParentType(ASTNode)} for nodes in * the type's body. * * @param node an AST node * @return the type binding of the node's parent type context, or <code>null</code> */ public static ITypeBinding getBindingOfParentTypeContext(ASTNode node) { StructuralPropertyDescriptor lastLocation = null; while (node != null) { if (node instanceof AbstractTypeDeclaration) { AbstractTypeDeclaration decl = (AbstractTypeDeclaration) node; if (lastLocation == decl.getBodyDeclarationsProperty() || lastLocation == decl.getJavadocProperty()) { return decl.resolveBinding(); } else if (decl instanceof EnumDeclaration && lastLocation == EnumDeclaration.ENUM_CONSTANTS_PROPERTY) { return decl.resolveBinding(); } } else if (node instanceof AnonymousClassDeclaration) { return ((AnonymousClassDeclaration) node).resolveBinding(); } lastLocation = node.getLocationInParent(); node = node.getParent(); } return null; }
protected String getFullTypeName() { ASTNode node = getNode(); while (true) { node = node.getParent(); if (node instanceof AbstractTypeDeclaration) { String typeName = ((AbstractTypeDeclaration) node).getName().getIdentifier(); if (getNode() instanceof LambdaExpression) { return Messages.format( RefactoringCoreMessages.ChangeSignatureRefactoring_lambda_expression, typeName); } return typeName; } else if (node instanceof ClassInstanceCreation) { ClassInstanceCreation cic = (ClassInstanceCreation) node; return Messages.format( RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass, BasicElementLabels.getJavaElementName(ASTNodes.asString(cic.getType()))); } else if (node instanceof EnumConstantDeclaration) { EnumDeclaration ed = (EnumDeclaration) node.getParent(); return Messages.format( RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass, BasicElementLabels.getJavaElementName(ASTNodes.asString(ed.getName()))); } } }
private void addInheritedTypeQualifications(final AbstractTypeDeclaration declaration, final CompilationUnitRewrite targetRewrite, final TextEditGroup group) { Assert.isNotNull(declaration); Assert.isNotNull(targetRewrite); final CompilationUnit unit= (CompilationUnit) declaration.getRoot(); final ITypeBinding binding= declaration.resolveBinding(); if (binding != null) { Type type= null; if (declaration instanceof TypeDeclaration) { type= ((TypeDeclaration) declaration).getSuperclassType(); if (type != null && unit.findDeclaringNode(binding) != null) addTypeQualification(type, targetRewrite, group); } List<Type> types= null; if (declaration instanceof TypeDeclaration) types= ((TypeDeclaration) declaration).superInterfaceTypes(); else if (declaration instanceof EnumDeclaration) types= ((EnumDeclaration) declaration).superInterfaceTypes(); if (types != null) { for (final Iterator<Type> iterator= types.iterator(); iterator.hasNext();) { type= iterator.next(); if (unit.findDeclaringNode(type.resolveBinding()) != null) addTypeQualification(type, targetRewrite, group); } } } }
protected String getFullTypeName() { ASTNode node= getNode(); while (true) { node= node.getParent(); if (node instanceof AbstractTypeDeclaration) { String typeName= ((AbstractTypeDeclaration) node).getName().getIdentifier(); if (getNode() instanceof LambdaExpression) { return Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_lambda_expression, typeName); } return typeName; } else if (node instanceof ClassInstanceCreation) { ClassInstanceCreation cic= (ClassInstanceCreation) node; return Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass, BasicElementLabels.getJavaElementName(ASTNodes.asString(cic.getType()))); } else if (node instanceof EnumConstantDeclaration) { EnumDeclaration ed= (EnumDeclaration) node.getParent(); return Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass, BasicElementLabels.getJavaElementName(ASTNodes.asString(ed.getName()))); } } }
private ListRewrite evaluateListRewrite(ASTRewrite rewrite, ASTNode declNode) { switch (declNode.getNodeType()) { case ASTNode.METHOD_DECLARATION: return rewrite.getListRewrite(declNode, MethodDeclaration.MODIFIERS2_PROPERTY); case ASTNode.FIELD_DECLARATION: return rewrite.getListRewrite(declNode, FieldDeclaration.MODIFIERS2_PROPERTY); case ASTNode.VARIABLE_DECLARATION_EXPRESSION: return rewrite.getListRewrite(declNode, VariableDeclarationExpression.MODIFIERS2_PROPERTY); case ASTNode.VARIABLE_DECLARATION_STATEMENT: return rewrite.getListRewrite(declNode, VariableDeclarationStatement.MODIFIERS2_PROPERTY); case ASTNode.SINGLE_VARIABLE_DECLARATION: return rewrite.getListRewrite(declNode, SingleVariableDeclaration.MODIFIERS2_PROPERTY); case ASTNode.TYPE_DECLARATION: return rewrite.getListRewrite(declNode, TypeDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ENUM_DECLARATION: return rewrite.getListRewrite(declNode, EnumDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ANNOTATION_TYPE_DECLARATION: return rewrite.getListRewrite(declNode, AnnotationTypeDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ENUM_CONSTANT_DECLARATION: return rewrite.getListRewrite(declNode, EnumConstantDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: return rewrite.getListRewrite(declNode, AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY); default: throw new IllegalArgumentException("node has no modifiers: " + declNode.getClass().getName()); //$NON-NLS-1$ } }
/** * {@inheritDoc} */ @Override public String getAdditionalInfo() { if (fTypeNode instanceof EnumDeclaration) return CorrectionMessages.UnimplementedMethodsCorrectionProposal_enum_info; IMethodBinding[] methodsToOverride= getMethodsToImplement(); StringBuffer buf= new StringBuffer(); buf.append("<b>"); //$NON-NLS-1$ if (methodsToOverride.length == 1) { buf.append(CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_singular); } else { buf.append(Messages.format(CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_plural, String.valueOf(methodsToOverride.length))); } buf.append("</b><ul>"); //$NON-NLS-1$ for (int i= 0; i < methodsToOverride.length; i++) { buf.append("<li>"); //$NON-NLS-1$ buf.append(BindingLabelProvider.getBindingLabel(methodsToOverride[i], JavaElementLabels.ALL_FULLY_QUALIFIED)); buf.append("</li>"); //$NON-NLS-1$ } buf.append("</ul>"); //$NON-NLS-1$ return buf.toString(); }
public String initialize(CompilationUnit root, ASTNode node) { if (!(node instanceof Name)) return SearchMessages.ImplementOccurrencesFinder_invalidTarget; fSelectedNode= ASTNodes.getNormalizedNode(node); if (!(fSelectedNode instanceof Type)) return SearchMessages.ImplementOccurrencesFinder_invalidTarget; StructuralPropertyDescriptor location= fSelectedNode.getLocationInParent(); if (location != TypeDeclaration.SUPERCLASS_TYPE_PROPERTY && location != TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY && location != EnumDeclaration.SUPER_INTERFACE_TYPES_PROPERTY) return SearchMessages.ImplementOccurrencesFinder_invalidTarget; fSelectedType= ((Type)fSelectedNode).resolveBinding(); if (fSelectedType == null) return SearchMessages.ImplementOccurrencesFinder_invalidTarget; fStart= fSelectedNode.getParent(); // type declaration fASTRoot= root; fDescription= Messages.format(SearchMessages.ImplementOccurrencesFinder_occurrence_description, BasicElementLabels.getJavaElementName(fSelectedType.getName())); return null; }
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) { SimpleName node= fOriginalNode; ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding); if (newTypeDecl == null) { astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } if (newTypeDecl != null) { AST ast= newTypeDecl.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration(); constDecl.setName(ast.newSimpleName(node.getIdentifier())); ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY); listRewriter.insertLast(constDecl, null); addLinkedPosition(rewrite.track(constDecl.getName()), false, KEY_NAME); return rewrite; } return null; }
@Override public boolean visit(EnumDeclaration node) { AbstractEnum absEnum = new AbstractEnum(); if (packageName != null) { absEnum.setName(packageName+'.'+node.getName().getFullyQualifiedName()); } else { absEnum.setName(node.getName().getFullyQualifiedName()); } TypeVisitor visitor = new TypeVisitor(); node.accept(visitor); absEnum.setMethods(visitor.getMethods()); absEnum.setFields(visitor.getFields()); absEnum.setStartPosition(node.getStartPosition()); absEnum.setEndPosition(node.getStartPosition() + node.getLength() - 1); absEnum.setConstants(visitor.getEnumConstants()); types.add(absEnum); return true; }
@SuppressWarnings("unchecked") public void writeLabels(Collection<String> labels) { if (labels.isEmpty()) return; EnumDeclaration enumType = getAST().newEnumDeclaration(); enumType.setName(getAST().newSimpleName("TAG")); enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD)); // elements int num = 0; for (String label : labels) { EnumConstantDeclaration constantDeclaration = getAST().newEnumConstantDeclaration(); constantDeclaration.setName(getAST().newSimpleName(normalizeEnumName(label))); enumType.enumConstants().add(num, constantDeclaration); num++; } getTarget().bodyDeclarations().add(enumType); }
@SuppressWarnings("unchecked") public void writeMessages(Collection<String> messages) { EnumDeclaration enumType = getAST().newEnumDeclaration(); enumType.setName(getAST().newSimpleName("QCPFMSG")); enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD)); // elements int num = 0; for (String message : messages) { if (message.equalsIgnoreCase("CPF0000")) continue; EnumConstantDeclaration constantDeclaration = getAST().newEnumConstantDeclaration(); constantDeclaration.setName(getAST().newSimpleName(normalizeEnumName(message))); enumType.enumConstants().add(num, constantDeclaration); num++; } getTarget().bodyDeclarations().add(enumType); }
@Override public boolean visit(EnumConstantDeclaration node) { //System.out.println("Found: " + node.getClass()); print("public static "); ((EnumDeclaration)node.getParent()).getName().accept(this); print(" "); node.getName().accept(this); print(" = new "); ((EnumDeclaration)node.getParent()).getName().accept(this); print("("); int printed = 0; for (Object o : node.arguments()) { if (printed > 0) { print(", "); } ((Expression)o).accept(this); printed++; } println(");"); return false; }
@Override public boolean visit(EnumDeclaration enumDeclaration) { if (enumDeclaration.isPackageMemberTypeDeclaration()) { if (currentPackage != null) { String identifier = enumDeclaration.getName().getIdentifier(); if (currentPackage.getPackagedElement(identifier) == null) { Enumeration enumeration = currentPackage.createOwnedEnumeration(identifier); currentClassifier = enumeration; @SuppressWarnings("rawtypes") List enumConstants = enumDeclaration.enumConstants(); for (Object object : enumConstants) { if (object instanceof EnumConstantDeclaration) { EnumConstantDeclaration enumConstantDeclaration = (EnumConstantDeclaration)object; enumeration.createOwnedLiteral(enumConstantDeclaration.getName().getIdentifier()); } } } } } return super.visit(enumDeclaration); }
/** * Return a BodyDeclaration instance according to the wanted BodyDeclaration * type. * * @param atd * An AbstractTypeDeclaration object * @param bd * A "same Body Declaration" used to find in {@code atd} * @return A BodyDeclaration instance according to the wanted * BodyDeclaration type. */ @SuppressWarnings("unchecked") public static BodyDeclaration getBodyDeclaration(AbstractTypeDeclaration atd, BodyDeclaration bd) { String bdName = JavaCodeHelper.getName(bd); Class<? extends BodyDeclaration> bdc = bd.getClass(); if (FieldDeclaration.class.isAssignableFrom(bdc)) { return getField(atd, bdName); } else if (MethodDeclaration.class.isAssignableFrom(bdc)) { return getMethod(atd, bdName, ((MethodDeclaration) bd).parameters()); } else if (AbstractTypeDeclaration.class.isAssignableFrom(bdc)) { return getInnerType(atd, bdName); } else if (EnumConstantDeclaration.class.isAssignableFrom(bdc)) { return getEnumConstant((EnumDeclaration) atd, bdName); } return null; }
/** * Return a list of {@code typeWanted} typed elements as children of {@code * atd} AbstractTypeDeclaration. * * @param atd * The parent instance * @param typeWanted * Type of children wanted * @return a list of {@code typeWanted} typed elements as children of * {@code atd} AbstractTypeDeclaration */ @SuppressWarnings("unchecked") public static <T extends BodyDeclaration> List<T> getTypedChildren(AbstractTypeDeclaration atd, Class<T> typeWanted) { if (atd == null) { return null; } List<T> result = new ArrayList<T>(5); if (typeWanted.equals(EnumConstantDeclaration.class)) { result = ((EnumDeclaration) atd).enumConstants(); } else { for (BodyDeclaration bd : (List<BodyDeclaration>) atd.bodyDeclarations()) { if (typeWanted.isAssignableFrom(bd.getClass())) { result.add((T) bd); } } } return result; }
@Override public boolean visit(EnumDeclaration node) { if (++fTypes > 1) { return false; } return super.visit(node); }
@Override public void endVisit(EnumDeclaration node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.superInterfaceTypes()); process(info, node.enumConstants()); process(info, node.bodyDeclarations()); info.setNoReturn(); }
@Override public boolean visit(EnumDeclaration node) { // Don't dive into a local type. if (node.isLocalTypeDeclaration()) { return false; } return true; }
private static EnumDeclaration createNewEnumDeclaration(AST ast, SimpleName name, Collection enumConstantDeclarationCollection, Object[] enumTypeModifierCollection) { final EnumDeclaration enumDecl = ast.newEnumDeclaration(); enumDecl.setName(name); for (int i = 0; i < enumTypeModifierCollection.length; i++) enumDecl.modifiers().add(enumTypeModifierCollection[i]); enumDecl.enumConstants().addAll(enumConstantDeclarationCollection); return enumDecl; }
private ListRewrite evaluateListRewrite(ASTRewrite rewrite, ASTNode declNode) { switch (declNode.getNodeType()) { case ASTNode.METHOD_DECLARATION: return rewrite.getListRewrite(declNode, MethodDeclaration.MODIFIERS2_PROPERTY); case ASTNode.FIELD_DECLARATION: return rewrite.getListRewrite(declNode, FieldDeclaration.MODIFIERS2_PROPERTY); case ASTNode.VARIABLE_DECLARATION_EXPRESSION: return rewrite.getListRewrite(declNode, VariableDeclarationExpression.MODIFIERS2_PROPERTY); case ASTNode.VARIABLE_DECLARATION_STATEMENT: return rewrite.getListRewrite(declNode, VariableDeclarationStatement.MODIFIERS2_PROPERTY); case ASTNode.SINGLE_VARIABLE_DECLARATION: return rewrite.getListRewrite(declNode, SingleVariableDeclaration.MODIFIERS2_PROPERTY); case ASTNode.TYPE_DECLARATION: return rewrite.getListRewrite(declNode, TypeDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ENUM_DECLARATION: return rewrite.getListRewrite(declNode, EnumDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ANNOTATION_TYPE_DECLARATION: return rewrite.getListRewrite(declNode, AnnotationTypeDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ENUM_CONSTANT_DECLARATION: return rewrite.getListRewrite(declNode, EnumConstantDeclaration.MODIFIERS2_PROPERTY); case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: return rewrite.getListRewrite( declNode, AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY); default: throw new IllegalArgumentException( "node has no modifiers: " + declNode.getClass().getName()); // $NON-NLS-1$ } }
public static boolean isStatic(BodyDeclaration bodyDeclaration) { if (isNestedInterfaceOrAnnotation(bodyDeclaration)) return true; int nodeType = bodyDeclaration.getNodeType(); if (!(nodeType == ASTNode.METHOD_DECLARATION || nodeType == ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION) && isInterfaceOrAnnotationMember(bodyDeclaration)) return true; if (bodyDeclaration instanceof EnumConstantDeclaration) return true; if (bodyDeclaration instanceof EnumDeclaration && bodyDeclaration.getParent() instanceof AbstractTypeDeclaration) return true; return Modifier.isStatic(bodyDeclaration.getModifiers()); }
/** {@inheritDoc} */ @Override public String getAdditionalInfo() { if (fTypeNode instanceof EnumDeclaration) return CorrectionMessages.UnimplementedMethodsCorrectionProposal_enum_info; IMethodBinding[] methodsToOverride = getMethodsToImplement(); StringBuffer buf = new StringBuffer(); buf.append("<b>"); // $NON-NLS-1$ if (methodsToOverride.length == 1) { buf.append(CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_singular); } else { buf.append( Messages.format( CorrectionMessages.UnimplementedMethodsCorrectionProposal_info_plural, String.valueOf(methodsToOverride.length))); } buf.append("</b><ul>"); // $NON-NLS-1$ for (int i = 0; i < methodsToOverride.length; i++) { buf.append("<li>"); // $NON-NLS-1$ buf.append( BindingLabelProvider.getBindingLabel( methodsToOverride[i], JavaElementLabels.ALL_FULLY_QUALIFIED)); buf.append("</li>"); // $NON-NLS-1$ } buf.append("</ul>"); // $NON-NLS-1$ return buf.toString(); }
private Iterator<ASTNode> getReplacementScope() throws JavaModelException { boolean declPredecessorReached = false; Collection<ASTNode> scope = new ArrayList<ASTNode>(); AbstractTypeDeclaration containingType = getContainingTypeDeclarationNode(); if (containingType instanceof EnumDeclaration) { // replace in all enum constants bodies EnumDeclaration enumDeclaration = (EnumDeclaration) containingType; scope.addAll(enumDeclaration.enumConstants()); } for (Iterator<IExtendedModifier> iter = containingType.modifiers().iterator(); iter.hasNext(); ) { IExtendedModifier modifier = iter.next(); if (modifier instanceof Annotation) { scope.add((ASTNode) modifier); } } for (Iterator<BodyDeclaration> bodyDeclarations = containingType.bodyDeclarations().iterator(); bodyDeclarations.hasNext(); ) { BodyDeclaration bodyDeclaration = bodyDeclarations.next(); if (bodyDeclaration == getNodeToInsertConstantDeclarationAfter()) declPredecessorReached = true; if (insertFirst() || declPredecessorReached || !isStaticFieldOrStaticInitializer(bodyDeclaration)) scope.add(bodyDeclaration); } return scope.iterator(); }
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) { SimpleName node = fOriginalNode; ASTNode newTypeDecl = astRoot.findDeclaringNode(fSenderBinding); if (newTypeDecl == null) { astRoot = ASTResolving.createQuickFixAST(getCompilationUnit(), null); newTypeDecl = astRoot.findDeclaringNode(fSenderBinding.getKey()); } if (newTypeDecl != null) { AST ast = newTypeDecl.getAST(); ASTRewrite rewrite = ASTRewrite.create(ast); EnumConstantDeclaration constDecl = ast.newEnumConstantDeclaration(); constDecl.setName(ast.newSimpleName(node.getIdentifier())); ListRewrite listRewriter = rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY); listRewriter.insertLast(constDecl, null); addLinkedPosition(rewrite.track(constDecl.getName()), false, KEY_NAME); return rewrite; } return null; }
public boolean visit(EnumDeclaration node) { ITypeBinding classType = node.resolveBinding(); String chordSig = chordClassName(classType); int lineNum = cu.getLineNumber(node.getName().getStartPosition()); XMLContainerObject object = new XMLContainerObject("class"); object.putAttribute("chordsig", escapeXml(chordSig)); object.putAttribute("line", Integer.toString(lineNum)); this.startObject(object); if(classType.isTopLevel()) { this.topLevelClassSig = chordSig; } return true; }
public void endVisit(EnumDeclaration node) { ITypeBinding classType = node.resolveBinding().getErasure(); if(classType.isTopLevel()) { this.topLevelClassSig = null; } this.endObject(); }
private Member _createMember(BodyDeclaration declaration) { List<String> modifiers = new ArrayList<>(); for (Object modifier : declaration.modifiers()) { modifiers.add(modifier.toString()); } StringBuilder sb = new StringBuilder(); _getVisibility(sb, modifiers); _getModifiers(sb, modifiers); if (declaration instanceof FieldDeclaration) { return _getFieldType((FieldDeclaration)declaration, sb); } if (declaration instanceof MethodDeclaration) { return _getMethodType((MethodDeclaration)declaration, sb); } if (declaration instanceof TypeDeclaration) { return _getClassType((TypeDeclaration)declaration, sb); } if (declaration instanceof Initializer) { return _getInitializerType((Initializer)declaration, sb); } if (declaration instanceof EnumDeclaration) { return _getEnumType((EnumDeclaration)declaration, sb); } return new Member("-nodata", "-nodata"); }
@Override public boolean visit(EnumDeclaration elem) { if (ElementTypeTeller.isModelEnum(elem)) { // TODO: check model enums } else { collector.report(new InvalidTypeInModel(collector.getSourceInfo(), elem)); } return false; }
@Override public boolean visit(EnumDeclaration node) { ITypeBinding binding = node.resolveBinding(); if (binding == null) { logNullBinding("enum declaration", node.getName(), ((CompilationUnit) node.getRoot()).getLineNumber(node.getStartPosition())); return false; } Enum famixEnum = (Enum) importer.ensureTypeFromTypeBinding(binding); famixEnum.setIsStub(false); importer.createSourceAnchor(famixEnum, node, (CompilationUnit) node.getRoot()); importer.ensureCommentFromBodyDeclaration(famixEnum, node); importer.pushOnContainerStack(famixEnum); return true; }