Java Code Examples for org.eclipse.jdt.core.dom.Modifier#PUBLIC

The following examples show how to use org.eclipse.jdt.core.dom.Modifier#PUBLIC . 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: ModifierCorrectionSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static int getNeededVisibility(ASTNode currNode, ITypeBinding targetType, IBinding binding) {
	ITypeBinding currNodeBinding = Bindings.getBindingOfParentType(currNode);
	if (currNodeBinding == null) { // import
		return Modifier.PUBLIC;
	}

	if (Bindings.isSuperType(targetType, currNodeBinding)) {
		if (binding != null && (JdtFlags.isProtected(binding) || binding.getKind() == IBinding.TYPE)) {
			return Modifier.PUBLIC;
		}
		return Modifier.PROTECTED;
	}

	if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) {
		return 0;
	}
	return Modifier.PUBLIC;
}
 
Example 2
Source File: JdtFlags.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Compares two visibilities.
 *
 * @param newVisibility the 'new' visibility
 * @param oldVisibility the 'old' visibility
 * @return <code>true</code> iff the 'new' visibility is strictly higher than the old visibility
 *
 * @see Modifier#PUBLIC
 * @see Modifier#PROTECTED
 * @see Modifier#NONE
 * @see Modifier#PRIVATE
 */
public static boolean isHigherVisibility(int newVisibility, int oldVisibility){
	assertVisibility(oldVisibility);
	assertVisibility(newVisibility);
	switch (oldVisibility) {
		case Modifier.PRIVATE :
			return 	newVisibility == Modifier.NONE
					||	newVisibility == Modifier.PUBLIC
					||  newVisibility == Modifier.PROTECTED;
		case Modifier.NONE :
			return 	newVisibility == Modifier.PUBLIC
					||  newVisibility == Modifier.PROTECTED;

		case Modifier.PROTECTED :
			return newVisibility == Modifier.PUBLIC;

		case Modifier.PUBLIC :
			return false;
		default:
			Assert.isTrue(false);
			return false;
	}
}
 
Example 3
Source File: AddUnimplementedConstructorsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a new add unimplemented constructors operation.
 *
 * @param astRoot the compilation unit AST node
 * @param type the type to add the methods to
 * @param constructorsToImplement the method binding keys to implement
 * @param insertPos the insertion point, or <code>-1</code>
 * @param imports <code>true</code> if the import edits should be applied, <code>false</code> otherwise
 * @param apply <code>true</code> if the resulting edit should be applied, <code>false</code> otherwise
 * @param save <code>true</code> if the changed compilation unit should be saved, <code>false</code> otherwise
 */
public AddUnimplementedConstructorsOperation(CompilationUnit astRoot, ITypeBinding type, IMethodBinding[] constructorsToImplement, int insertPos, final boolean imports, final boolean apply, final boolean save) {
	if (astRoot == null || !(astRoot.getJavaElement() instanceof ICompilationUnit)) {
		throw new IllegalArgumentException("AST must not be null and has to be created from a ICompilationUnit"); //$NON-NLS-1$
	}
	if (type == null) {
		throw new IllegalArgumentException("The type must not be null"); //$NON-NLS-1$
	}
	ASTNode node= astRoot.findDeclaringNode(type);
	if (!(node instanceof AnonymousClassDeclaration || node instanceof AbstractTypeDeclaration)) {
		throw new IllegalArgumentException("type has to map to a type declaration in the AST"); //$NON-NLS-1$
	}

	fType= type;
	fInsertPos= insertPos;
	fASTRoot= astRoot;
	fConstructorsToImplement= constructorsToImplement;
	fSave= save;
	fApply= apply;
	fImports= imports;

	fCreateComments= StubUtility.doAddComments(astRoot.getJavaElement().getJavaProject());
	fVisibility= Modifier.PUBLIC;
	fOmitSuper= false;
}
 
Example 4
Source File: UMLModelASTReader.java    From RefactoringMiner with MIT License 6 votes vote down vote up
private void processModifiers(CompilationUnit cu, String sourceFile, AbstractTypeDeclaration typeDeclaration, UMLClass umlClass) {
	int modifiers = typeDeclaration.getModifiers();
   	if((modifiers & Modifier.ABSTRACT) != 0)
   		umlClass.setAbstract(true);
   	
   	if((modifiers & Modifier.PUBLIC) != 0)
   		umlClass.setVisibility("public");
   	else if((modifiers & Modifier.PROTECTED) != 0)
   		umlClass.setVisibility("protected");
   	else if((modifiers & Modifier.PRIVATE) != 0)
   		umlClass.setVisibility("private");
   	else
   		umlClass.setVisibility("package");
   	
   	List<IExtendedModifier> extendedModifiers = typeDeclaration.modifiers();
	for(IExtendedModifier extendedModifier : extendedModifiers) {
		if(extendedModifier.isAnnotation()) {
			Annotation annotation = (Annotation)extendedModifier;
			umlClass.addAnnotation(new UMLAnnotation(cu, sourceFile, annotation));
		}
	}
}
 
Example 5
Source File: NewMethodCorrectionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private int getInterfaceMethodModifiers(ASTNode targetTypeDecl, boolean createAbstractMethod) {
	// for interface and annotation members copy the modifiers from an existing member
	if (targetTypeDecl instanceof TypeDeclaration) {
		TypeDeclaration type= (TypeDeclaration) targetTypeDecl;
		MethodDeclaration[] methodDecls= type.getMethods();
		if (methodDecls.length > 0) {
			if (createAbstractMethod) {
				for (MethodDeclaration methodDeclaration : methodDecls) {
					IMethodBinding methodBinding= methodDeclaration.resolveBinding();
					if (methodBinding != null && JdtFlags.isAbstract(methodBinding)) {
						return methodDeclaration.getModifiers();
					}
				}
			}
			return methodDecls[0].getModifiers() & Modifier.PUBLIC;
		}
		List<BodyDeclaration> bodyDecls= type.bodyDeclarations();
		if (bodyDecls.size() > 0) {
			return bodyDecls.get(0).getModifiers() & Modifier.PUBLIC;
		}
	}
	return 0;
}
 
Example 6
Source File: NewVariableCorrectionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private int evaluateFieldModifiers(ASTNode newTypeDecl) {
	if (fSenderBinding.isAnnotation()) {
		return 0;
	}
	if (fSenderBinding.isInterface()) {
		// for interface members copy the modifiers from an existing field
		FieldDeclaration[] fieldDecls= ((TypeDeclaration) newTypeDecl).getFields();
		if (fieldDecls.length > 0) {
			return fieldDecls[0].getModifiers();
		}
		return 0;
	}
	int modifiers= 0;

	if (fVariableKind == CONST_FIELD) {
		modifiers |= Modifier.FINAL | Modifier.STATIC;
	} else {
		ASTNode parent= fOriginalNode.getParent();
		if (parent instanceof QualifiedName) {
			IBinding qualifierBinding= ((QualifiedName)parent).getQualifier().resolveBinding();
			if (qualifierBinding instanceof ITypeBinding) {
				modifiers |= Modifier.STATIC;
			}
		} else if (ASTResolving.isInStaticContext(fOriginalNode)) {
			modifiers |= Modifier.STATIC;
		}
	}
	ASTNode node= ASTResolving.findParentType(fOriginalNode, true);
	if (newTypeDecl.equals(node)) {
		modifiers |= Modifier.PRIVATE;
	} else if (node instanceof AnonymousClassDeclaration) {
		modifiers |= Modifier.PROTECTED;
	} else {
		modifiers |= Modifier.PUBLIC;
	}

	return modifiers;
}
 
Example 7
Source File: MoveStaticMembersProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean isVisibleFrom(IType newMemberDeclaringType, IType accessingType) throws JavaModelException {
	int memberVisibility= JdtFlags.getVisibilityCode(newMemberDeclaringType);

	IType declaringType= newMemberDeclaringType.getDeclaringType();
	while (declaringType != null) { //get lowest visibility in all parent types of newMemberDeclaringType
		memberVisibility= JdtFlags.getLowerVisibility(
				memberVisibility, JdtFlags.getVisibilityCode(declaringType));
		declaringType= declaringType.getDeclaringType();
	}

	switch (memberVisibility) {
		case Modifier.PRIVATE :
			return isEqualOrEnclosedType(accessingType, newMemberDeclaringType);

		case Modifier.NONE :
			return JavaModelUtil.isSamePackage(accessingType.getPackageFragment(), newMemberDeclaringType.getPackageFragment());

		case Modifier.PROTECTED :
			return JavaModelUtil.isSamePackage(accessingType.getPackageFragment(), newMemberDeclaringType.getPackageFragment())
					|| accessingType.newSupertypeHierarchy(null).contains(newMemberDeclaringType);

		case Modifier.PUBLIC :
			return true;

		default:
			Assert.isTrue(false);
			return false;
	}
}
 
Example 8
Source File: UMLModelASTReader.java    From RefactoringMiner with MIT License 5 votes vote down vote up
private List<UMLAttribute> processFieldDeclaration(CompilationUnit cu, FieldDeclaration fieldDeclaration, boolean isInterfaceField, String sourceFile) {
	UMLJavadoc javadoc = generateJavadoc(fieldDeclaration);
	List<UMLAttribute> attributes = new ArrayList<UMLAttribute>();
	Type fieldType = fieldDeclaration.getType();
	List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments();
	for(VariableDeclarationFragment fragment : fragments) {
		UMLType type = UMLType.extractTypeObject(cu, sourceFile, fieldType, fragment.getExtraDimensions());
		String fieldName = fragment.getName().getFullyQualifiedName();
		LocationInfo locationInfo = generateLocationInfo(cu, sourceFile, fragment, CodeElementType.FIELD_DECLARATION);
		UMLAttribute umlAttribute = new UMLAttribute(fieldName, type, locationInfo);
		VariableDeclaration variableDeclaration = new VariableDeclaration(cu, sourceFile, fragment);
		variableDeclaration.setAttribute(true);
		umlAttribute.setVariableDeclaration(variableDeclaration);
		umlAttribute.setJavadoc(javadoc);
		
		int fieldModifiers = fieldDeclaration.getModifiers();
		if((fieldModifiers & Modifier.PUBLIC) != 0)
			umlAttribute.setVisibility("public");
		else if((fieldModifiers & Modifier.PROTECTED) != 0)
			umlAttribute.setVisibility("protected");
		else if((fieldModifiers & Modifier.PRIVATE) != 0)
			umlAttribute.setVisibility("private");
		else if(isInterfaceField)
			umlAttribute.setVisibility("public");
		else
			umlAttribute.setVisibility("package");
		
		if((fieldModifiers & Modifier.FINAL) != 0)
			umlAttribute.setFinal(true);
		
		if((fieldModifiers & Modifier.STATIC) != 0)
			umlAttribute.setStatic(true);
		
		attributes.add(umlAttribute);
	}
	return attributes;
}
 
Example 9
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(final Modifier it) {
  boolean append = true;
  int _flagValue = it.getKeyword().toFlagValue();
  switch (_flagValue) {
    case Modifier.PUBLIC:
      if (((it.getParent() instanceof TypeDeclaration) || (it.getParent() instanceof MethodDeclaration))) {
        append = false;
      }
      break;
    case Modifier.PRIVATE:
      ASTNode _parent = it.getParent();
      if ((_parent instanceof FieldDeclaration)) {
        append = false;
      }
      break;
    case Modifier.FINAL:
      if (((it.getParent() instanceof VariableDeclarationExpression) || (it.getParent() instanceof VariableDeclarationStatement))) {
        append = false;
      }
      break;
    default:
      append = true;
      break;
  }
  if (append) {
    String valueToAppend = it.getKeyword().toString();
    int _flagValue_1 = it.getKeyword().toFlagValue();
    boolean _equals = (_flagValue_1 == 0);
    if (_equals) {
      valueToAppend = "package";
    }
    this.appendToBuffer(valueToAppend);
    this.appendSpaceToBuffer();
  }
  return false;
}
 
Example 10
Source File: NewVariableCorrectionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int evaluateFieldModifiers(ASTNode newTypeDecl) {
	if (fSenderBinding.isAnnotation()) {
		return 0;
	}
	if (fSenderBinding.isInterface()) {
		// for interface members copy the modifiers from an existing field
		FieldDeclaration[] fieldDecls= ((TypeDeclaration) newTypeDecl).getFields();
		if (fieldDecls.length > 0) {
			return fieldDecls[0].getModifiers();
		}
		return 0;
	}
	int modifiers= 0;

	if (fVariableKind == CONST_FIELD) {
		modifiers |= Modifier.FINAL | Modifier.STATIC;
	} else {
		ASTNode parent= fOriginalNode.getParent();
		if (parent instanceof QualifiedName) {
			IBinding qualifierBinding= ((QualifiedName)parent).getQualifier().resolveBinding();
			if (qualifierBinding instanceof ITypeBinding) {
				modifiers |= Modifier.STATIC;
			}
		} else if (ASTResolving.isInStaticContext(fOriginalNode)) {
			modifiers |= Modifier.STATIC;
		}
	}
	ASTNode node= ASTResolving.findParentType(fOriginalNode, true);
	if (newTypeDecl.equals(node)) {
		modifiers |= Modifier.PRIVATE;
	} else if (node instanceof AnonymousClassDeclaration) {
		modifiers |= Modifier.PROTECTED;
	} else {
		modifiers |= Modifier.PUBLIC;
	}

	return modifiers;
}
 
Example 11
Source File: TokenModifiers.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean applies(IBinding binding) {
    int flags = binding.getModifiers();
    if ((flags & Modifier.PUBLIC) != 0) {
        return true;
    }
    return false;
}
 
Example 12
Source File: SelfEncapsulateFieldRefactoring.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private int createModifiers() throws JavaModelException {
	int result = 0;
	if (Flags.isPublic(fVisibility)) {
		result |= Modifier.PUBLIC;
	} else if (Flags.isProtected(fVisibility)) {
		result |= Modifier.PROTECTED;
	} else if (Flags.isPrivate(fVisibility)) {
		result |= Modifier.PRIVATE;
	}
	if (JdtFlags.isStatic(fField)) {
		result |= Modifier.STATIC;
	}
	return result;
}
 
Example 13
Source File: SourceActionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected Composite addVisibilityAndModifiersChoices(Composite buttonComposite) {
	// Add visibility and modifiers buttons: http://bugs.eclipse.org/bugs/show_bug.cgi?id=35870
	// Add persistence of options: http://bugs.eclipse.org/bugs/show_bug.cgi?id=38400
	IVisibilityChangeListener visibilityChangeListener= new IVisibilityChangeListener(){
		public void visibilityChanged(int newVisibility) {
			setVisibility(newVisibility);
		}
		public void modifierChanged(int modifier, boolean isChecked) {
			switch (modifier) {
				case Modifier.FINAL:  {
					setFinal(isChecked);
					return;
				}
				case Modifier.SYNCHRONIZED:  {
					setSynchronized(isChecked);
					return;
				}
				default: return;
			}
		}
	};

	int initialVisibility= getVisibilityModifier();
	int[] availableVisibilities= new int[]{Modifier.PUBLIC, Modifier.PROTECTED, Modifier.PRIVATE, Modifier.NONE};

	Composite visibilityComposite= createVisibilityControlAndModifiers(buttonComposite, visibilityChangeListener, availableVisibilities, initialVisibility);
	return visibilityComposite;
}
 
Example 14
Source File: JdtFlags.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static int getVisibilityCode(String visibilityString) {
	Assert.isNotNull(visibilityString);
	if (VISIBILITY_STRING_PACKAGE.equals(visibilityString)) {
		return 0;
	} else if (VISIBILITY_STRING_PRIVATE.equals(visibilityString)) {
		return Modifier.PRIVATE;
	} else if (VISIBILITY_STRING_PROTECTED.equals(visibilityString)) {
		return Modifier.PROTECTED;
	} else if (VISIBILITY_STRING_PUBLIC.equals(visibilityString)) {
		return Modifier.PUBLIC;
	}
	return VISIBILITY_CODE_INVALID;
}
 
Example 15
Source File: JdtFlags.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static int getVisibilityCode(IBinding binding) {
	if (isPublic(binding)) {
		return Modifier.PUBLIC;
	} else if (isProtected(binding)) {
		return Modifier.PROTECTED;
	} else if (isPackageVisible(binding)) {
		return Modifier.NONE;
	} else if (isPrivate(binding)) {
		return Modifier.PRIVATE;
	}
	Assert.isTrue(false);
	return VISIBILITY_CODE_INVALID;
}
 
Example 16
Source File: SelfEncapsulateFieldRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private TextEditGroup makeDeclarationPrivate(ASTRewrite rewriter, FieldDeclaration decl) {
	TextEditGroup description= new TextEditGroup(RefactoringCoreMessages.SelfEncapsulateField_change_visibility);
	VariableDeclarationFragment[] vdfs= new VariableDeclarationFragment[] { fFieldDeclaration };
	int includedModifiers= Modifier.PRIVATE;
	int excludedModifiers= Modifier.PROTECTED | Modifier.PUBLIC;
	VariableDeclarationRewrite.rewriteModifiers(decl, vdfs, includedModifiers, excludedModifiers, rewriter, description);
	return description;
}
 
Example 17
Source File: NewMethodCorrectionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int evaluateModifiers(ASTNode targetTypeDecl) {
	if (getSenderBinding().isAnnotation()) {
		return 0;
	}
	if (getSenderBinding().isInterface()) {
		// for interface and annotation members copy the modifiers from an existing field
		MethodDeclaration[] methodDecls= ((TypeDeclaration) targetTypeDecl).getMethods();
		if (methodDecls.length > 0) {
			return methodDecls[0].getModifiers();
		}
		return 0;
	}
	ASTNode invocationNode= getInvocationNode();
	if (invocationNode instanceof MethodInvocation) {
		int modifiers= 0;
		Expression expression= ((MethodInvocation)invocationNode).getExpression();
		if (expression != null) {
			if (expression instanceof Name && ((Name) expression).resolveBinding().getKind() == IBinding.TYPE) {
				modifiers |= Modifier.STATIC;
			}
		} else if (ASTResolving.isInStaticContext(invocationNode)) {
			modifiers |= Modifier.STATIC;
		}
		ASTNode node= ASTResolving.findParentType(invocationNode);
		if (targetTypeDecl.equals(node)) {
			modifiers |= Modifier.PRIVATE;
		} else if (node instanceof AnonymousClassDeclaration && ASTNodes.isParent(node, targetTypeDecl)) {
			modifiers |= Modifier.PROTECTED;
			if (ASTResolving.isInStaticContext(node) && expression == null) {
				modifiers |= Modifier.STATIC;
			}
		} else {
			modifiers |= Modifier.PUBLIC;
		}
		return modifiers;
	}
	return Modifier.PUBLIC;
}
 
Example 18
Source File: SourceActionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected Composite createVisibilityControl(Composite parent, final IVisibilityChangeListener visibilityChangeListener, int[] availableVisibilities, int correctVisibility) {
	fAllowedVisibilities= convertToIntegerList(availableVisibilities);
	if (fAllowedVisibilities.size() == 1)
		return null;

	Group group= new Group(parent, SWT.NONE);
	group.setText(ActionMessages.SourceActionDialog_modifier_group);
	GridData gd= new GridData(GridData.FILL_BOTH);
	group.setLayoutData(gd);
	GridLayout layout= new GridLayout();
	layout.makeColumnsEqualWidth= true;
	layout.numColumns= 4;
	group.setLayout(layout);

	String[] labels= new String[] {
		ActionMessages.SourceActionDialog_modifier_public,
		ActionMessages.SourceActionDialog_modifier_protected,
		ActionMessages.SourceActionDialog_modifier_default,
		ActionMessages.SourceActionDialog_modifier_private,
	};
	Integer[] data= new Integer[] {
				new Integer(Modifier.PUBLIC),
				new Integer(Modifier.PROTECTED),
				new Integer(Modifier.NONE),
				new Integer(Modifier.PRIVATE)};
	Integer initialVisibility= new Integer(correctVisibility);
	for (int i= 0; i < labels.length; i++) {
		Button radio= new Button(group, SWT.RADIO);
		Integer visibilityCode= data[i];
		radio.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
		radio.setText(labels[i]);
		radio.setData(visibilityCode);
		radio.setSelection(visibilityCode.equals(initialVisibility));
		radio.setEnabled(fAllowedVisibilities.contains(visibilityCode));
		radio.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent event) {
				visibilityChangeListener.visibilityChanged(((Integer)event.widget.getData()).intValue());
			}
		});
	}
	return group;
}
 
Example 19
Source File: ASTReader.java    From JDeodorant with MIT License 4 votes vote down vote up
private ClassObject processEnumDeclaration(IFile iFile, IDocument document, EnumDeclaration enumDeclaration, List<Comment> comments) {
	final ClassObject classObject = new ClassObject();
	classObject.setEnum(true);
	classObject.setIFile(iFile);
	classObject.addComments(processComments(iFile, document, enumDeclaration, comments));
	classObject.setName(enumDeclaration.resolveBinding().getQualifiedName());
	classObject.setAbstractTypeDeclaration(enumDeclaration);
	
	int modifiers = enumDeclaration.getModifiers();
	if((modifiers & Modifier.ABSTRACT) != 0)
		classObject.setAbstract(true);
	
	if((modifiers & Modifier.PUBLIC) != 0)
		classObject.setAccess(Access.PUBLIC);
	else if((modifiers & Modifier.PROTECTED) != 0)
		classObject.setAccess(Access.PROTECTED);
	else if((modifiers & Modifier.PRIVATE) != 0)
		classObject.setAccess(Access.PRIVATE);
	else
		classObject.setAccess(Access.NONE);
	
	if((modifiers & Modifier.STATIC) != 0)
		classObject.setStatic(true);
	
	List<Type> superInterfaceTypes = enumDeclaration.superInterfaceTypes();
	for(Type interfaceType : superInterfaceTypes) {
		ITypeBinding binding = interfaceType.resolveBinding();
		String qualifiedName = binding.getQualifiedName();
		TypeObject typeObject = TypeObject.extractTypeObject(qualifiedName);
		classObject.addInterface(typeObject);
	}
	
	List<EnumConstantDeclaration> enumConstantDeclarations = enumDeclaration.enumConstants();
	for(EnumConstantDeclaration enumConstantDeclaration : enumConstantDeclarations) {
		EnumConstantDeclarationObject enumConstantDeclarationObject = new EnumConstantDeclarationObject(enumConstantDeclaration.getName().getIdentifier());
		enumConstantDeclarationObject.setEnumName(classObject.getName());
		enumConstantDeclarationObject.setEnumConstantDeclaration(enumConstantDeclaration);
		List<Expression> arguments = enumConstantDeclaration.arguments();
		for(Expression argument : arguments) {
			AbstractExpression abstractExpression = new AbstractExpression(argument);
			enumConstantDeclarationObject.addArgument(abstractExpression);
		}
		classObject.addEnumConstantDeclaration(enumConstantDeclarationObject);
	}
	
	List<BodyDeclaration> bodyDeclarations = enumDeclaration.bodyDeclarations();
	for(BodyDeclaration bodyDeclaration : bodyDeclarations) {
		if(bodyDeclaration instanceof MethodDeclaration) {
			processMethodDeclaration(classObject, (MethodDeclaration)bodyDeclaration);
		}
		else if(bodyDeclaration instanceof FieldDeclaration) {
			processFieldDeclaration(classObject, (FieldDeclaration)bodyDeclaration);
		}
	}
	return classObject;
}
 
Example 20
Source File: MemberVisibilityAdjustor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Is the specified modifier a visibility modifier?
 *
 * @param modifier the keyword to test
 * @return <code>true</code> if it is a visibility modifier, <code>false</code> otherwise
 */
private static boolean isVisibilityModifier(final int modifier) {
	return modifier == Modifier.NONE || modifier == Modifier.PUBLIC || modifier == Modifier.PROTECTED || modifier == Modifier.PRIVATE;
}