当前位置: 首页>>代码示例>>Java>>正文


Java FieldDeclaration.getModifiers方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.FieldDeclaration.getModifiers方法的典型用法代码示例。如果您正苦于以下问题:Java FieldDeclaration.getModifiers方法的具体用法?Java FieldDeclaration.getModifiers怎么用?Java FieldDeclaration.getModifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.FieldDeclaration的用法示例。


在下文中一共展示了FieldDeclaration.getModifiers方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(FieldDeclaration fieldDeclaration) {
    Type fieldType = fieldDeclaration.getType();
    int fieldModifiers = fieldDeclaration.getModifiers();
    Visibility visibility = getVisibility(fieldModifiers);
    // boolean isFinal = (fieldModifiers & Modifier.FINAL) != 0;
    boolean isStatic = (fieldModifiers & Modifier.STATIC) != 0;
    List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments();
    for (VariableDeclarationFragment fragment : fragments) {
        String fieldName = fragment.getName().getIdentifier();
        final SDAttribute attribute = model.createAttribute(fieldName, containerStack.peek());
        attribute.setStatic(isStatic);
        attribute.setVisibility(visibility);
        attribute.setType(AstUtils.normalizeTypeName(fieldType, fragment.getExtraDimensions(), false));

        Expression expression = fragment.getInitializer();
        if (expression != null) {
            //attribute.setAssignment(srbForAttributes.buildSourceRepresentation(fileContent, expression.getStartPosition(), expression.getLength()));
            addClientCode(attribute.key().toString(), srbForAttributes.buildPartialSourceRepresentation(fileContent, expression));
        }
        attribute.setClientCode(srbForAttributes.buildEmptySourceRepresentation());
    }
    return true;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:25,代码来源:BindingsRecoveryAstVisitor.java

示例2: visit

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(FieldDeclaration node) {

	int modifiers = node.getModifiers();
	if (Modifier.isPrivate(modifiers) || Modifier.isProtected(modifiers)) {
		List<VariableDeclarationFragment> fragments = node.fragments();
		for (VariableDeclarationFragment varDeclFrag : fragments) {
			IVariableBinding varBinding = varDeclFrag.resolveBinding();
			String enclosingClass = varBinding.getDeclaringClass().getQualifiedName();
			if(!varBinding.getType().isPrimitive() && !varBinding.getType().getQualifiedName().equals("java.lang.String")){
				final TACVariable fieldVar = new TACVariable(varBinding);
				if(!enclosingClass.equals(Config.MAINCLASS)){
					context.addEncapsulatedVariable(fieldVar);
				}
			}
		}
	}
	return super.visit(node);
}
 
开发者ID:aroog,项目名称:code,代码行数:20,代码来源:HeuristicOwnedVisitor.java

示例3: parseFieldDeclaration

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
/**
 * Factory Method for ASTField.
 * 
 * @param node
 *          FiledDeclaration node of Eclipse AST
 */
public void parseFieldDeclaration(FieldDeclaration node) {
  for (Object obj : node.fragments()) {
    VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
    String fieldName = fragment.getName().toString();

    int fieldModifier = node.getModifiers();
    String fieldVisibility = getVisibility(fieldModifier);
    Blob fieldBlob = new Blob(fieldVisibility + "\n", fieldName);

    if (fieldMap.containsKey(fieldName)) {
      int numConflicted = 0;
      for (Blob field : fieldMap.get(fieldName)) {
        conflict(field, fieldName, numConflicted++);
      }
      conflict(fieldBlob, fieldName, numConflicted);
    }
    fieldMap.put(fieldName, fieldBlob);
  }
}
 
开发者ID:niyaton,项目名称:kenja-java-parser,代码行数:26,代码来源:ASTField.java

示例4: getVisibility

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
private static String getVisibility(FieldDeclaration decl) {
    int modifiers = decl.getModifiers();
    if (Modifier.isPrivate(modifiers))
        return "private";
    if (Modifier.isProtected(modifiers))
        return "protected";
    if (Modifier.isPublic(modifiers))
        return "public";
    return "package";
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:11,代码来源:JavaASTVisitor.java

示例5: isUiField

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
public static boolean isUiField(FieldDeclaration fieldDecl) {
  if ((fieldDecl.getModifiers() & Modifier.STATIC) != 0) {
    return false;
  }
  return (JavaASTUtils.findAnnotation(fieldDecl,
      UiBinderConstants.UI_FIELD_ANNOTATION_NAME) != null);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:8,代码来源:UiBinderUtilities.java

示例6: visit

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(FieldDeclaration node)
{
	if (nestLevel != 1)
		return false;
	int modifiers = node.getModifiers();
	// Check modifers to spare binding overhead.
	if (Modifier.isPublic(modifiers) || !Modifier.isFinal(modifiers))
	{
		@SuppressWarnings("unchecked")
		List<VariableDeclarationFragment> fragments = node.fragments();
		for (VariableDeclarationFragment fragment : fragments)
		{
			String fieldName = fragment.getName().toString();
			String qualifiedName = getQualifiedNameFromType(node.getType());
			if (qualifiedName != null)
			{
				if (Modifier.isPublic(modifiers))
					readableFields.put(fieldName,
						NameUtil.resolveTypeParam(actualTypeParams, typeParams, qualifiedName));
				if (!Modifier.isFinal(modifiers))
					writableFields.put(fieldName,
						NameUtil.resolveTypeParam(actualTypeParams, typeParams, qualifiedName));
			}
		}
	}
	return false;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:29,代码来源:BeanPropertyVisitor.java

示例7: isFinal

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
private static boolean isFinal(FieldDeclaration decl) {
    int modifiers = decl.getModifiers();
    return (Modifier.isFinal(modifiers));
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:5,代码来源:JavaASTVisitor.java

示例8: isStatic

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
private static boolean isStatic(FieldDeclaration decl) {
    int modifiers = decl.getModifiers();
    return (Modifier.isStatic(modifiers));
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:5,代码来源:JavaASTVisitor.java

示例9: performFieldRewrite

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
private FieldDeclaration performFieldRewrite(IType type, ParameterObjectFactory pof, RefactoringStatus status) throws CoreException {
	fBaseCURewrite= new CompilationUnitRewrite(type.getCompilationUnit());
	SimpleName name= (SimpleName) NodeFinder.perform(fBaseCURewrite.getRoot(), type.getNameRange());
	TypeDeclaration typeNode= (TypeDeclaration) ASTNodes.getParent(name, ASTNode.TYPE_DECLARATION);
	ASTRewrite rewrite= fBaseCURewrite.getASTRewrite();
	int modifier= Modifier.PRIVATE;
	TextEditGroup removeFieldGroup= fBaseCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractClassRefactoring_group_remove_field);
	FieldDeclaration lastField= null;
	initializeDeclaration(typeNode);
	for (Iterator<FieldInfo> iter= fVariables.values().iterator(); iter.hasNext();) {
		FieldInfo pi= iter.next();
		if (isCreateField(pi)) {
			VariableDeclarationFragment vdf= pi.declaration;
			FieldDeclaration parent= (FieldDeclaration) vdf.getParent();
			if (lastField == null)
				lastField= parent;
			else if (lastField.getStartPosition() < parent.getStartPosition())
				lastField= parent;

			ListRewrite listRewrite= rewrite.getListRewrite(parent, FieldDeclaration.FRAGMENTS_PROPERTY);
			removeNode(vdf, removeFieldGroup, fBaseCURewrite);
			if (listRewrite.getRewrittenList().size() == 0) {
				removeNode(parent, removeFieldGroup, fBaseCURewrite);
			}

			if (fDescriptor.isCreateTopLevel()) {
				IVariableBinding binding= vdf.resolveBinding();
				ITypeRoot typeRoot= fBaseCURewrite.getCu();
				if (binding == null || binding.getType() == null){
					status.addFatalError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_fatal_error_cannot_resolve_binding, BasicElementLabels.getJavaElementName(pi.name)), JavaStatusContext.create(typeRoot, vdf));
				} else {
					ITypeBinding typeBinding= binding.getType();
					if (Modifier.isPrivate(typeBinding.getModifiers())){
						status.addError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_error_referencing_private_class, BasicElementLabels.getJavaElementName(typeBinding.getName())), JavaStatusContext.create(typeRoot, vdf));
					} else if (Modifier.isProtected(typeBinding.getModifiers())){
						ITypeBinding declaringClass= typeBinding.getDeclaringClass();
						if (declaringClass != null) {
							IPackageBinding package1= declaringClass.getPackage();
							if (package1 != null && !fDescriptor.getPackage().equals(package1.getName())){
								status.addError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_error_referencing_protected_class, new String[] {BasicElementLabels.getJavaElementName(typeBinding.getName()), BasicElementLabels.getJavaElementName(fDescriptor.getPackage())}), JavaStatusContext.create(typeRoot, vdf));
							}
						}
					}
				}
			}
			Expression initializer= vdf.getInitializer();
			if (initializer != null)
				pi.initializer= initializer;
			int modifiers= parent.getModifiers();
			if (!MemberVisibilityAdjustor.hasLowerVisibility(modifiers, modifier)){
				modifier= modifiers;
			}
		}
	}
	FieldDeclaration fieldDeclaration= createParameterObjectField(pof, typeNode, modifier);
	ListRewrite bodyDeclList= rewrite.getListRewrite(typeNode, TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
	if (lastField != null)
		bodyDeclList.insertAfter(fieldDeclaration, lastField, null);
	else
		bodyDeclList.insertFirst(fieldDeclaration, null);
	return fieldDeclaration;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:63,代码来源:ExtractClassRefactoring.java

示例10: performFieldRewrite

import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
private FieldDeclaration performFieldRewrite(IType type, ParameterObjectFactory pof, RefactoringStatus status) throws CoreException {
	fBaseCURewrite= new CompilationUnitRewrite(type.getCompilationUnit());
	SimpleName name= (SimpleName) NodeFinder.perform(fBaseCURewrite.getRoot(), type.getNameRange());
	TypeDeclaration typeNode= (TypeDeclaration) ASTNodes.getParent(name, ASTNode.TYPE_DECLARATION);
	ASTRewrite rewrite= fBaseCURewrite.getASTRewrite();
	int modifier= Modifier.PRIVATE;
	TextEditGroup removeFieldGroup= fBaseCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractClassRefactoring_group_remove_field);
	FieldDeclaration lastField= null;
	initializeDeclaration(typeNode);
	for (Iterator<FieldInfo> iter= fVariables.values().iterator(); iter.hasNext();) {
		FieldInfo pi= iter.next();
		if (isCreateField(pi)) {
			VariableDeclarationFragment vdf= pi.declaration;
			FieldDeclaration parent= (FieldDeclaration) vdf.getParent();
			if (lastField == null)
				lastField= parent;
			else if (lastField.getStartPosition() < parent.getStartPosition())
				lastField= parent;

			ListRewrite listRewrite= rewrite.getListRewrite(parent, FieldDeclaration.FRAGMENTS_PROPERTY);
			removeNode(vdf, removeFieldGroup, fBaseCURewrite);
			if (listRewrite.getRewrittenList().size() == 0) {
				removeNode(parent, removeFieldGroup, fBaseCURewrite);
			}

			if (fDescriptor.isCreateTopLevel()) {
				IVariableBinding binding= vdf.resolveBinding();
				ITypeRoot typeRoot= fBaseCURewrite.getCu();
				if (binding == null || binding.getType() == null){
					status.addFatalError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_fatal_error_cannot_resolve_binding, BasicElementLabels.getJavaElementName(pi.name)), JavaStatusContext.create(typeRoot, vdf));
				} else {
					ITypeBinding typeBinding= binding.getType();
					if (Modifier.isPrivate(typeBinding.getDeclaredModifiers())){
						status.addError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_error_referencing_private_class, BasicElementLabels.getJavaElementName(typeBinding.getName())), JavaStatusContext.create(typeRoot, vdf));
					} else if (Modifier.isProtected(typeBinding.getDeclaredModifiers())){
						ITypeBinding declaringClass= typeBinding.getDeclaringClass();
						if (declaringClass != null) {
							IPackageBinding package1= declaringClass.getPackage();
							if (package1 != null && !fDescriptor.getPackage().equals(package1.getName())){
								status.addError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_error_referencing_protected_class, new String[] {BasicElementLabels.getJavaElementName(typeBinding.getName()), BasicElementLabels.getJavaElementName(fDescriptor.getPackage())}), JavaStatusContext.create(typeRoot, vdf));
							}
						}
					}
				}
			}
			Expression initializer= vdf.getInitializer();
			if (initializer != null)
				pi.initializer= initializer;
			int modifiers= parent.getModifiers();
			if (!MemberVisibilityAdjustor.hasLowerVisibility(modifiers, modifier)){
				modifier= modifiers;
			}
		}
	}
	FieldDeclaration fieldDeclaration= createParameterObjectField(pof, typeNode, modifier);
	ListRewrite bodyDeclList= rewrite.getListRewrite(typeNode, TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
	if (lastField != null)
		bodyDeclList.insertAfter(fieldDeclaration, lastField, null);
	else
		bodyDeclList.insertFirst(fieldDeclaration, null);
	return fieldDeclaration;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:63,代码来源:ExtractClassRefactoring.java


注:本文中的org.eclipse.jdt.core.dom.FieldDeclaration.getModifiers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。