@Nullable
public String getType(final RefEntity ref) {
if (ref instanceof RefMethod) {
- return RefJavaManager.METHOD;
+ return METHOD;
}
else if (ref instanceof RefClass) {
- return RefJavaManager.CLASS;
+ return CLASS;
}
else if (ref instanceof RefField) {
- return RefJavaManager.FIELD;
+ return FIELD;
}
else if (ref instanceof RefParameter) {
- return RefJavaManager.PARAMETER;
+ return PARAMETER;
}
else if (ref instanceof RefPackage) {
- return RefJavaManager.PACKAGE;
+ return PACKAGE;
}
return null;
}
}
public boolean belongsToScope(final PsiElement psiElement) {
- if (psiElement instanceof PsiTypeParameter) return false;
- return true;
+ return !(psiElement instanceof PsiTypeParameter);
}
public void export(final RefEntity refEntity, final Element element) {
private static void appendPackageElement(final Element element, final String packageName) {
final Element packageElement = new Element("package");
- packageElement
- .addContent(packageName.length() > 0 ? packageName : InspectionsBundle.message("inspection.export.results.default"));
+ packageElement.addContent(packageName.length() > 0 ? packageName : InspectionsBundle.message("inspection.export.results.default"));
element.addContent(packageElement);
}
public void visitMethod(final PsiMethod method) {
super.visitMethod(method);
final RefElement refElement = myRefManager.getReference(method);
- if (refElement instanceof RefMethod) {
+ if (refElement instanceof RefMethodImpl) {
((RefMethodImpl)refElement).buildReferences();
}
}
public void visitField(final PsiField field) {
super.visitField(field);
final RefElement refElement = myRefManager.getReference(field);
- if (refElement instanceof RefField) {
+ if (refElement instanceof RefFieldImpl) {
((RefFieldImpl)refElement).buildReferences();
}
}
}
}
}
-}
\ No newline at end of file
+}
public void buildReferences() {
// Work on code block to find what we're referencing...
PsiMethod method = (PsiMethod) getElement();
- if (method != null) {
- PsiCodeBlock body = method.getBody();
- final RefJavaUtil refUtil = RefJavaUtil.getInstance();
- refUtil.addReferences(method, this, body);
- refUtil.addReferences(method, this, method.getModifierList());
- checkForSuperCall(method);
- setOnlyCallsSuper(refUtil.isMethodOnlyCallsSuper(method));
-
- setBodyEmpty(isOnlyCallsSuper() || !isExternalOverride() && (body == null || body.getStatements().length == 0));
-
- PsiType retType = method.getReturnType();
- if (retType != null) {
- PsiType psiType = retType;
- RefClass ownerClass = refUtil.getOwnerClass(getRefManager(), method);
-
- if (ownerClass != null) {
- psiType = psiType.getDeepComponentType();
-
- if (psiType instanceof PsiClassType) {
- PsiClass psiClass = PsiUtil.resolveClassInType(psiType);
- if (psiClass != null && getRefManager().belongsToScope(psiClass)) {
- RefClassImpl refClass = (RefClassImpl) getRefManager().getReference(psiClass);
- if (refClass != null) {
- refClass.addTypeReference(ownerClass);
- refClass.addClassExporter(this);
- }
+ if (method == null) return;
+ PsiCodeBlock body = method.getBody();
+ final RefJavaUtil refUtil = RefJavaUtil.getInstance();
+ refUtil.addReferences(method, this, body);
+ refUtil.addReferences(method, this, method.getModifierList());
+ checkForSuperCall(method);
+ setOnlyCallsSuper(refUtil.isMethodOnlyCallsSuper(method));
+
+ setBodyEmpty(isOnlyCallsSuper() || !isExternalOverride() && (body == null || body.getStatements().length == 0));
+
+ PsiType retType = method.getReturnType();
+ if (retType != null) {
+ PsiType psiType = retType;
+ RefClass ownerClass = refUtil.getOwnerClass(getRefManager(), method);
+
+ if (ownerClass != null) {
+ psiType = psiType.getDeepComponentType();
+
+ if (psiType instanceof PsiClassType) {
+ PsiClass psiClass = PsiUtil.resolveClassInType(psiType);
+ if (psiClass != null && getRefManager().belongsToScope(psiClass)) {
+ RefClassImpl refClass = (RefClassImpl) getRefManager().getReference(psiClass);
+ if (refClass != null) {
+ refClass.addTypeReference(ownerClass);
+ refClass.addClassExporter(this);
}
}
}
}
+ }
- for (RefParameter parameter : getParameters()) {
- refUtil.setIsFinal(parameter, parameter.getElement().hasModifierProperty(PsiModifier.FINAL));
- }
-
- getRefManager().fireBuildReferences(this);
+ for (RefParameter parameter : getParameters()) {
+ refUtil.setIsFinal(parameter, parameter.getElement().hasModifierProperty(PsiModifier.FINAL));
}
+
+ getRefManager().fireBuildReferences(this);
}
private void collectUncaughtExceptions(PsiMethod method) {
}
public boolean isReferenced() {
- return getInReferences().size() > 0;
+ return !getInReferences().isEmpty();
}
public boolean hasSuspiciousCallers() {
}
}
final RefEntity entity = getOwner();
- return entity instanceof RefElement && ((RefElementImpl)entity).isSuppressed(toolId);
+ return entity instanceof RefElementImpl && ((RefElementImpl)entity).isSuppressed(toolId);
}
}
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ArrayUtil;
import org.jdom.Element;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
class CompositeProjectRoot implements ProjectRoot {
private final List<ProjectRoot> myRoots = new ArrayList<ProjectRoot>();
+ @NotNull
ProjectRoot[] getProjectRoots() {
return myRoots.toArray(new ProjectRoot[myRoots.size()]);
}
myRoots.remove(root);
}
+ @NotNull
ProjectRoot add(VirtualFile virtualFile) {
final SimpleProjectRoot root = new SimpleProjectRoot(virtualFile);
myRoots.add(root);
}
public final void setVersionString(String versionString) {
- myVersionString = (versionString == null || "".equals(versionString)) ? null : versionString;
+ myVersionString = versionString == null || "".equals(versionString) ? null : versionString;
myVersionDefined = true;
}
configureInspections(myInspections == null ? new LocalInspectionTool[0] : myInspections);
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
DaemonCodeAnalyzer.getInstance(getProject()).setUpdateByTimerEnabled(false);
+ ensureIndexesUpToDate(getProject());
}
private void enableInspectionTool(InspectionProfileEntry tool){
}
}
- private static void ensureIndexesUpToDate(Project project) {
+ public static void ensureIndexesUpToDate(Project project) {
FileBasedIndex.getInstance().ensureUpToDate(StubUpdatingIndex.INDEX_ID, project, null);
FileBasedIndex.getInstance().ensureUpToDate(TodoIndex.NAME, project, null);
assertTrue(!DumbServiceImpl.getInstance(project).isDumb());
}
public ModuleFixtureBuilder<T> addSourceRoot(final String sourceRootPath) {
- assert myContentRoots.size() > 0 : "content root should be added first";
+ assert !myContentRoots.isEmpty() : "content root should be added first";
mySourceRoots.add(sourceRootPath);
return this;
}
protected abstract T instantiateFixture();
Module buildModule() {
- final Module[] module = new Module[]{null};
+ final Module[] module = {null};
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
if (separator.length() == 0) {
return Collections.singletonList(s);
}
- ArrayList<String> result = new ArrayList<String>();
+ List<String> result = new ArrayList<String>();
int pos = 0;
while (true) {
int index = s.indexOf(separator, pos);