本文整理汇总了Java中com.intellij.codeInspection.reference.RefPackage类的典型用法代码示例。如果您正苦于以下问题:Java RefPackage类的具体用法?Java RefPackage怎么用?Java RefPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RefPackage类属于com.intellij.codeInspection.reference包,在下文中一共展示了RefPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRelatedClasses
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的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: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的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))};
}
}
示例3: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的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)
};
}
示例4: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的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)};
}
示例5: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的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)
};
}
示例6: createComponents
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的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;
}
示例7: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的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 || numClasses == 0) {
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)
};
}
示例8: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的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 RefPackage refPackage = (RefPackage)refEntity;
final Set<RefPackage> dependencies =
DependencyUtils.calculateTransitiveDependenciesForPackage(refPackage);
final Set<RefPackage> dependents =
DependencyUtils.calculateTransitiveDependentsForPackage(refPackage);
final Set<RefPackage> mutualDependents =
new HashSet<RefPackage>(dependencies);
mutualDependents.retainAll(dependents);
final int numMutualDependents = mutualDependents.size();
if (numMutualDependents <= 1) {
return null;
}
final String packageName = refEntity.getName();
final String errorString = InspectionGadgetsBundle.message(
"cyclic.package.dependency.problem.descriptor",
packageName, numMutualDependents - 1);
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)
};
}
示例9: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
RefEntity refEntity,
AnalysisScope analysisScope,
InspectionManager inspectionManager,
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)
};
}
示例10: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
RefEntity refEntity, AnalysisScope analysisScope,
InspectionManager inspectionManager,
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)};
}
示例11: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
RefEntity refEntity,
AnalysisScope analysisScope,
InspectionManager inspectionManager,
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 || numClasses == 0) {
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)
};
}
示例12: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的package包/类
@Nullable
public CommonProblemDescriptor[] checkElement(
RefEntity refEntity,
AnalysisScope analysisScope,
InspectionManager inspectionManager,
GlobalInspectionContext globalInspectionContext) {
if (!(refEntity instanceof RefPackage)) {
return null;
}
final RefPackage refPackage = (RefPackage)refEntity;
final Set<RefPackage> dependencies =
DependencyUtils.calculateTransitiveDependenciesForPackage(refPackage);
final Set<RefPackage> dependents =
DependencyUtils.calculateTransitiveDependentsForPackage(refPackage);
final Set<RefPackage> mutualDependents =
new HashSet<RefPackage>(dependencies);
mutualDependents.retainAll(dependents);
final int numMutualDependents = mutualDependents.size();
if (numMutualDependents <= 1) {
return null;
}
final String packageName = refEntity.getName();
final String errorString = InspectionGadgetsBundle.message(
"cyclic.package.dependency.problem.descriptor",
packageName, numMutualDependents - 1);
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)
};
}
示例13: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
@NotNull RefEntity refEntity,
@NotNull AnalysisScope analysisScope,
@NotNull InspectionManager manager,
@NotNull GlobalInspectionContext globalInspectionContext) {
if (!(refEntity instanceof RefClass)) {
return null;
}
final RefClass refClass = (RefClass)refEntity;
final RefEntity owner = refClass.getOwner();
if (!(owner instanceof RefPackage)) {
return null;
}
final Set<RefClass> dependencies =
DependencyUtils.calculateDependenciesForClass(refClass);
for (RefClass dependency : dependencies) {
if (inSamePackage(refClass, dependency)) {
return null;
}
}
final Set<RefClass> dependents =
DependencyUtils.calculateDependentsForClass(refClass);
for (RefClass dependent : dependents) {
if (inSamePackage(refClass, dependent)) {
return null;
}
}
final PsiClass aClass = refClass.getElement();
final PsiIdentifier identifier = aClass.getNameIdentifier();
if (identifier == null) {
return null;
}
return new CommonProblemDescriptor[]{
manager.createProblemDescriptor(identifier,
InspectionGadgetsBundle.message(
"class.unconnected.to.package.problem.descriptor"),
true, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false)
};
}
示例14: checkElement
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的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 RefPackage refPackage = (RefPackage)refEntity;
final List<RefEntity> children = refPackage.getChildren();
if (children == null) {
return null;
}
final Set<RefClass> childClasses = new HashSet<RefClass>();
for (RefEntity child : children) {
if (!(child instanceof RefClass)) {
continue;
}
final PsiClass psiClass = ((RefClass)child).getElement();
if (ClassUtils.isInnerClass(psiClass)) {
continue;
}
childClasses.add((RefClass)child);
}
if (childClasses.isEmpty()) {
return null;
}
final Set<Set<RefClass>> components =
createComponents(refPackage, childClasses);
if (components.size() == 1) {
return null;
}
final String errorString = InspectionGadgetsBundle
.message("disjoint.package.problem.descriptor",
refPackage.getQualifiedName(),
Integer.valueOf(components.size()));
return new CommonProblemDescriptor[]{
inspectionManager.createProblemDescriptor(errorString)};
}
示例15: packageContainsClass
import com.intellij.codeInspection.reference.RefPackage; //导入依赖的package包/类
private static boolean packageContainsClass(RefPackage aPackage,
RefClass aClass) {
return aPackage.equals(RefJavaUtil.getPackage(aClass));
}