org.eclipse.jdt.core.dom.EnumDeclaration Java Examples

The following examples show how to use org.eclipse.jdt.core.dom.EnumDeclaration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MoveInnerToTopRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);
			}
		}
	}
}
 
Example #2
Source File: NewVariableCorrectionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: AddUnimplementedMethodsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@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();
}
 
Example #4
Source File: AstVisitor.java    From jdt2famix with Eclipse Public License 1.0 6 votes vote down vote up
@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;
	}
	Type ensureTypeFromTypeBinding = importer.ensureTypeFromTypeBinding(binding);
	if (ensureTypeFromTypeBinding instanceof Enum) {
		Enum famixEnum = (Enum) ensureTypeFromTypeBinding;
		createSourceAnchorsForInterfaceInheritance(node, famixEnum);
		famixEnum.setIsStub(false);
		importer.createSourceAnchor(famixEnum, node);
		importer.ensureCommentFromBodyDeclaration(famixEnum, node);
		importer.pushOnContainerStack(famixEnum);
	}
	return true;
}
 
Example #5
Source File: CompilationUnitBuilder.java    From j2cl with Apache License 2.0 6 votes vote down vote up
private void convert(EnumDeclaration enumDeclaration) {
  convertAndAddType(
      enumDeclaration,
      enumType -> {
        checkState(enumType.isEnum());

        int ordinal = 0;
        for (EnumConstantDeclaration enumConstantDeclaration :
            JdtUtils.<EnumConstantDeclaration>asTypedList(enumDeclaration.enumConstants())) {
          enumType.addField(ordinal, convert(enumConstantDeclaration));
          ordinal++;
        }
        EnumMethodsCreator.applyTo(enumType);
        return null;
      });
}
 
Example #6
Source File: UMLModelASTReader.java    From RefactoringMiner with MIT License 6 votes vote down vote up
private void processEnumDeclaration(CompilationUnit cu, EnumDeclaration enumDeclaration, String packageName, String sourceFile,
		List<String> importedTypes) {
	UMLJavadoc javadoc = generateJavadoc(enumDeclaration);
	if(javadoc != null && javadoc.containsIgnoreCase(FREE_MARKER_GENERATED)) {
		return;
	}
	String className = enumDeclaration.getName().getFullyQualifiedName();
	LocationInfo locationInfo = generateLocationInfo(cu, sourceFile, enumDeclaration, CodeElementType.TYPE_DECLARATION);
	UMLClass umlClass = new UMLClass(packageName, className, locationInfo, enumDeclaration.isPackageMemberTypeDeclaration(), importedTypes);
	umlClass.setJavadoc(javadoc);
	
	umlClass.setEnum(true);
	processModifiers(cu, sourceFile, enumDeclaration, umlClass);
	
	processBodyDeclarations(cu, enumDeclaration, packageName, sourceFile, importedTypes, umlClass);
	
	processAnonymousClassDeclarations(cu, enumDeclaration, packageName, sourceFile, className, umlClass);
	
	this.getUmlModel().addClass(umlClass);
}
 
Example #7
Source File: ModifierRewrite.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
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$
	}
}
 
Example #8
Source File: JdtFlags.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
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());
}
 
Example #9
Source File: UMLModelASTReader.java    From RefactoringMiner with MIT License 6 votes vote down vote up
protected void processCompilationUnit(String sourceFilePath, CompilationUnit compilationUnit) {
	PackageDeclaration packageDeclaration = compilationUnit.getPackage();
	String packageName = null;
	if(packageDeclaration != null)
		packageName = packageDeclaration.getName().getFullyQualifiedName();
	else
		packageName = "";
	
	List<ImportDeclaration> imports = compilationUnit.imports();
	List<String> importedTypes = new ArrayList<String>();
	for(ImportDeclaration importDeclaration : imports) {
		importedTypes.add(importDeclaration.getName().getFullyQualifiedName());
	}
	List<AbstractTypeDeclaration> topLevelTypeDeclarations = compilationUnit.types();
       for(AbstractTypeDeclaration abstractTypeDeclaration : topLevelTypeDeclarations) {
       	if(abstractTypeDeclaration instanceof TypeDeclaration) {
       		TypeDeclaration topLevelTypeDeclaration = (TypeDeclaration)abstractTypeDeclaration;
       		processTypeDeclaration(compilationUnit, topLevelTypeDeclaration, packageName, sourceFilePath, importedTypes);
       	}
       	else if(abstractTypeDeclaration instanceof EnumDeclaration) {
       		EnumDeclaration enumDeclaration = (EnumDeclaration)abstractTypeDeclaration;
       		processEnumDeclaration(compilationUnit, enumDeclaration, packageName, sourceFilePath, importedTypes);
       	}
       }
}
 
Example #10
Source File: ModifierRewrite.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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$
	}
}
 
Example #11
Source File: ChangeSignatureProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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())));
		}
	}
}
 
Example #12
Source File: Bindings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: FileVisitor.java    From repositoryminer with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #14
Source File: NewVariableCorrectionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example #15
Source File: TestQ19.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preVisit2(ASTNode node) {
	if (node instanceof EnumDeclaration|| node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface())
		return false;
	if (node instanceof TypeDeclaration || node instanceof AnonymousClassDeclaration){
		fieldsStack.push(fieds2);
		fieds2 = 0;
	}
	return true;
}
 
Example #16
Source File: ExtractConstantRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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();
}
 
Example #17
Source File: TestQ10.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preVisit2(ASTNode node) {
	if (node instanceof EnumDeclaration|| node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface())
		return false;
	if (node instanceof TypeDeclaration || node instanceof AnonymousClassDeclaration){
		methodsStack.push(methods2);
		methods2 = 0;
	}
	return true;
}
 
Example #18
Source File: UMLModelASTReader.java    From RefactoringMiner with MIT License 5 votes vote down vote up
private void processBodyDeclarations(CompilationUnit cu, AbstractTypeDeclaration abstractTypeDeclaration, String packageName,
		String sourceFile, List<String> importedTypes, UMLClass umlClass) {
	List<BodyDeclaration> bodyDeclarations = abstractTypeDeclaration.bodyDeclarations();
	for(BodyDeclaration bodyDeclaration : bodyDeclarations) {
		if(bodyDeclaration instanceof FieldDeclaration) {
			FieldDeclaration fieldDeclaration = (FieldDeclaration)bodyDeclaration;
			List<UMLAttribute> attributes = processFieldDeclaration(cu, fieldDeclaration, umlClass.isInterface(), sourceFile);
    		for(UMLAttribute attribute : attributes) {
    			attribute.setClassName(umlClass.getName());
    			umlClass.addAttribute(attribute);
    		}
		}
		else if(bodyDeclaration instanceof MethodDeclaration) {
			MethodDeclaration methodDeclaration = (MethodDeclaration)bodyDeclaration;
			UMLOperation operation = processMethodDeclaration(cu, methodDeclaration, packageName, umlClass.isInterface(), sourceFile);
    		operation.setClassName(umlClass.getName());
    		umlClass.addOperation(operation);
		}
		else if(bodyDeclaration instanceof TypeDeclaration) {
			TypeDeclaration typeDeclaration = (TypeDeclaration)bodyDeclaration;
			processTypeDeclaration(cu, typeDeclaration, umlClass.getName(), sourceFile, importedTypes);
		}
		else if(bodyDeclaration instanceof EnumDeclaration) {
			EnumDeclaration enumDeclaration = (EnumDeclaration)bodyDeclaration;
			processEnumDeclaration(cu, enumDeclaration, umlClass.getName(), sourceFile, importedTypes);
		}
	}
}
 
Example #19
Source File: TestQ16.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preVisit2(ASTNode node) {
	if (node instanceof EnumDeclaration
			|| node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface())
		return false;
	if (node instanceof TypeDeclaration || node instanceof AnonymousClassDeclaration) {
		methodsStack.push(methods2);
		methods2 = 0;
	}
	return true;
}
 
Example #20
Source File: TestQ22.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preVisit2(ASTNode node) {
	if (node instanceof EnumDeclaration|| node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface())
		return false;
	if (node instanceof TypeDeclaration || node instanceof AnonymousClassDeclaration){
		stringFieldStack.push(stringField2);
		stringField2 = 0;
	}
	return true;
}
 
Example #21
Source File: TestQ13.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preVisit2(ASTNode node) {
	if (node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface()) {
		methodsStack.push(methods2);
		methods2 = 0;
		interfaces++;
		return true;
	}
	if (node instanceof TypeDeclaration || node instanceof AnonymousClassDeclaration
			|| node instanceof EnumDeclaration) {
		return false;
	}
	return true;
}
 
Example #22
Source File: Testq12.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preVisit2(ASTNode node) {
	if (node instanceof EnumDeclaration
			|| node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface())
		return false;
	if (node instanceof TypeDeclaration || node instanceof AnonymousClassDeclaration) {
		methodsStack.push(methods2);
		methods2 = 0;
	}
	return true;
}
 
Example #23
Source File: TestQ21.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preVisit2(ASTNode node) {
	if (node instanceof EnumDeclaration|| node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface()) {
		return false;
	}
	if (node instanceof TypeDeclaration || node instanceof AnonymousClassDeclaration) {
		classes++;
		fieldsStack.push(fieds2);
		fieds2 = 0;
	}
	return true;
}
 
Example #24
Source File: MethodsInClass.java    From api-mining with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean visit(final EnumDeclaration node) {
	if (className.isEmpty()) {
		className.push(currentPackageName + "."
				+ node.getName().getIdentifier());
	} else {
		className.push(className.peek() + "."
				+ node.getName().getIdentifier());
	}
	return super.visit(node);
}
 
Example #25
Source File: MethodsInClass.java    From tassal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean visit(final EnumDeclaration node) {
	if (className.isEmpty()) {
		className.push(currentPackageName + "."
				+ node.getName().getIdentifier());
	} else {
		className.push(className.peek() + "."
				+ node.getName().getIdentifier());
	}
	return super.visit(node);
}
 
Example #26
Source File: JdtFlags.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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());
}
 
Example #27
Source File: TestQ15.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preVisit2(ASTNode node) {
	if (node instanceof EnumDeclaration|| node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface())
		return false;
	if (node instanceof TypeDeclaration || node instanceof AnonymousClassDeclaration){
		methodsStack.push(methods2);
		methods2 = 0;
	}
	return true;
}
 
Example #28
Source File: TestQ1.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean preVisit2(ASTNode node) {
	if (node instanceof EnumDeclaration|| node instanceof TypeDeclaration && ((TypeDeclaration) node).isInterface())
		return false;
	if (node instanceof TypeDeclaration || node instanceof AnonymousClassDeclaration){
		classes ++;
	}
	return true;
}
 
Example #29
Source File: AbstractExceptionAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(EnumDeclaration node) {
	// Don't dive into a local type.
	if (node.isLocalTypeDeclaration())
		return false;
	return true;
}
 
Example #30
Source File: TypenameScopeExtractor.java    From tassal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean visit(EnumDeclaration node) {
	if (topClass == null) {
		topClass = node;
	}
	types.put(topClass, node.getName().getIdentifier());
	return super.visit(node);
}