本文整理汇总了Java中com.intellij.codeInspection.reference.RefClass类的典型用法代码示例。如果您正苦于以下问题:Java RefClass类的具体用法?Java RefClass怎么用?Java RefClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RefClass类属于com.intellij.codeInspection.reference包,在下文中一共展示了RefClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRelatedClasses
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
private static Set<RefClass> getRelatedClasses(RefPackage aPackage,
RefClass classToProcess) {
final Set<RefClass> out = new HashSet<RefClass>();
final Set<RefClass> dependencies =
DependencyUtils.calculateDependenciesForClass(classToProcess);
for (RefClass dependency : dependencies) {
if (packageContainsClass(aPackage, dependency)) {
out.add(dependency);
}
}
final Set<RefClass> dependents =
DependencyUtils.calculateDependentsForClass(classToProcess);
for (RefClass dependent : dependents) {
if (packageContainsClass(aPackage, dependent)) {
out.add(dependent);
}
}
return out;
}
示例2: tabulateInitializationDependencyClasses
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@SuppressWarnings({"MethodWithMultipleLoops"})
static void tabulateInitializationDependencyClasses(
RefElement element, Set<RefClass> dependencies) {
final Collection<RefElement> references = element.getOutReferences();
final RefJavaUtil refUtil = RefJavaUtil.getInstance();
for (RefElement reference : references) {
final RefClass refClass = refUtil.getTopLevelClass(reference);
if (refClass != null) {
dependencies.add(refClass);
}
}
final List<RefEntity> children = element.getChildren();
if (children == null) {
return;
}
for (RefEntity child : children) {
if (child instanceof RefElement) {
tabulateInitializationDependencyClasses((RefElement)child,
dependencies);
}
}
}
示例3: tabulateTransitiveInitializationDependencyClasses
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
private static void tabulateTransitiveInitializationDependencyClasses(
RefClass refClass, Set<RefClass> newDependencies) {
final LinkedList<RefClass> pendingClasses = new LinkedList<RefClass>();
final Set<RefClass> processedClasses = new HashSet<RefClass>();
pendingClasses.addLast(refClass);
while (!pendingClasses.isEmpty()) {
final RefClass classToProcess = pendingClasses.removeFirst();
newDependencies.add(classToProcess);
processedClasses.add(classToProcess);
final Set<RefClass> dependencies =
calculateInitializationDependenciesForClass(classToProcess);
for (RefClass dependency : dependencies) {
if (!pendingClasses.contains(dependency) &&
!processedClasses.contains(dependency)) {
pendingClasses.addLast(dependency);
}
}
}
newDependencies.remove(refClass);
}
示例4: tabulateInitializationDependentClasses
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@SuppressWarnings({"MethodWithMultipleLoops"})
private static void tabulateInitializationDependentClasses(
RefElement element, Set<RefClass> dependents) {
final Collection<RefElement> references = element.getInReferences();
final RefJavaUtil refUtil = RefJavaUtil.getInstance();
for (RefElement reference : references) {
final RefClass refClass = refUtil.getTopLevelClass(reference);
if (refClass != null) {
dependents.add(refClass);
}
}
final List<RefEntity> children = element.getChildren();
if (children == null) {
return;
}
for (RefEntity child : children) {
if (child instanceof RefElement) {
tabulateInitializationDependentClasses((RefElement)child,
dependents);
}
}
}
示例5: tabulateInitializationTransitiveDependentClasses
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
private static void tabulateInitializationTransitiveDependentClasses(
RefClass refClass, Set<RefClass> newDependents) {
final LinkedList<RefClass> pendingClasses = new LinkedList<RefClass>();
final Set<RefClass> processedClasses = new HashSet<RefClass>();
pendingClasses.addLast(refClass);
while (!pendingClasses.isEmpty()) {
final RefClass classToProcess = pendingClasses.removeFirst();
newDependents.add(classToProcess);
processedClasses.add(classToProcess);
final Set<RefClass> dependents =
calculateInitializationDependentsForClass(classToProcess);
for (RefClass dependent : dependents) {
if (!pendingClasses.contains(dependent) &&
!processedClasses.contains(dependent)) {
pendingClasses.addLast(dependent);
}
}
}
newDependents.remove(refClass);
}
示例6: getClassOrInterface
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
public static String getClassOrInterface(RefClass refClass, boolean capitalizeFirstLetter) {
if (refClass.isInterface()) {
return capitalizeFirstLetter ? InspectionsBundle.message("inspection.export.results.capitalized.interface") : InspectionsBundle.message("inspection.export.results.interface");
}
else if (refClass.isAbstract()) {
return capitalizeFirstLetter ? InspectionsBundle.message("inspection.export.results.capitalized.abstract.class") : InspectionsBundle.message("inspection.export.results.abstract.class");
}
else {
return capitalizeFirstLetter ? InspectionsBundle.message("inspection.export.results.capitalized.class") : InspectionsBundle.message("inspection.export.results.class");
}
}
示例7: checkElement
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
@NotNull RefEntity refEntity,
@NotNull AnalysisScope analysisScope,
@NotNull InspectionManager inspectionManager,
@NotNull GlobalInspectionContext globalInspectionContext) {
if (!(refEntity instanceof RefModule)) {
return null;
}
final List<RefEntity> children = refEntity.getChildren();
if (children == null) {
return null;
}
int numClasses = 0;
for (RefEntity child : children) {
if (child instanceof RefClass) {
numClasses++;
}
}
if (numClasses <= limit) {
return null;
}
final String errorString = InspectionGadgetsBundle.message(
"module.with.too.many.classes.problem.descriptor",
refEntity.getName(), Integer.valueOf(numClasses),
Integer.valueOf(limit));
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)
};
}
示例8: checkElement
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope, @NotNull InspectionManager inspectionManager,
@NotNull GlobalInspectionContext globalInspectionContext) {
if (!(refEntity instanceof RefModule)) {
return null;
}
final RefModule refModule = (RefModule)refEntity;
final List<RefEntity> children = refModule.getChildren();
if (children == null) {
return null;
}
int numClasses = 0;
for (RefEntity child : children) {
if (child instanceof RefClass) {
numClasses++;
}
}
if (numClasses >= limit || numClasses == 0) {
return null;
}
final Project project = globalInspectionContext.getProject();
final Module[] modules = ModuleManager.getInstance(project).getModules();
if (modules.length == 1) {
return null;
}
final String errorString = InspectionGadgetsBundle.message("module.with.too.few.classes.problem.descriptor",
refModule.getName(), Integer.valueOf(numClasses), Integer.valueOf(limit));
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)
};
}
示例9: checkElement
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@Nullable
@Override
public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity,
@NotNull AnalysisScope scope,
@NotNull InspectionManager manager,
@NotNull GlobalInspectionContext globalContext) {
if (!(refEntity instanceof RefPackage)) {
return null;
}
final RefPackage refPackage = (RefPackage)refEntity;
final String packageName = refPackage.getQualifiedName();
final Project project = globalContext.getProject();
final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
if (hasPackageInfoFile(aPackage)) {
return null;
}
final List<RefEntity> children = refPackage.getChildren();
boolean hasClasses = false;
for (RefEntity child : children) {
if (child instanceof RefClass) {
hasClasses = true;
break;
}
}
if (!hasClasses) {
return null;
}
if (PsiUtil.isLanguageLevel5OrHigher(aPackage)) {
return new CommonProblemDescriptor[] {
manager.createProblemDescriptor(InspectionGadgetsBundle.message("missing.package.info.problem.descriptor", packageName))};
}
else {
return new CommonProblemDescriptor[] {
manager.createProblemDescriptor(InspectionGadgetsBundle.message("missing.package.html.problem.descriptor", packageName))};
}
}
示例10: checkElement
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
@NotNull RefEntity refEntity,
@NotNull AnalysisScope analysisScope,
@NotNull InspectionManager inspectionManager,
@NotNull GlobalInspectionContext globalInspectionContext) {
if (!(refEntity instanceof RefPackage)) {
return null;
}
final List<RefEntity> children = refEntity.getChildren();
if (children == null) {
return null;
}
int numClasses = 0;
for (RefEntity child : children) {
if (child instanceof RefClass) {
numClasses++;
}
}
if (numClasses <= limit) {
return null;
}
final String errorString = InspectionGadgetsBundle.message(
"package.with.too.many.classes.problem.descriptor",
refEntity.getQualifiedName(), Integer.valueOf(numClasses),
Integer.valueOf(limit));
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)
};
}
示例11: checkElement
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
@NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope,
@NotNull InspectionManager inspectionManager,
@NotNull GlobalInspectionContext globalInspectionContext) {
if (!(refEntity instanceof RefPackage)) {
return null;
}
final List<RefEntity> children = refEntity.getChildren();
if (children == null) {
return null;
}
final Set<RefModule> modules = new HashSet<RefModule>();
for (RefEntity child : children) {
if (!(child instanceof RefClass)) {
continue;
}
final RefClass refClass = (RefClass)child;
final RefModule module = refClass.getModule();
modules.add(module);
}
if (modules.size() <= 1) {
return null;
}
final String errorString =
InspectionGadgetsBundle.message(
"package.in.multiple.modules.problem.descriptor",
refEntity.getQualifiedName());
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)};
}
示例12: checkElement
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
@NotNull RefEntity refEntity,
@NotNull AnalysisScope analysisScope,
@NotNull InspectionManager inspectionManager,
@NotNull GlobalInspectionContext globalInspectionContext) {
if (!(refEntity instanceof RefPackage)) {
return null;
}
final List<RefEntity> children = refEntity.getChildren();
if (children == null) {
return null;
}
int numClasses = 0;
boolean subpackage = false;
for (RefEntity child : children) {
if (child instanceof RefClass) {
numClasses++;
}
else if (child instanceof RefPackage) {
subpackage = true;
}
}
if (numClasses >= limit || (numClasses == 0 && subpackage)) {
return null;
}
final String errorString = InspectionGadgetsBundle.message(
"package.with.too.few.classes.problem.descriptor",
refEntity.getQualifiedName(), Integer.valueOf(numClasses),
Integer.valueOf(limit));
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)
};
}
示例13: createComponents
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
private static Set<Set<RefClass>> createComponents(
RefPackage aPackage, Set<RefClass> classes) {
final Set<RefClass> allClasses = new HashSet<RefClass>(classes);
final Set<Set<RefClass>> out = new HashSet<Set<RefClass>>();
while (!allClasses.isEmpty()) {
final RefClass seed = allClasses.iterator().next();
allClasses.remove(seed);
final Set<RefClass> currentComponent = new HashSet<RefClass>();
currentComponent.add(seed);
final List<RefClass> pendingClasses = new ArrayList<RefClass>();
pendingClasses.add(seed);
while (!pendingClasses.isEmpty()) {
final RefClass classToProcess = pendingClasses.remove(0);
final Set<RefClass> relatedClasses =
getRelatedClasses(aPackage, classToProcess);
for (RefClass relatedClass : relatedClasses) {
if (!currentComponent.contains(relatedClass) &&
!pendingClasses.contains(relatedClass)) {
currentComponent.add(relatedClass);
pendingClasses.add(relatedClass);
allClasses.remove(relatedClass);
}
}
}
out.add(currentComponent);
}
return out;
}
示例14: checkElement
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
@NotNull RefEntity refEntity,
@NotNull AnalysisScope analysisScope,
@NotNull InspectionManager inspectionManager,
@NotNull GlobalInspectionContext globalInspectionContext) {
if (!(refEntity instanceof RefClass)) {
return null;
}
final RefClass refClass = (RefClass)refEntity;
final PsiClass aClass = refClass.getElement();
if (ClassUtils.isInnerClass(aClass)) {
return null;
}
final Set<RefClass> dependents =
DependencyUtils.calculateDependentsForClass(refClass);
final int numDependents = dependents.size();
if (numDependents <= limit) {
return null;
}
final String errorString = InspectionGadgetsBundle.message(
"class.with.too.many.dependents.problem.descriptor",
refEntity.getName(), numDependents, limit);
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)
};
}
示例15: runInspection
import com.intellij.codeInspection.reference.RefClass; //导入依赖的package包/类
@Override
public void runInspection(
@NotNull AnalysisScope scope,
@NotNull final InspectionManager inspectionManager,
@NotNull GlobalInspectionContext globalInspectionContext,
@NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
final RefManager refManager = globalInspectionContext.getRefManager();
refManager.iterate(new RefJavaVisitor() {
@Override
public void visitClass(@NotNull RefClass refClass) {
super.visitClass(refClass);
if (refClass.getOwner() instanceof RefClass) {
return;
}
final Set<RefClass> dependencies =
DependencyUtils.calculateDependenciesForClass(refClass);
final int numDependencies = dependencies.size();
if (numDependencies <= limit) {
return;
}
final String errorString = InspectionGadgetsBundle.message(
"class.with.too.many.dependencies.problem.descriptor",
refClass.getName(), numDependencies, limit);
final CommonProblemDescriptor[] descriptors = {
inspectionManager.createProblemDescriptor(errorString)};
problemDescriptionsProcessor.addProblemElement(refClass, descriptors);
}
});
}