當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。