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


Java Modifier.isStatic方法代碼示例

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


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

示例1: visit

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public boolean visit(FieldDeclaration node) {
	List fragments = node.fragments();
	for(Object o : fragments) {
		VariableDeclarationFragment frag = (VariableDeclarationFragment) o;
		String varName = frag.getName().getIdentifier();
		int line = cunit.getLineNumber(frag.getStartPosition());
		ASTNode parent = node.getParent();
		Scope scope = new Scope(cunit.getLineNumber(parent.getStartPosition()), getEndLine(parent, cunit));
		TypeDeclaration dec = (TypeDeclaration) node.getParent();
		String qName = dec.getName().getFullyQualifiedName();
		PackageDeclaration packageDec = cunit.getPackage();
		if(packageDec != null)
			qName = packageDec.getName().getFullyQualifiedName() + "." + qName;
		String type = !Modifier.isStatic(node.getModifiers()) ? qName : null; 
		VariableTags tags = new VariableTags(varName, type, line, scope, true);
		variables.add(tags);
	}
	return false;
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:21,代碼來源:TagParser.java

示例2: visit

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public boolean visit(TypeDeclaration node) {
	System.out.println(node.getParent().getClass());
	if(info == null)
		info = new ClassInfo(node.resolveBinding().getQualifiedName(), VisibilityInfo.from(node));
	
	
	for(FieldDeclaration f : node.getFields()) {
		if(!Modifier.isStatic(f.getModifiers())) {
			for(Object o : f.fragments()) {
				VariableDeclarationFragment frag = (VariableDeclarationFragment) o;
				info.addField(new FieldInfo(frag.getName().toString()));
			}
		}

	}

	return true;
}
 
開發者ID:andre-santos-pt,項目名稱:pandionj,代碼行數:20,代碼來源:Visitor.java

示例3: isMethodCompatible

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public static boolean isMethodCompatible(IMethodBinding methodBinding) {

	Options options = Options.getInstance();
	if (!options.includeConstructors()
			&& (methodBinding.isConstructor() || methodBinding
					.isDefaultConstructor())) {
		return false;
	}
	if (!options.includeStaticMethods()
			&& Modifier.isStatic(methodBinding.getModifiers())) {
		return false;
	}

	return true;

}
 
開發者ID:aroog,項目名稱:code,代碼行數:17,代碼來源:Utils.java

示例4: ensureAttributeForFragment

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
/**
 * We pass both the fragment and the field because we need the field type when the binding cannot be resolved
 */
public Attribute ensureAttributeForFragment(VariableDeclarationFragment fragment, FieldDeclaration field) {
	IVariableBinding binding = fragment.resolveBinding();
	Attribute attribute;
	if (binding == null)
		attribute = ensureAttributeFromFragmentIntoParentType(fragment, field, this.topFromContainerStack(Type.class));
	else {
		attribute = ensureAttributeForVariableBinding(binding);
		extractBasicModifiersFromBinding(binding.getModifiers(), attribute);
		if (Modifier.isStatic(binding.getModifiers()))
			attribute.setHasClassScope(true);
	}
	attribute.setIsStub(true);
	return attribute;
}
 
開發者ID:feenkcom,項目名稱:jdt2famix,代碼行數:18,代碼來源:InJavaImporter.java

示例5: endVisit

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public void endVisit(MethodDeclaration node) {
  int modifiers = node.getModifiers();
  if (Modifier.isNative(modifiers)) {
    String nativeCode = extractNativeCode(node);
    if (nativeCode != null) {
      Block body = new Block();
      body.getStatements().add(new NativeStatement(nativeCode));
      node.setBody(body);
      node.removeModifiers(Modifier.NATIVE);
    }
  }
  if (Modifier.isSynchronized(modifiers)) {
    ITypeBinding declaringClass = node.getMethodBinding().getDeclaringClass();
    SynchronizedStatement syncStmt = new SynchronizedStatement(
        Modifier.isStatic(modifiers) ? new TypeLiteral(declaringClass)
        : new ThisExpression(declaringClass));
    syncStmt.setBody(TreeUtil.remove(node.getBody()));
    Block newBody = new Block();
    newBody.getStatements().add(syncStmt);
    node.setBody(newBody);
    node.removeModifiers(Modifier.SYNCHRONIZED);
  }
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:25,代碼來源:OcniExtractor.java

示例6: getReceiver

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private String getReceiver(
    CallContext context, int modifiers, ImportRewriteContext importRewriteContext) {
  String receiver = context.receiver;
  ITypeBinding invocationType = ASTNodes.getEnclosingType(context.invocation);
  ITypeBinding sourceType = fDeclaration.resolveBinding().getDeclaringClass();
  if (!context.receiverIsStatic && Modifier.isStatic(modifiers)) {
    if ("this".equals(receiver)
        && invocationType != null
        && Bindings.equals(invocationType, sourceType)) { // $NON-NLS-1$
      receiver = null;
    } else {
      receiver = context.importer.addImport(sourceType, importRewriteContext);
    }
  }
  return receiver;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:17,代碼來源:SourceProvider.java

示例7: addFieldEdges

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private void addFieldEdges() {
  for (ITypeBinding type : allTypes.values()) {
    for (IVariableBinding field : type.getDeclaredFields()) {
      ITypeBinding fieldType = getElementType(field.getType());
      if (!whitelist.containsField(field)
          && !whitelist.containsType(fieldType)
          && !fieldType.isPrimitive()
          && !Modifier.isStatic(field.getModifiers())
          // Exclude self-referential fields. (likely linked DS or delegate pattern)
          && !type.isAssignmentCompatible(fieldType)
          && !BindingUtil.isWeakReference(field)) {
        addEdge(Edge.newFieldEdge(type, field));
      }
    }
  }
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:17,代碼來源:ReferenceGraph.java

示例8: 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

示例9: setUpMethodFromMethodBinding

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private void setUpMethodFromMethodBinding(Method method, IMethodBinding binding) {
	if (binding.isConstructor()) 
		method.setKind(CONSTRUCTOR_KIND);
	ITypeBinding returnType = binding.getReturnType();
	if ((returnType != null) && !(returnType.isPrimitive() && returnType.getName().equals("void")))
		//we do not want to set void as a return type
		method.setDeclaredType(ensureTypeFromTypeBinding(returnType));
	extractBasicModifiersFromBinding(binding.getModifiers(), method);
	if (Modifier.isStatic(binding.getModifiers()))
		method.setHasClassScope(true);
	try {
		IAnnotationBinding[] annotations = binding.getAnnotations();
		createAnnotationInstancesToEntityFromAnnotationBinding(method, annotations);
	} catch(NullPointerException e) {
		/* This happens in some very strange circumstances, likely due to missing dependencies.
		 * The only solution I found was to catch the exception and log it and provide people
		 * with a way to solve it by adding the missing dependencies to the import.
		 */
		logNullBinding("annotation instances for method binding", Famix.qualifiedNameOf(method) , -1);
	}
}
 
開發者ID:feenkcom,項目名稱:jdt2famix,代碼行數:22,代碼來源:InJavaImporter.java

示例10: isStaticFieldOrStaticInitializer

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static boolean isStaticFieldOrStaticInitializer(BodyDeclaration node) {
  if (node instanceof MethodDeclaration || node instanceof AbstractTypeDeclaration) return false;

  int modifiers;
  if (node instanceof FieldDeclaration) {
    modifiers = ((FieldDeclaration) node).getModifiers();
  } else if (node instanceof Initializer) {
    modifiers = ((Initializer) node).getModifiers();
  } else {
    Assert.isTrue(false);
    return false;
  }

  if (!Modifier.isStatic(modifiers)) return false;

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

示例11: getOverridableMethods

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static void getOverridableMethods(
    AST ast, ITypeBinding superBinding, List<IMethodBinding> allMethods) {
  IMethodBinding[] methods = superBinding.getDeclaredMethods();
  for (int offset = 0; offset < methods.length; offset++) {
    final int modifiers = methods[offset].getModifiers();
    if (!methods[offset].isConstructor()
        && !Modifier.isStatic(modifiers)
        && !Modifier.isPrivate(modifiers)) {
      if (findOverridingMethod(methods[offset], allMethods) == null
          && !Modifier.isStatic(modifiers)) allMethods.add(methods[offset]);
    }
  }
  ITypeBinding[] superInterfaces = superBinding.getInterfaces();
  for (int index = 0; index < superInterfaces.length; index++) {
    getOverridableMethods(ast, superInterfaces[index], allMethods);
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:18,代碼來源:StubUtility2.java

示例12: 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

示例13: 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

示例14: getOverridableMethods

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static void getOverridableMethods(AST ast, ITypeBinding superBinding, List<IMethodBinding> allMethods) {
	IMethodBinding[] methods= superBinding.getDeclaredMethods();
	for (int offset= 0; offset < methods.length; offset++) {
		final int modifiers= methods[offset].getModifiers();
		if (!methods[offset].isConstructor() && !Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers)) {
			if (findOverridingMethod(methods[offset], allMethods) == null) {
				allMethods.add(methods[offset]);
			}
		}
	}
	ITypeBinding[] superInterfaces= superBinding.getInterfaces();
	for (int index= 0; index < superInterfaces.length; index++) {
		getOverridableMethods(ast, superInterfaces[index], allMethods);
	}
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:16,代碼來源:StubUtility2.java

示例15: 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


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