[Fb-contrib-commit] SF.net SVN: fb-contrib: [978] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-11-24 01:22:26
|
Revision: 978 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=978&view=rev Author: dbrosius Date: 2007-11-23 17:22:26 -0800 (Fri, 23 Nov 2007) Log Message: ----------- be precise about setup/teardown Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2007-11-23 07:59:00 UTC (rev 977) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/FieldCouldBeLocal.java 2007-11-24 01:22:26 UTC (rev 978) @@ -79,36 +79,37 @@ */ @Override public void visitClassContext(ClassContext classContext) { - localizableFields = new HashMap<String, FieldInfo>(); - visitedBlocks = new BitSet(); - clsContext = classContext; - cfg = null; - cpg = null; - JavaClass cls = classContext.getJavaClass(); - Field[] fields = cls.getFields(); - for (Field f : fields) { - if ((!f.isStatic() && f.getName().indexOf('$') < 0) && f.isPrivate()) { - FieldAnnotation fa = new FieldAnnotation(cls.getClassName(), f.getName(), f.getSignature(), false); - localizableFields.put(f.getName(), new FieldInfo(fa)); + try { + localizableFields = new HashMap<String, FieldInfo>(); + visitedBlocks = new BitSet(); + clsContext = classContext; + JavaClass cls = classContext.getJavaClass(); + Field[] fields = cls.getFields(); + for (Field f : fields) { + if ((!f.isStatic() && f.getName().indexOf('$') < 0) && f.isPrivate()) { + FieldAnnotation fa = new FieldAnnotation(cls.getClassName(), f.getName(), f.getSignature(), false); + localizableFields.put(f.getName(), new FieldInfo(fa)); + } } - } - - if (localizableFields.size() > 0) { - super.visitClassContext(classContext); - for (FieldInfo fi : localizableFields.values()) { - FieldAnnotation fa = fi.getFieldAnnotation(); - SourceLineAnnotation sla = fi.getSrcLineAnnotation(); - BugInstance bug = new BugInstance(this, "FCBL_FIELD_COULD_BE_LOCAL", NORMAL_PRIORITY) - .addClass(this) - .addField(fa); - if (sla != null) - bug.addSourceLine(sla); - bugReporter.reportBug(bug); + + if (localizableFields.size() > 0) { + super.visitClassContext(classContext); + for (FieldInfo fi : localizableFields.values()) { + FieldAnnotation fa = fi.getFieldAnnotation(); + SourceLineAnnotation sla = fi.getSrcLineAnnotation(); + BugInstance bug = new BugInstance(this, "FCBL_FIELD_COULD_BE_LOCAL", NORMAL_PRIORITY) + .addClass(this) + .addField(fa); + if (sla != null) + bug.addSourceLine(sla); + bugReporter.reportBug(bug); + } } + } finally { + localizableFields = null; + visitedBlocks = null; + clsContext = null; } - localizableFields = null; - visitedBlocks = null; - clsContext = null; } /** @@ -138,6 +139,7 @@ } finally { cfg = null; + cpg = null; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |