Author: scabanovich
Date: 2007-07-31 07:07:49 -0400 (Tue, 31 Jul 2007)
New Revision: 2749
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/ScannerException.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
EXIN-217 - Most exceptions in throw/catch narrowed.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -41,7 +41,7 @@
}
try {
this.scopeType = scope == null || scope.length() == 0 ? ScopeType.UNSPECIFIED :
ScopeType.valueOf(scope.toUpperCase());
- } catch (Exception e) {
+ } catch (IllegalArgumentException e) {
//ignore
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -92,7 +92,7 @@
if(s == null || s.length() == 0) continue;
try {
return Integer.valueOf(s);
- } catch (Exception e) {
+ } catch (NumberFormatException e) {
//ignore here
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -64,7 +64,7 @@
} else {
try {
scopeType = ScopeType.valueOf(scope.toUpperCase());
- } catch (Exception e) {
+ } catch (IllegalArgumentException e) {
scopeType = ScopeType.UNSPECIFIED;
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -132,11 +132,7 @@
public void resolveStorage(boolean load) {
if(isStorageResolved) return;
if(load) {
- try {
- load();
- } catch (Exception e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
+ load();
} else {
isStorageResolved = true;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -7,7 +7,10 @@
import java.util.Map;
import org.eclipse.core.resources.IFile;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.FindObjectHelper;
@@ -92,17 +95,17 @@
public void open() {
if(id instanceof XModelObject) {
XModelObject o = (XModelObject)id;
- try {
- FindObjectHelper.findModelObject(o, FindObjectHelper.IN_EDITOR_ONLY);
- } catch(Exception e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
+ FindObjectHelper.findModelObject(o, FindObjectHelper.IN_EDITOR_ONLY);
} else if(getResource() instanceof IFile) {
IFile f = (IFile)getResource();
try {
- IWorkbenchPage page =
SeamCorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbench workbench = SeamCorePlugin.getDefault().getWorkbench();
+ if(workbench == null) return;
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ if(window == null) return;
+ IWorkbenchPage page = window.getActivePage();
if(page != null) IDE.openEditor(page, f);
- } catch(Exception e) {
+ } catch(PartInitException e) {
SeamCorePlugin.getPluginLog().logError(e);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -41,7 +41,7 @@
if(scope == null || scope.length() == 0) return ScopeType.UNSPECIFIED;
try {
return ScopeType.valueOf(scope.toUpperCase());
- } catch (Exception e) {
+ } catch (IllegalArgumentException e) {
return ScopeType.UNSPECIFIED;
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -34,8 +34,8 @@
* Loading components declared in resource.
* @param f
* @return
- * @throws Exception
+ * @throws ScannerException
*/
- public LoadedDeclarations parse(IFile f) throws Exception;
+ public LoadedDeclarations parse(IFile f) throws ScannerException;
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/ScannerException.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/ScannerException.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/ScannerException.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -0,0 +1,17 @@
+package org.jboss.tools.seam.internal.core.scanner;
+
+public class ScannerException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public ScannerException() {
+ }
+
+ public ScannerException(Throwable cause) {
+ super(cause);
+ }
+
+ public ScannerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -18,6 +18,7 @@
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.ASTVisitor;
@@ -299,8 +300,13 @@
if(!name.equals(ms[i].getElementName())) continue;
int s = m.getStartPosition() + m.getLength() / 2;
try {
- int b = ms[i].getSourceRange().getOffset();
- int e = b + ms[i].getSourceRange().getLength();
+ ISourceRange range = ms[i].getSourceRange();
+ if(range == null) {
+ //no source and we cannot check position.
+ return ms[i];
+ }
+ int b = range.getOffset();
+ int e = b + range.getLength();
if(s >= b && s <= e) return ms[i];
} catch (JavaModelException e) {
return ms[i];
@@ -325,8 +331,13 @@
if(!name.equals(fs[i].getElementName())) continue;
int s = f.getStartPosition() + f.getLength() / 2;
try {
- int b = fs[i].getSourceRange().getOffset();
- int e = b + fs[i].getSourceRange().getLength();
+ ISourceRange range = fs[i].getSourceRange();
+ if(range == null) {
+ //no source and we cannot check position.
+ return fs[i];
+ }
+ int b = range.getOffset();
+ int e = b + range.getLength();
if(s >= b && s <= e) return fs[i];
} catch (JavaModelException e) {
return fs[i];
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -13,6 +13,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
@@ -28,6 +29,7 @@
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+import org.jboss.tools.seam.internal.core.scanner.ScannerException;
/**
* This object collects changes in target that should be fired to listeners.
@@ -70,10 +72,15 @@
* TODO change return type
* @param f
* @return
- * @throws Exception
+ * @throws ScannerException
*/
- public LoadedDeclarations parse(IFile f) throws Exception {
- ICompilationUnit u = getCompilationUnit(f);
+ public LoadedDeclarations parse(IFile f) throws ScannerException {
+ ICompilationUnit u = null;
+ try {
+ u = getCompilationUnit(f);
+ } catch (CoreException e) {
+ throw new ScannerException("Cannot get compilation unit for " + f, e);
+ }
if(u == null) return null;
ASTRequestorImpl requestor = new ASTRequestorImpl(f);
ICompilationUnit[] us = new ICompilationUnit[]{u};
@@ -81,7 +88,7 @@
return requestor.getDeclarations();
}
- private ICompilationUnit getCompilationUnit(IFile f) throws Exception {
+ private ICompilationUnit getCompilationUnit(IFile f) throws CoreException {
IProject project = f.getProject();
IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
IResource[] rs = EclipseResourceUtil.getJavaSourceRoots(project);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -22,6 +22,7 @@
import java.util.Set;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathContainer;
@@ -38,6 +39,7 @@
import org.jboss.tools.seam.internal.core.InnerModelHelper;
import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+import org.jboss.tools.seam.internal.core.scanner.ScannerException;
/**
* Monitors class path of project and loads seam components of it.
@@ -175,7 +177,7 @@
LoadedDeclarations c = null;
try {
c = scanner.parse(o, new Path(p));
- } catch (Exception e) {
+ } catch (ScannerException e) {
SeamCorePlugin.getDefault().logError(e);
}
if(c != null) componentsLoaded(c, new Path(p));
@@ -213,7 +215,7 @@
return classLoader;
}
- public static List<String> getJREClassPath(IProject project) throws Exception {
+ public static List<String> getJREClassPath(IProject project) throws CoreException
{
if(!project.hasNature(JavaCore.NATURE_ID)) return null;
ArrayList<String> l = new ArrayList<String>();
IJavaProject javaProject = JavaCore.create(project);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -34,6 +34,7 @@
import org.jboss.tools.seam.internal.core.InnerModelHelper;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+import org.jboss.tools.seam.internal.core.scanner.ScannerException;
import org.jboss.tools.seam.internal.core.scanner.xml.PropertiesScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
@@ -71,7 +72,7 @@
return isLikelyComponentSource(o);
}
- public LoadedDeclarations parse(IFile f) throws Exception {
+ public LoadedDeclarations parse(IFile f) throws ScannerException {
XModel model = InnerModelHelper.createXModel(f.getProject());
if(model == null) return null;
XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
@@ -92,7 +93,7 @@
return false;
}
- public LoadedDeclarations parse(XModelObject o, IPath path) throws Exception {
+ public LoadedDeclarations parse(XModelObject o, IPath path) throws ScannerException {
if(o == null) return null;
sourcePath = path;
XModelObject seamProperties = o.getChildByPath("META-INF/seam.properties");
@@ -102,7 +103,11 @@
LoadedDeclarations ds = new LoadedDeclarations();
- processJavaClasses(o, ds);
+ try {
+ processJavaClasses(o, ds);
+ } catch (JavaModelException e) {
+ throw new ScannerException("Cannot process Java Classes", e);
+ }
if(componentsXML != null) {
LoadedDeclarations ds1 = new XMLScanner().parse(componentsXML, path);
@@ -174,16 +179,10 @@
LoadedDeclarations ds1 = null;
TypeScanner scanner = new TypeScanner();
- try {
- if(!scanner.isLikelyComponentSource(reader)) return;
- ds1 = scanner.parse(type, reader, sourcePath);
- } catch (Throwable t) {
- System.out.println("failed " + className);
-// SeamCorePlugin.getPluginLog().logError(t);
- }
+ if(!scanner.isLikelyComponentSource(reader)) return;
+ ds1 = scanner.parse(type, reader, sourcePath);
if(ds1 != null) {
-// System.out.println("declarations found in " + className);
ds.add(ds1);
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -1,9 +1,6 @@
package org.jboss.tools.seam.internal.core.scanner.lib;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -12,6 +9,7 @@
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.env.EnumConstantSignature;
@@ -134,7 +132,7 @@
try {
int i = Integer.parseInt(precedence);
component.setPrecedence(i);
- } catch (Exception e) {
+ } catch (NumberFormatException e) {
//ignore
}
}
@@ -269,7 +267,7 @@
IMethod[] ms = null;
try {
ms = type.getMethods();
- } catch (Exception e) {
+ } catch (JavaModelException e) {
//ignore
}
if(ms != null) for (int i = 0; i < ms.length; i++) {
@@ -277,7 +275,7 @@
//check parameters
try {
if(ms[i].getParameterNames().length != m.getArgumentNames().length) continue;
- } catch (Exception e) {
+ } catch (JavaModelException e) {
continue;
}
//compare
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/PropertiesScanner.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -24,6 +24,7 @@
import org.jboss.tools.seam.internal.core.SeamValueString;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+import org.jboss.tools.seam.internal.core.scanner.ScannerException;
public class PropertiesScanner implements IFileScanner {
@@ -56,9 +57,9 @@
* Returns list of components
* @param f
* @return
- * @throws Exception
+ * @throws ScannerException
*/
- public LoadedDeclarations parse(IFile f) throws Exception {
+ public LoadedDeclarations parse(IFile f) throws ScannerException {
XModel model = InnerModelHelper.createXModel(f.getProject());
if(model == null) return null;
XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-31
10:54:56 UTC (rev 2748)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-31
11:07:49 UTC (rev 2749)
@@ -34,6 +34,7 @@
import org.jboss.tools.seam.internal.core.SeamXmlFactory;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+import org.jboss.tools.seam.internal.core.scanner.ScannerException;
/**
* @author Viacheslav Kabanovich
@@ -74,9 +75,9 @@
* Returns list of components
* @param f
* @return
- * @throws Exception
+ * @throws ScannerException
*/
- public LoadedDeclarations parse(IFile f) throws Exception {
+ public LoadedDeclarations parse(IFile f) throws ScannerException {
XModel model = InnerModelHelper.createXModel(f.getProject());
if(model == null) return null;
XModelObject o = EclipseResourceUtil.getObjectByResource(model, f);