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


Java Modifier.FINAL属性代码示例

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


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

示例1: handleFragments

private boolean handleFragments(List<VariableDeclarationFragment> list, ASTNode declaration) {
  List<VariableDeclarationFragment> toChange = new ArrayList<VariableDeclarationFragment>();

  for (Iterator<VariableDeclarationFragment> iter = list.iterator(); iter.hasNext(); ) {
    VariableDeclarationFragment fragment = iter.next();
    SimpleName name = fragment.getName();
    IBinding resolveBinding = name.resolveBinding();
    if (canAddFinal(resolveBinding, declaration)) {
      IVariableBinding varbinding = (IVariableBinding) resolveBinding;
      if (varbinding.isField()) {
        if (fieldCanBeFinal(fragment, varbinding)) toChange.add(fragment);
      } else {
        if (!fWrittenVariables.containsKey(resolveBinding)) toChange.add(fragment);
      }
    }
  }

  if (toChange.size() == 0) return false;

  ModifierChangeOperation op =
      new ModifierChangeOperation(declaration, toChange, Modifier.FINAL, Modifier.NONE);
  fResult.add(op);
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:VariableDeclarationFix.java

示例2: addParameter

private GeneratedVariableBinding addParameter(
    MethodDeclaration constructor, ITypeBinding paramType, String name, int idx) {
  GeneratedMethodBinding constructorBinding =
      new GeneratedMethodBinding(constructor.getMethodBinding().getMethodDeclaration());
  constructor.setMethodBinding(constructorBinding);
  GeneratedVariableBinding paramBinding = new GeneratedVariableBinding(
      name, Modifier.FINAL, paramType, false, true, constructorBinding.getDeclaringClass(),
      constructorBinding);
  SingleVariableDeclaration paramNode = new SingleVariableDeclaration(paramBinding);
  if (idx == -1) {
    constructor.getParameters().add(paramNode);
    constructorBinding.addParameter(paramType);
  } else {
    constructor.getParameters().add(idx, paramNode);
    constructorBinding.addParameter(idx, paramType);
  }
  return paramBinding;
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:18,代码来源:InnerClassExtractor.java

示例3: testModifier

protected boolean testModifier(IVariableBinding curr) {
	int modifiers= curr.getModifiers();
	int staticFinal= Modifier.STATIC | Modifier.FINAL;
	if ((modifiers & staticFinal) == staticFinal) {
		return false;
	}
	if (Modifier.isStatic(modifiers) && !Modifier.isStatic(getModifiers())) {
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:MissingReturnTypeCorrectionProposal.java

示例4: evaluateFieldModifiers

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;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:38,代码来源:NewVariableCorrectionProposal.java

示例5: createAddFinalOperation

private static ModifierChangeOperation createAddFinalOperation(SimpleName name, ASTNode decl) {
  if (decl == null) return null;

  IBinding binding = name.resolveBinding();
  if (!canAddFinal(binding, decl)) return null;

  if (decl instanceof SingleVariableDeclaration) {
    return new ModifierChangeOperation(
        decl, new ArrayList<VariableDeclarationFragment>(), Modifier.FINAL, Modifier.NONE);
  } else if (decl instanceof VariableDeclarationExpression) {
    return new ModifierChangeOperation(
        decl, new ArrayList<VariableDeclarationFragment>(), Modifier.FINAL, Modifier.NONE);
  } else if (decl instanceof VariableDeclarationFragment) {
    VariableDeclarationFragment frag = (VariableDeclarationFragment) decl;
    decl = decl.getParent();
    if (decl instanceof FieldDeclaration || decl instanceof VariableDeclarationStatement) {
      List<VariableDeclarationFragment> list = new ArrayList<VariableDeclarationFragment>();
      list.add(frag);
      return new ModifierChangeOperation(decl, list, Modifier.FINAL, Modifier.NONE);
    } else if (decl instanceof VariableDeclarationExpression) {
      return new ModifierChangeOperation(
          decl, new ArrayList<VariableDeclarationFragment>(), Modifier.FINAL, Modifier.NONE);
    }
  }

  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:VariableDeclarationFix.java

示例6: testModifier

protected boolean testModifier(IVariableBinding curr) {
  int modifiers = curr.getModifiers();
  int staticFinal = Modifier.STATIC | Modifier.FINAL;
  if ((modifiers & staticFinal) == staticFinal) {
    return false;
  }
  if (Modifier.isStatic(modifiers) && !Modifier.isStatic(getModifiers())) {
    return false;
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:MissingReturnTypeCorrectionProposal.java

示例7: evaluateFieldModifiers

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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:38,代码来源:NewVariableCorrectionProposal.java

示例8: consumes

@Override
public boolean consumes(SemanticToken token) {
  IBinding binding = token.getBinding();
  return binding != null
      && binding.getKind() == IBinding.VARIABLE
      && ((IVariableBinding) binding).isField()
      && (binding.getModifiers() & (Modifier.FINAL | Modifier.STATIC))
          == (Modifier.FINAL | Modifier.STATIC);
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:SemanticHighlightings.java

示例9: createModifiersForNestedClass

private int createModifiersForNestedClass() {
  int flags = fVisibility;
  if (fDeclareFinal) flags |= Modifier.FINAL;
  if (mustInnerClassBeStatic() || fDeclareStatic) flags |= Modifier.STATIC;
  return flags;
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:ConvertAnonymousToNestedRefactoring.java

示例10: getModifiers

private int getModifiers() {
  int flags = fVisibility;
  if (fDeclareFinal) flags |= Modifier.FINAL;
  if (fDeclareStatic) flags |= Modifier.STATIC;
  return flags;
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:PromoteTempToFieldRefactoring.java


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