本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例9: createModifiersForNestedClass
private int createModifiersForNestedClass() {
int flags = fVisibility;
if (fDeclareFinal) flags |= Modifier.FINAL;
if (mustInnerClassBeStatic() || fDeclareStatic) flags |= Modifier.STATIC;
return flags;
}
示例10: getModifiers
private int getModifiers() {
int flags = fVisibility;
if (fDeclareFinal) flags |= Modifier.FINAL;
if (fDeclareStatic) flags |= Modifier.STATIC;
return flags;
}