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


Java Modifier.isPrivate方法代碼示例

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


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

示例1: visit

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public boolean visit(FieldDeclaration node) {

	int modifiers = node.getModifiers();
	if (Modifier.isPrivate(modifiers) || Modifier.isProtected(modifiers)) {
		List<VariableDeclarationFragment> fragments = node.fragments();
		for (VariableDeclarationFragment varDeclFrag : fragments) {
			IVariableBinding varBinding = varDeclFrag.resolveBinding();
			String enclosingClass = varBinding.getDeclaringClass().getQualifiedName();
			if(!varBinding.getType().isPrimitive() && !varBinding.getType().getQualifiedName().equals("java.lang.String")){
				final TACVariable fieldVar = new TACVariable(varBinding);
				if(!enclosingClass.equals(Config.MAINCLASS)){
					context.addEncapsulatedVariable(fieldVar);
				}
			}
		}
	}
	return super.visit(node);
}
 
開發者ID:aroog,項目名稱:code,代碼行數:20,代碼來源:HeuristicOwnedVisitor.java

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

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

示例4: getBaseImageDescriptor

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static ImageDescriptor getBaseImageDescriptor(IBinding binding, int flags) {
  if (binding instanceof ITypeBinding) {
    ITypeBinding typeBinding = (ITypeBinding) binding;
    if (typeBinding.isArray()) {
      typeBinding = typeBinding.getElementType();
    }
    if (typeBinding.isCapture()) {
      typeBinding.getWildcard();
    }
    return getTypeImageDescriptor(typeBinding.getDeclaringClass() != null, typeBinding, flags);
  } else if (binding instanceof IMethodBinding) {
    ITypeBinding type = ((IMethodBinding) binding).getDeclaringClass();
    int modifiers = binding.getModifiers();
    if (type.isEnum()
        && (!Modifier.isPublic(modifiers)
            && !Modifier.isProtected(modifiers)
            && !Modifier.isPrivate(modifiers))
        && ((IMethodBinding) binding).isConstructor()) return JavaPluginImages.DESC_MISC_PRIVATE;
    return getMethodImageDescriptor(binding.getModifiers());
  } else if (binding instanceof IVariableBinding)
    return getFieldImageDescriptor((IVariableBinding) binding);
  return JavaPluginImages.DESC_OBJS_UNKNOWN;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:24,代碼來源:BindingLabelProvider.java

示例5: getVisibility

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static String getVisibility(TypeDeclaration decl) {
    int modifiers = decl.getModifiers();
    if (Modifier.isPrivate(modifiers))
        return "private";
    if (Modifier.isProtected(modifiers))
        return "protected";
    if (Modifier.isPublic(modifiers))
        return "public";
    return "package";
}
 
開發者ID:linzeqipku,項目名稱:SnowGraph,代碼行數:11,代碼來源:JavaASTVisitor.java

示例6: isVisibleInHierarchy

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public static boolean isVisibleInHierarchy(IMethodBinding member, IPackageBinding pack) {
	int otherflags= member.getModifiers();
	ITypeBinding declaringType= member.getDeclaringClass();
	if (Modifier.isPublic(otherflags) || Modifier.isProtected(otherflags) || (declaringType != null && declaringType.isInterface())) {
		return true;
	} else if (Modifier.isPrivate(otherflags)) {
		return false;
	}
	return declaringType != null && pack == declaringType.getPackage();
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:11,代碼來源:Bindings.java

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

示例8: needsImport

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private boolean needsImport(ITypeBinding typeBinding, SimpleName ref) {
	if (!typeBinding.isTopLevel() && !typeBinding.isMember() || typeBinding.isRecovered()) {
		return false; // no imports for anonymous, local, primitive types or parameters types
	}
	int modifiers= typeBinding.getModifiers();
	if (Modifier.isPrivate(modifiers)) {
		return false; // imports for privates are not required
	}
	ITypeBinding currTypeBinding= Bindings.getBindingOfParentType(ref);
	if (currTypeBinding == null) {
		if (ASTNodes.getParent(ref, ASTNode.PACKAGE_DECLARATION) != null) {
			return true; // reference in package-info.java
		}
		return false; // not in a type
	}
	if (!Modifier.isPublic(modifiers)) {
		if (!currTypeBinding.getPackage().getName().equals(typeBinding.getPackage().getName())) {
			return false; // not visible
		}
	}

	ASTNode parent= ref.getParent();
	while (parent instanceof Type) {
		parent= parent.getParent();
	}
	if (parent instanceof AbstractTypeDeclaration && parent.getParent() instanceof CompilationUnit) {
		return true;
	}

	if (typeBinding.isMember()) {
		if (fAnalyzer.isDeclaredInScope(typeBinding, ref, ScopeAnalyzer.TYPES | ScopeAnalyzer.CHECK_VISIBILITY)) {
			return false;
		}
	}
	return true;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:37,代碼來源:OrganizeImportsOperation.java

示例9: getInnerInterfaceImageDescriptor

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static ImageDescriptor getInnerInterfaceImageDescriptor(int modifiers) {
  if (Modifier.isPublic(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_INTERFACE_PUBLIC;
  else if (Modifier.isPrivate(modifiers))
    return JavaPluginImages.DESC_OBJS_INNER_INTERFACE_PRIVATE;
  else if (Modifier.isProtected(modifiers))
    return JavaPluginImages.DESC_OBJS_INNER_INTERFACE_PROTECTED;
  else return JavaPluginImages.DESC_OBJS_INTERFACE_DEFAULT;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:9,代碼來源:BindingLabelProvider.java

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

示例11: getInnerClassImageDescriptor

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static ImageDescriptor getInnerClassImageDescriptor(int modifiers) {
  if (Modifier.isPublic(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_CLASS_PUBLIC;
  else if (Modifier.isPrivate(modifiers)) return JavaPluginImages.DESC_OBJS_INNER_CLASS_PRIVATE;
  else if (Modifier.isProtected(modifiers))
    return JavaPluginImages.DESC_OBJS_INNER_CLASS_PROTECTED;
  else return JavaPluginImages.DESC_OBJS_INNER_CLASS_DEFAULT;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:8,代碼來源:BindingLabelProvider.java

示例12: needsImport

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private boolean needsImport(ITypeBinding typeBinding, SimpleName ref) {
  if (!typeBinding.isTopLevel() && !typeBinding.isMember() || typeBinding.isRecovered()) {
    return false; // no imports for anonymous, local, primitive types or parameters types
  }
  int modifiers = typeBinding.getModifiers();
  if (Modifier.isPrivate(modifiers)) {
    return false; // imports for privates are not required
  }
  ITypeBinding currTypeBinding = Bindings.getBindingOfParentType(ref);
  if (currTypeBinding == null) {
    if (ASTNodes.getParent(ref, ASTNode.PACKAGE_DECLARATION) != null) {
      return true; // reference in package-info.java
    }
    return false; // not in a type
  }
  if (!Modifier.isPublic(modifiers)) {
    if (!currTypeBinding.getPackage().getName().equals(typeBinding.getPackage().getName())) {
      return false; // not visible
    }
  }

  ASTNode parent = ref.getParent();
  while (parent instanceof Type) {
    parent = parent.getParent();
  }
  if (parent instanceof AbstractTypeDeclaration
      && parent.getParent() instanceof CompilationUnit) {
    return true;
  }

  if (typeBinding.isMember()) {
    if (fAnalyzer.isDeclaredInScope(
        typeBinding, ref, ScopeAnalyzer.TYPES | ScopeAnalyzer.CHECK_VISIBILITY)) return false;
  }
  return true;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:37,代碼來源:OrganizeImportsOperation.java

示例13: getFieldImageDescriptor

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static ImageDescriptor getFieldImageDescriptor(IVariableBinding binding) {
  final int modifiers = binding.getModifiers();
  if (Modifier.isPublic(modifiers) || binding.isEnumConstant())
    return JavaPluginImages.DESC_FIELD_PUBLIC;
  if (Modifier.isProtected(modifiers)) return JavaPluginImages.DESC_FIELD_PROTECTED;
  if (Modifier.isPrivate(modifiers)) return JavaPluginImages.DESC_FIELD_PRIVATE;

  return JavaPluginImages.DESC_FIELD_DEFAULT;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:10,代碼來源:BindingLabelProvider.java

示例14: getAccessModifier

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static int getAccessModifier(AbstractTypeDeclaration subclass) {
  int modifiers = subclass.getModifiers();
  if (Modifier.isPublic(modifiers)) return Modifier.PUBLIC;
  else if (Modifier.isProtected(modifiers)) return Modifier.PROTECTED;
  else if (Modifier.isPrivate(modifiers)) return Modifier.PRIVATE;
  else return Modifier.NONE;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:8,代碼來源:ChangeSignatureProcessor.java

示例15: getVisibilityString

import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static String getVisibilityString(int code) {
  if (Modifier.isPublic(code)) {
    return "public"; // $NON-NLS-1$
  } else if (Modifier.isProtected(code)) {
    return "protected"; // $NON-NLS-1$
  } else if (Modifier.isPrivate(code)) {
    return "private"; // $NON-NLS-1$
  }
  return CorrectionMessages.ModifierCorrectionSubProcessor_default;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:11,代碼來源:ModifierCorrectionSubProcessor.java


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