mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -209,19 +209,19 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
@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;
|
||||
}
|
||||
@@ -247,8 +247,7 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -265,8 +264,7 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -320,7 +318,7 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -328,7 +326,7 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -409,4 +407,4 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,43 +250,42 @@ public class RefMethodImpl extends RefJavaElementImpl implements RefMethod {
|
||||
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));
|
||||
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));
|
||||
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);
|
||||
PsiType retType = method.getReturnType();
|
||||
if (retType != null) {
|
||||
PsiType psiType = retType;
|
||||
RefClass ownerClass = refUtil.getOwnerClass(getRefManager(), method);
|
||||
|
||||
if (ownerClass != null) {
|
||||
psiType = psiType.getDeepComponentType();
|
||||
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 (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) {
|
||||
|
||||
@@ -139,7 +139,7 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement
|
||||
}
|
||||
|
||||
public boolean isReferenced() {
|
||||
return getInReferences().size() > 0;
|
||||
return !getInReferences().isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasSuspiciousCallers() {
|
||||
@@ -257,6 +257,6 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement
|
||||
}
|
||||
}
|
||||
final RefEntity entity = getOwner();
|
||||
return entity instanceof RefElement && ((RefElementImpl)entity).isSuppressed(toolId);
|
||||
return entity instanceof RefElementImpl && ((RefElementImpl)entity).isSuppressed(toolId);
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -23,6 +23,7 @@ import com.intellij.openapi.vfs.VfsUtil;
|
||||
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;
|
||||
@@ -35,6 +36,7 @@ import java.util.List;
|
||||
class CompositeProjectRoot implements ProjectRoot {
|
||||
private final List<ProjectRoot> myRoots = new ArrayList<ProjectRoot>();
|
||||
|
||||
@NotNull
|
||||
ProjectRoot[] getProjectRoots() {
|
||||
return myRoots.toArray(new ProjectRoot[myRoots.size()]);
|
||||
}
|
||||
@@ -68,6 +70,7 @@ class CompositeProjectRoot implements ProjectRoot {
|
||||
myRoots.remove(root);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
ProjectRoot add(VirtualFile virtualFile) {
|
||||
final SimpleProjectRoot root = new SimpleProjectRoot(virtualFile);
|
||||
myRoots.add(root);
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ProjectJdkImpl extends UserDataHolderBase implements JDOMExternaliz
|
||||
}
|
||||
|
||||
public final void setVersionString(String versionString) {
|
||||
myVersionString = (versionString == null || "".equals(versionString)) ? null : versionString;
|
||||
myVersionString = versionString == null || "".equals(versionString) ? null : versionString;
|
||||
myVersionDefined = true;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -838,6 +838,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
configureInspections(myInspections == null ? new LocalInspectionTool[0] : myInspections);
|
||||
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
|
||||
DaemonCodeAnalyzer.getInstance(getProject()).setUpdateByTimerEnabled(false);
|
||||
ensureIndexesUpToDate(getProject());
|
||||
}
|
||||
|
||||
private void enableInspectionTool(InspectionProfileEntry tool){
|
||||
@@ -1188,7 +1189,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ public abstract class ModuleFixtureBuilderImpl<T extends ModuleFixture> implemen
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public abstract class ModuleFixtureBuilderImpl<T extends ModuleFixture> implemen
|
||||
protected abstract T instantiateFixture();
|
||||
|
||||
Module buildModule() {
|
||||
final Module[] module = new Module[]{null};
|
||||
final Module[] module = {null};
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
@@ -890,7 +890,7 @@ public class StringUtil {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user