當前位置: 首頁>>代碼示例>>Java>>正文


Java Modifier.isFinal方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.dom.Modifier.isFinal方法的典型用法代碼示例。如果您正苦於以下問題:Java Modifier.isFinal方法的具體用法?Java Modifier.isFinal怎麽用?Java Modifier.isFinal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.dom.Modifier的用法示例。


在下文中一共展示了Modifier.isFinal方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ensureParameterFromSingleVariableDeclaration

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public Parameter ensureParameterFromSingleVariableDeclaration(SingleVariableDeclaration variableDeclaration,
		Method method) {
	String name = variableDeclaration.getName().toString();
	String qualifiedName = Famix.qualifiedNameOf(method) + NAME_SEPARATOR + name;
	if (parameters.has(qualifiedName)) 
		return parameters.named(qualifiedName);
	Parameter parameter = new Parameter();
	parameters.add(qualifiedName, parameter);
	parameter.setName(name);
	parameter.setParentBehaviouralEntity(method);
	parameter.setDeclaredType(ensureTypeFromDomType(variableDeclaration.getType()));
	IVariableBinding binding = variableDeclaration.resolveBinding();
	if (binding != null) {
		createAnnotationInstancesToEntityFromAnnotationBinding(parameter, binding.getAnnotations());
		//We only recover the final modifier
		if (Modifier.isFinal(binding.getModifiers())) parameter.addModifiers("final");
	}
	return parameter;
}
 
開發者ID:feenkcom,項目名稱:jdt2famix,代碼行數:20,代碼來源:InJavaImporter.java

示例2: canAddFinal

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static boolean canAddFinal(IBinding binding, ASTNode declNode) {
  if (!(binding instanceof IVariableBinding)) return false;

  IVariableBinding varbinding = (IVariableBinding) binding;
  int modifiers = varbinding.getModifiers();
  if (Modifier.isFinal(modifiers)
      || Modifier.isVolatile(modifiers)
      || Modifier.isTransient(modifiers)) return false;

  ASTNode parent = ASTNodes.getParent(declNode, VariableDeclarationExpression.class);
  if (parent != null && ((VariableDeclarationExpression) parent).fragments().size() > 1)
    return false;

  if (varbinding.isField() && !Modifier.isPrivate(modifiers)) return false;

  if (varbinding.isParameter()) {
    ASTNode varDecl = declNode.getParent();
    if (varDecl instanceof MethodDeclaration) {
      MethodDeclaration declaration = (MethodDeclaration) varDecl;
      if (declaration.getBody() == null) return false;
    }
  }

  return true;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:26,代碼來源:VariableDeclarationFix.java

示例3: findConstantNameNode

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private Name findConstantNameNode() {
  ASTNode node =
      NodeFinder.perform(fSelectionCuRewrite.getRoot(), fSelectionStart, fSelectionLength);
  if (node == null) return null;
  if (node instanceof FieldAccess) node = ((FieldAccess) node).getName();
  if (!(node instanceof Name)) return null;
  Name name = (Name) node;
  IBinding binding = name.resolveBinding();
  if (!(binding instanceof IVariableBinding)) return null;
  IVariableBinding variableBinding = (IVariableBinding) binding;
  if (!variableBinding.isField() || variableBinding.isEnumConstant()) return null;
  int modifiers = binding.getModifiers();
  if (!(Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers))) return null;

  return name;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:17,代碼來源:InlineConstantRefactoring.java

示例4: visit

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public boolean visit(SimpleName node) {
  IBinding binding = node.resolveBinding();
  if (binding instanceof IVariableBinding) {
    int accessMode = fFormalArgument.getSimplifiedAccessMode();
    if (fFormalArgument.isFinal() && !Modifier.isFinal(binding.getModifiers())) {
      return setResult(false);
    }
    if (accessMode == FlowInfo.READ || accessMode == FlowInfo.UNUSED) return setResult(true);
    // from now on we only have write accesses.
    IVariableBinding vb = (IVariableBinding) binding;
    if (vb.isField()) return setResult(false);
    return setResult(
        fFlowInfo.hasAccessMode(fFlowContext, vb, FlowInfo.UNUSED | FlowInfo.WRITE));
  }
  return setResult(false);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:18,代碼來源:CallInliner.java

示例5: addAddSafeVarargsProposals

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public static void addAddSafeVarargsProposals(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
  ASTNode coveringNode = problem.getCoveringNode(context.getASTRoot());

  MethodDeclaration methodDeclaration = ASTResolving.findParentMethodDeclaration(coveringNode);
  if (methodDeclaration == null) return;

  IMethodBinding methodBinding = methodDeclaration.resolveBinding();
  if (methodBinding == null) return;

  int modifiers = methodBinding.getModifiers();
  if (!Modifier.isStatic(modifiers)
      && !Modifier.isFinal(modifiers)
      && !methodBinding.isConstructor()) return;

  String label = CorrectionMessages.VarargsWarningsSubProcessor_add_safevarargs_label;
  AddSafeVarargsProposal proposal =
      new AddSafeVarargsProposal(
          label,
          context.getCompilationUnit(),
          methodDeclaration,
          null,
          IProposalRelevance.ADD_SAFEVARARGS);
  proposals.add(proposal);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:26,代碼來源:VarargsWarningsSubProcessor.java

示例6: getAdornmentFlags

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static int getAdornmentFlags(IBinding binding) {
  int adornments = 0;
  final int modifiers = binding.getModifiers();
  if (Modifier.isAbstract(modifiers)) adornments |= JavaElementImageDescriptor.ABSTRACT;
  if (Modifier.isFinal(modifiers)) adornments |= JavaElementImageDescriptor.FINAL;
  if (Modifier.isStatic(modifiers)) adornments |= JavaElementImageDescriptor.STATIC;

  if (binding.isDeprecated()) adornments |= JavaElementImageDescriptor.DEPRECATED;

  if (binding instanceof IMethodBinding) {
    if (((IMethodBinding) binding).isConstructor())
      adornments |= JavaElementImageDescriptor.CONSTRUCTOR;
    if (Modifier.isSynchronized(modifiers)) adornments |= JavaElementImageDescriptor.SYNCHRONIZED;
    if (Modifier.isNative(modifiers)) adornments |= JavaElementImageDescriptor.NATIVE;
    ITypeBinding type = ((IMethodBinding) binding).getDeclaringClass();
    if (type.isInterface() && !Modifier.isAbstract(modifiers) && !Modifier.isStatic(modifiers))
      adornments |= JavaElementImageDescriptor.DEFAULT_METHOD;
    if (((IMethodBinding) binding).getDefaultValue() != null)
      adornments |= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
  }
  if (binding instanceof IVariableBinding && ((IVariableBinding) binding).isField()) {
    if (Modifier.isTransient(modifiers)) adornments |= JavaElementImageDescriptor.TRANSIENT;
    if (Modifier.isVolatile(modifiers)) adornments |= JavaElementImageDescriptor.VOLATILE;
  }
  return adornments;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:27,代碼來源:BindingLabelProvider.java

示例7: checkModifiers

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public static void checkModifiers(ProblemCollector collector, BodyDeclaration elem,
		Predicate<Modifier> allowSpecific) {
	for (Object obj : elem.modifiers()) {
		if (!(obj instanceof Modifier)) {
			continue;
		}
		Modifier modifier = (Modifier) obj;
		boolean valid;
		if (allowSpecific.test(modifier)) {
			valid = true;
		} else {
			valid = modifier.isPrivate() || modifier.isPublic() || modifier.isProtected() || modifier.isFinal();
		}
		if (!valid) {
			collector.report(new InvalidModifier(collector.getSourceInfo(), modifier));
		}
	}
}
 
開發者ID:ELTE-Soft,項目名稱:txtUML,代碼行數:19,代碼來源:Utils.java

示例8: getOrderPreference

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static int getOrderPreference(BodyDeclaration member, MemberSortOrder sortOrder) {
	int memberType= member.getNodeType();
	int modifiers= member.getModifiers();

	switch (memberType) {
	case ASTNode.TYPE_DECLARATION:
	case ASTNode.ENUM_DECLARATION :
	case ASTNode.ANNOTATION_TYPE_DECLARATION :
		return sortOrder.getCategoryIndex(MemberSortOrder.TYPE_INDEX) * 2;
	case ASTNode.FIELD_DECLARATION:
		if (Modifier.isStatic(modifiers)) {
			int index = sortOrder.getCategoryIndex(MemberSortOrder.STATIC_FIELDS_INDEX) * 2;
			if (Modifier.isFinal(modifiers)) {
				return index; // first final static, then static
			}
			return index + 1;
		}
		return sortOrder.getCategoryIndex(MemberSortOrder.FIELDS_INDEX) * 2;
	case ASTNode.INITIALIZER:
		if (Modifier.isStatic(modifiers)) {
			return sortOrder.getCategoryIndex(MemberSortOrder.STATIC_INIT_INDEX) * 2;
		}
		return sortOrder.getCategoryIndex(MemberSortOrder.INIT_INDEX) * 2;
	case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
		return sortOrder.getCategoryIndex(MemberSortOrder.METHOD_INDEX) * 2;
	case ASTNode.METHOD_DECLARATION:
		if (Modifier.isStatic(modifiers)) {
			return sortOrder.getCategoryIndex(MemberSortOrder.STATIC_METHODS_INDEX) * 2;
		}
		if (((MethodDeclaration) member).isConstructor()) {
			return sortOrder.getCategoryIndex(MemberSortOrder.CONSTRUCTORS_INDEX) * 2;
		}
		return sortOrder.getCategoryIndex(MemberSortOrder.METHOD_INDEX) * 2;
	default:
		return 100;
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:38,代碼來源:BodyDeclarationRewrite.java

示例9: getFieldKind

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static int getFieldKind(int modifiers) {
	if (!Modifier.isStatic(modifiers)) {
		return NamingConventions.VK_INSTANCE_FIELD;
	}

	if (!Modifier.isFinal(modifiers)) {
		return NamingConventions.VK_STATIC_FIELD;
	}

	return NamingConventions.VK_STATIC_FINAL_FIELD;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:12,代碼來源:StubUtility.java

示例10: noAnnotateVisitor

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public void noAnnotateVisitor(ITypeBinding objType) {
	if (objType != null) {
		if (utils.isContainerOfGeneralType(objType.getQualifiedName())) {
			numContainerOfInterfaces++;
		}
		else if (utils.isContainerType(objType.getQualifiedName())) {
			numContainerOfType++;
		}
		else if (utils.isFieldOfAtLeastOneGeneralType(objType.getQualifiedName())) {
			numFieldOfGeneralTypes++;
		}
		else if (utils.isFrameworkType(objType.getQualifiedName())) {
			numofAppFrameworkTypes++;
		}
		else if (utils.isapplicationType(objType.getQualifiedName())) {
			numofAppTypes++;
		}
		else if (utils.isJavaTypes(objType.getQualifiedName())) {
			numofFrameworkTypes++;
		}
		else if (Modifier.isFinal(objType.getModifiers())) {
			numFieldOfFinal++;
		}
		else if (utils.isdataType(objType.getQualifiedName())) {
			numDataType++;
		}
		else if (utils.isexceptionType(objType.getQualifiedName())) {
			numExceptionType++;
		}
		else {
			unknown++;
		}
	}
}
 
開發者ID:aroog,項目名稱:code,代碼行數:36,代碼來源:ClassifyUtlis.java

示例11: printModifiers

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private void printModifiers(int modifiers) {
  if (Modifier.isPublic(modifiers)) {
    sb.print("public ");
  }
  if (Modifier.isProtected(modifiers)) {
    sb.print("protected ");
  }
  if (Modifier.isPrivate(modifiers)) {
    sb.print("private ");
  }
  if (Modifier.isStatic(modifiers)) {
    sb.print("static ");
  }
  if (Modifier.isAbstract(modifiers)) {
    sb.print("abstract ");
  }
  if (Modifier.isFinal(modifiers)) {
    sb.print("final ");
  }
  if (Modifier.isSynchronized(modifiers)) {
    sb.print("synchronized ");
  }
  if (Modifier.isVolatile(modifiers)) {
    sb.print("volatile ");
  }
  if (Modifier.isNative(modifiers)) {
    sb.print("native ");
  }
  if (Modifier.isStrictfp(modifiers)) {
    sb.print("strictfp ");
  }
  if (Modifier.isTransient(modifiers)) {
    sb.print("transient ");
  }
  if ((modifiers & BindingUtil.ACC_SYNTHETIC) > 0) {
    sb.print("synthetic ");
  }
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:39,代碼來源:DebugASTPrinter.java

示例12: printStaticFieldFullDeclaration

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private void printStaticFieldFullDeclaration(VariableDeclarationFragment fragment) {
  IVariableBinding var = fragment.getVariableBinding();

  if (BindingUtil.extractMappingName(var.getDeclaringClass()) != null) {
    // mapped class doesn't have usual java static field
    return;
  }

  ITypeBinding binding = var.getType();
  String objcType = NameTable.getObjCType(binding);
  String typeWithSpace = objcType + (objcType.endsWith("*") ? "" : " ");
  String name = NameTable.getStaticVarName(var);
  boolean isFinal = Modifier.isFinal(var.getModifiers());
  boolean isPrimitive = binding.isPrimitive();
  newline();
  if (BindingUtil.isPrimitiveConstant(var)) {
    name = var.getName();
  } else {
    printStaticFieldDeclaration(
        fragment, String.format("%s%s_%s", typeWithSpace, typeName, name));
  }
  printf("J2OBJC_STATIC_FIELD_GETTER(%s, %s, %s)\n", typeName, name, objcType);
  if (!isFinal) {
    if (isPrimitive || BindingUtil.isValueType(binding) || binding instanceof IOSBlockTypeBinding) {
      printf("J2OBJC_STATIC_FIELD_REF_GETTER(%s, %s, %s)\n", typeName, name, objcType);
    } else {
      printf("J2OBJC_STATIC_FIELD_SETTER(%s, %s, %s)\n", typeName, name, objcType);
    }
  }
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:31,代碼來源:TypeDeclarationGenerator.java

示例13: isInlinableConstant

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private boolean isInlinableConstant(BodyDeclaration decl) {
  if (!(decl instanceof FieldDeclaration)) {
    return false;
  }
  int modifiers = decl.getModifiers();
  if (!Modifier.isStatic(modifiers) || !Modifier.isFinal(modifiers)
      || Modifier.isPrivate(modifiers)) {
    return false;
  }
  ITypeBinding type = ((FieldDeclaration) decl).getType().getTypeBinding();
  return type.isPrimitive() || Types.isStringType(type);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:13,代碼來源:DeadCodeEliminator.java

示例14: handleVariable

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private void handleVariable(SimpleName node, IVariableBinding varbinding) {
  if (!varbinding.isField()) return;

  if (varbinding.isEnumConstant()) return;

  ITypeBinding declaringClass = varbinding.getDeclaringClass();
  if (Modifier.isStatic(varbinding.getModifiers())) {
    if (fFindUnqualifiedStaticAccesses) {
      Initializer initializer = (Initializer) ASTNodes.getParent(node, Initializer.class);
      // Do not qualify assignments to static final fields in static initializers (would result
      // in compile error)
      StructuralPropertyDescriptor parentDescription = node.getLocationInParent();
      if (initializer != null
          && Modifier.isStatic(initializer.getModifiers())
          && Modifier.isFinal(varbinding.getModifiers())
          && parentDescription == Assignment.LEFT_HAND_SIDE_PROPERTY) return;

      // Do not qualify static fields if defined inside an anonymous class
      if (declaringClass.isAnonymous()) return;

      fResult.add(new AddStaticQualifierOperation(declaringClass, node));
    }
  } else if (fFindUnqualifiedAccesses) {
    String qualifier = getThisExpressionQualifier(declaringClass, fImportRewrite, node);
    if (qualifier == null) return;

    if (qualifier.length() == 0) qualifier = null;

    fResult.add(new AddThisQualifierOperation(qualifier, node));
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:32,代碼來源:CodeStyleFix.java

示例15: isBindingToTemp

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private boolean isBindingToTemp(IVariableBinding variable) {
  if (variable.isField()) return false;
  if (!Modifier.isFinal(variable.getModifiers())) return false;
  ASTNode declaringNode = fCompilationUnitNode.findDeclaringNode(variable);
  if (declaringNode == null) return false;
  if (ASTNodes.isParent(declaringNode, fAnonymousInnerClassNode)) return false;
  return true;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:9,代碼來源:ConvertAnonymousToNestedRefactoring.java


注:本文中的org.eclipse.jdt.core.dom.Modifier.isFinal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。