(no message)

This commit is contained in:
Dave Griffith
2005-02-10 23:54:31 +03:00
parent 14494ace1b
commit 04924a69e9
10 changed files with 43 additions and 69 deletions
@@ -14,6 +14,15 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/extensions.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntryProperties />
</component>
</module>
@@ -192,7 +192,7 @@
<module fileurl="file://$PROJECT_DIR$/InspectionGadgetsSVN.iml" filepath="$PROJECT_DIR$/InspectionGadgetsSVN.iml" />
</modules>
</component>
<component name="ProjectRootManager" version="2" assert-keyword="false" jdk-15="false" project-jdk-name="IDEA 3200" />
<component name="ProjectRootManager" version="2" assert-keyword="false" jdk-15="false" project-jdk-name="IDEA 3212" />
<component name="RmicSettings">
<option name="IS_EANABLED" value="false" />
<option name="DEBUGGING_INFO" value="true" />
@@ -1,3 +1,4 @@
<idea-plugin>
<name>Inspection Gadgets</name>
<category>inspection</category>
@@ -11,10 +12,5 @@
<implementation-class>com.siyeh.ig.InspectionGadgetsPlugin</implementation-class>
</component>
</application-components>
<!--project-components>
<component>
<implementation-class>com.siyeh.ig.dependency.DependencyMap</implementation-class>
</component>
</project-components-->
</idea-plugin>
+3 -2
View File
@@ -3,7 +3,7 @@
<project name="InspectionGadgets" default="compile">
<taskdef name="javac2" classname="com.intellij.uiDesigner.ant.Javac2" classpathref="project.class.path"/>
<property name="src.dir" value="src"/>
<property name="idea.dir" value="c:/IntelliJ-IDEA-3193"/>
<property name="idea.dir" value="c:/IntelliJ-IDEA-3212/IntelliJ IDEA"/>
<property name="idea.plugin.dir" value="C:\Documents and Settings\dgriffith\.IntelliJIdea\config\plugins"/>
<property name="debug" value="true"/>
<property name="optimize" value="off"/>
@@ -17,6 +17,7 @@
<pathelement location="${idea.dir}/lib/openAPI.jar"/>
<pathelement location="${idea.dir}/lib/idea.jar"/>
<pathelement location="${idea.dir}/lib/jdom.jar"/>
<pathelement location="${idea.dir}/lib/extensions.jar"/>
</path>
<target name="init">
@@ -64,7 +65,7 @@
<include name="**/*"/>
</fileset>
</zip>
</target>
</target>
<target name="sync" depends="clean" description="Dump it to the watch">
<sync todir="E:\InspectionGadgets">
@@ -5,7 +5,6 @@ import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemHighlightType;
import com.intellij.psi.*;
import com.siyeh.ig.dependency.DependencyMap;
import java.util.ArrayList;
import java.util.List;
@@ -134,14 +133,4 @@ public abstract class BaseInspectionVisitor extends PsiRecursiveElementVisitor {
}
}
public DependencyMap fetchDependencyMap()
{
final DependencyMap dependencyMap = (DependencyMap) m_inspectionManager.getProject().getComponent(DependencyMap.class);
if(!m_onTheFly)
{
dependencyMap.waitForCompletion();
}
return dependencyMap;
}
}
@@ -14,7 +14,6 @@ import com.siyeh.ig.cloneable.CloneCallsSuperCloneInspection;
import com.siyeh.ig.cloneable.CloneDeclaresCloneNotSupportedInspection;
import com.siyeh.ig.cloneable.CloneableImplementsCloneInspection;
import com.siyeh.ig.confusing.*;
import com.siyeh.ig.dependency.*;
import com.siyeh.ig.encapsulation.*;
import com.siyeh.ig.errorhandling.*;
import com.siyeh.ig.finalization.FinalizeCallsSuperFinalizeInspection;
@@ -31,9 +30,6 @@ import com.siyeh.ig.logging.NonStaticFinalLoggerInspection;
import com.siyeh.ig.maturity.*;
import com.siyeh.ig.methodmetrics.*;
import com.siyeh.ig.naming.*;
import com.siyeh.ig.packaging.PackageEncapsulationInspection;
import com.siyeh.ig.packaging.PackageSizeInspection;
import com.siyeh.ig.packaging.PackageTangleInspection;
import com.siyeh.ig.performance.*;
import com.siyeh.ig.portability.*;
import com.siyeh.ig.resources.IOResourceInspection;
@@ -189,7 +185,6 @@ public class InspectionGadgetsPlugin implements ApplicationComponent,
registerNamingInspections();
registerBugInspections();
registerCloneInspections();
//registerDependencyInspections();
registerConfusingInspections();
registerAbstractionInspections();
registerClassLayoutInspections();
@@ -213,7 +208,6 @@ public class InspectionGadgetsPlugin implements ApplicationComponent,
registerLoggingInspections();
registerSecurityInspections();
registerResourceManagementInspections();
// registerPackagingInspections();
Collections.sort(m_inspectionClasses, new InspectionComparator());
}
@@ -223,16 +217,6 @@ public class InspectionGadgetsPlugin implements ApplicationComponent,
inspectionClasses.add(JDBCResourceInspection.class);
}
private void registerDependencyInspections(){
final List inspectionClasses = m_inspectionClasses;
inspectionClasses.add(LocalButterflyInspection.class);
inspectionClasses.add(LocalBreakableInspection.class);
inspectionClasses.add(LocalHubInspection.class);
inspectionClasses.add(GlobalButterflyInspection.class);
inspectionClasses.add(GlobalBreakableInspection.class);
inspectionClasses.add(GlobalHubInspection.class);
inspectionClasses.add(TangleInspection.class);
}
private void registerLoggingInspections(){
final List inspectionClasses = m_inspectionClasses;
@@ -241,13 +225,6 @@ public class InspectionGadgetsPlugin implements ApplicationComponent,
inspectionClasses.add(NonStaticFinalLoggerInspection.class);
}
private void registerPackagingInspections(){
final List inspectionClasses = m_inspectionClasses;
inspectionClasses.add(PackageSizeInspection.class);
inspectionClasses.add(PackageEncapsulationInspection.class);
inspectionClasses.add(PackageTangleInspection.class);
}
private void registerSecurityInspections(){
final List inspectionClasses = m_inspectionClasses;
inspectionClasses.add(DeserializableClassInSecureContextInspection.class);
@@ -1,9 +1,7 @@
package com.siyeh.ig.confusing;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.psi.PsiAssignmentExpression;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiExpressionStatement;
import com.intellij.psi.*;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.ig.ExpressionInspection;
@@ -34,7 +32,10 @@ public class NestedAssignmentInspection extends ExpressionInspection {
public void visitAssignmentExpression(PsiAssignmentExpression expression) {
super.visitAssignmentExpression(expression);
if (expression.getParent() instanceof PsiExpressionStatement) {
final PsiElement parent = expression.getParent();
final PsiElement grandparent = parent.getParent();
if (parent instanceof PsiExpressionStatement ||
grandparent instanceof PsiExpressionListStatement) {
return;
}
registerError(expression);
@@ -80,32 +80,17 @@ public class EmptyCatchBlockInspection extends StatementInspection {
}
}
final PsiCodeBlock[] catchBlocks = statement.getCatchBlocks();
for (int i = 0; i < catchBlocks.length; i++) {
final PsiCodeBlock block = catchBlocks[i];
final PsiCatchSection[] catchSections = statement.getCatchSections();
for (int i = 0; i < catchSections.length; i++) {
final PsiCatchSection section = catchSections[i];
final PsiCodeBlock block = section.getCatchBlock();
if (catchBlockIsEmpty(block)) {
final PsiElement catchToken = getCatchToken(statement, i);
final PsiElement catchToken = section.getFirstChild();
registerError(catchToken);
}
}
}
private PsiElement getCatchToken(PsiTryStatement statement, int i) {
final PsiElement[] children = statement.getChildren();
int catchNumber = 0;
for (int j = 0; j < children.length; j++) {
final PsiElement child = children[j];
final String childText = child.getText();
if ("catch".equals(childText)) {
if (catchNumber == i) {
return child;
}
catchNumber++;
}
}
return null;
}
private boolean catchBlockIsEmpty(PsiCodeBlock block) {
if (m_includeComments) {
final PsiElement[] children = block.getChildren();
@@ -67,6 +67,15 @@ public class UnnecessaryConstructorInspection extends ClassInspection {
if (parameterList.getParameters().length != 0) {
return;
}
final PsiReferenceList throwsList = constructor.getThrowsList();
if(throwsList!=null)
{
final PsiJavaCodeReferenceElement[] elements = throwsList.getReferenceElements();
if(elements.length!=0)
{
return;
}
}
final PsiCodeBlock body = constructor.getBody();
if (body == null) {
return;
@@ -2,20 +2,27 @@ package com.siyeh.igtest.confusing;
public class NestedAssignmentInspection
{
public NestedAssignmentInspection()
public NestedAssignmentInspection() throws Exception
{
super();
}
public void foo()
{
final int[] baz = new int[3];
final int i;
final int val = baz[i=2];
int i;
int val = baz[i=2];
System.out.println("i = " + i);
System.out.println("val = " + val);
for(int j=0,k=0;j<1000;j += 1,k += 1)
{
}
barangus(i=2, val=3);
System.out.println("i = " + i);
System.out.println("val = " + val);
}
private void barangus(int i, int val){
}
}