Author: dgolovin
Date: 2008-07-23 20:31:39 -0400 (Wed, 23 Jul 2008)
New Revision: 9257
Added:
trunk/common/plugins/org.jboss.tools.common.text.ext/.ruleset
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/.project
trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/CSSClassHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassMethodHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/HyperlinkDetector.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/HyperlinkPartitionerDefinition.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/JumpToHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/LinkHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/RelativeLinkHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/TLDAttributeNameHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/XModelBasedHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLClassHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLContextParamLinkHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLDoctypeHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLDoctypeHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLElementHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLElementNameHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLJumpToHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLLinkHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLRootHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLTagAttributeValueHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLTextHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlinkPartitioner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/HyperlinkDefinition.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredModelWrapper.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredSelectionHelper.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/TextScanner.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/Utils.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2472:
1. The unnecessary catches for Exception removed;
2. Wide catches for Exception replaced for particular one(s) where it was possible.
3. Logical errors like provided below were fixed where it was obvious:
try {
String fileName = getFilePath(region);
IFile fileToOpen = getFileFromProject(fileName);
if (fileToOpen.exists()) {
IWorkbenchPage workbenchPage =
ExtensionsPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(workbenchPage,fileToOpen,true);
} else {
// thids exception is caught by local catch block
throw new FileNotFoundException((fileToOpen == null ? "" :
fileToOpen.toString()));
}
} catch (Exception x) {
// could not open editor
openFileFailed();
}
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/.project
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/.project 2008-07-23 22:58:18 UTC
(rev 9256)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/.project 2008-07-24 00:31:39 UTC
(rev 9257)
@@ -1,28 +1,34 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.jboss.tools.common.text.ext</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.common.text.ext</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sourceforge.pmd.runtime.pmdBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>net.sourceforge.pmd.runtime.pmdNature</nature>
+ </natures>
+</projectDescription>
Added: trunk/common/plugins/org.jboss.tools.common.text.ext/.ruleset
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/.ruleset
(rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/.ruleset 2008-07-24 00:31:39 UTC
(rev 9257)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset
xmlns="http://pmd.sf.net/ruleset/1.0.0" name=""
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema....
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd">
+<description></description>
+<rule class="net.sourceforge.pmd.rules.XPathRule" dfa="false"
externalInfoUrl="" message="Exception catch is too generic"
name="Avoid Catching Excetpion" typeResolution="true">
+<description></description>
+<priority>1</priority>
+<properties>
+<property name="xpath">
+<value><![CDATA[//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='Exception']]]></value>
+</property>
+</properties>
+<example></example>
+<example></example>
+<example></example>
+</rule>
+</ruleset>
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2008-07-23
22:58:18 UTC (rev 9256)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/META-INF/MANIFEST.MF 2008-07-24
00:31:39 UTC (rev 9257)
@@ -14,7 +14,7 @@
Bundle-ManifestVersion: 2
Bundle-Vendor: %providerName
Plugin-Class: org.jboss.tools.common.text.ext.ExtensionsPlugin
-Bundle-SymbolicName: org.jboss.tools.common.text.ext; singleton:=true
+Bundle-SymbolicName: org.jboss.tools.common.text.ext;singleton:=true
Bundle-Localization: plugin
Require-Bundle: org.jboss.tools.common,
org.jboss.tools.common.model,
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -59,9 +59,6 @@
try {
smw.init(getDocument());
return smw.getFile();
- } catch (Exception t) {
- // ignore
- return null;
} finally {
smw.dispose();
}
@@ -72,9 +69,6 @@
try {
smw.init(getDocument());
return smw.getXModel();
- } catch (Exception t) {
- // ignore
- return null;
} finally {
smw.dispose();
}
@@ -111,26 +105,23 @@
}
public static IFile getFile(IStructuredModel structuredModel) {
- if (structuredModel == null)
+ if (structuredModel == null) {
return null;
+ }
String wsRelativePath = structuredModel.getBaseLocation();
- if (wsRelativePath == null)
+ if (wsRelativePath == null) {
return null;
- try {
- if (wsRelativePath.startsWith("/")) {
- IPath path = new Path(wsRelativePath);
- IResource r = ModelPlugin.getWorkspace().getRoot().findMember(
- path);
- if (r.exists() && r instanceof IFile)
- return (IFile) r;
- }
- String path = Platform.getLocation().append(wsRelativePath)
- .toFile().getAbsolutePath();
- return EclipseResourceUtil.getFile(path);
- } catch (Exception e) {
- //ignore
- return null;
}
+ if (wsRelativePath.startsWith("/")) {
+ IPath path = new Path(wsRelativePath);
+ IResource r = ModelPlugin.getWorkspace().getRoot().findMember(
+ path);
+ if (r.exists() && r instanceof IFile)
+ return (IFile) r;
+ }
+ String path = Platform.getLocation().append(wsRelativePath)
+ .toFile().getAbsolutePath();
+ return EclipseResourceUtil.getFile(path);
}
abstract protected IRegion doGetHyperlinkRegion(int offset);
@@ -142,107 +133,95 @@
if(documentFile == null || !documentFile.isAccessible()) return null;
IProject project = documentFile.getProject();
- try {
- String name = Utils.trimFilePath(fileName);
- IPath currentPath = documentFile.getLocation()
- .removeLastSegments(1);
- IResource member = null;
- StructureEdit se = StructureEdit.getStructureEditForRead(project);
- if (se == null) {
- return null;
- }
- WorkbenchComponent[] modules = se.getWorkbenchModules();
- for (int i = 0; i < modules.length; i++) {
- if (name.startsWith("/")) {
- member = findFileByAbsolutePath(project, modules[i], name);
- } else {
- member = findFileByRelativePath(project, modules[i],
- currentPath, name);
- if (member == null && name.length() > 0) {
- // in some cases path having no leading "/" is
- // nevertheless absolute
- member = findFileByAbsolutePath(project, modules[i],
- "/" + name);
- }
+ String name = Utils.trimFilePath(fileName);
+ IPath currentPath = documentFile.getLocation()
+ .removeLastSegments(1);
+ IResource member = null;
+ StructureEdit se = StructureEdit.getStructureEditForRead(project);
+ if (se == null) {
+ return null;
+ }
+ WorkbenchComponent[] modules = se.getWorkbenchModules();
+ for (int i = 0; i < modules.length; i++) {
+ if (name.startsWith("/")) {
+ member = findFileByAbsolutePath(project, modules[i], name);
+ } else {
+ member = findFileByRelativePath(project, modules[i],
+ currentPath, name);
+ if (member == null && name.length() > 0) {
+ // in some cases path having no leading "/" is
+ // nevertheless absolute
+ member = findFileByAbsolutePath(project, modules[i],
+ "/" + name);
}
- if (member != null) {
- if (((IFile) member).exists())
- return (IFile) member;
- }
}
- } catch (Exception x) {
- //ignore
+ if (member != null) {
+ if (((IFile) member).exists())
+ return (IFile) member;
+ }
}
return null;
}
private IFile findFileByRelativePath(IProject project,
WorkbenchComponent module, IPath basePath, String path) {
- try {
- ComponentResource[] resources = module.findResourcesBySourcePath(
- new Path("/"), 0);
- IPath projectPath = project.getLocation();
- IResource member = null;
+ ComponentResource[] resources = module.findResourcesBySourcePath(
+ new Path("/"), 0);
+ IPath projectPath = project.getLocation();
+ IResource member = null;
- for (int i = 0; resources != null && i < resources.length; i++) {
- IPath runtimePath = resources[i].getRuntimePath();
- IPath sourcePath = resources[i].getSourcePath();
+ for (int i = 0; resources != null && i < resources.length; i++) {
+ IPath runtimePath = resources[i].getRuntimePath();
+ IPath sourcePath = resources[i].getSourcePath();
- // Look in source environment
- IPath webRootPath = projectPath.append(sourcePath);
- IPath relativePath = Utils.getRelativePath(webRootPath,
- basePath);
- IPath filePath = relativePath.append(path);
- member = project.getFolder(sourcePath).findMember(filePath);
- if (member != null) {
- if (((IFile) member).exists())
- return (IFile) member;
- }
+ // Look in source environment
+ IPath webRootPath = projectPath.append(sourcePath);
+ IPath relativePath = Utils.getRelativePath(webRootPath,
+ basePath);
+ IPath filePath = relativePath.append(path);
+ member = project.getFolder(sourcePath).findMember(filePath);
+ if (member != null) {
+ if (((IFile) member).exists())
+ return (IFile) member;
+ }
- // Look in runtime environment
- webRootPath = projectPath.append(runtimePath);
- relativePath = Utils.getRelativePath(webRootPath, basePath);
- filePath = relativePath.append(path);
- member = project.getFolder(runtimePath).findMember(filePath);
- if (member != null) {
- if (((IFile) member).exists())
- return (IFile) member;
- }
+ // Look in runtime environment
+ webRootPath = projectPath.append(runtimePath);
+ relativePath = Utils.getRelativePath(webRootPath, basePath);
+ filePath = relativePath.append(path);
+ member = project.getFolder(runtimePath).findMember(filePath);
+ if (member != null) {
+ if (((IFile) member).exists())
+ return (IFile) member;
}
- } catch (Exception x) {
- //ignore
}
return null;
}
private IFile findFileByAbsolutePath(IProject project,
- WorkbenchComponent module, String path) {
- try {
- ComponentResource[] resources = module.findResourcesBySourcePath(
- new Path("/"), 0);
+ WorkbenchComponent module, String path) {
+ ComponentResource[] resources = module.findResourcesBySourcePath(
+ new Path("/"), 0);
// IPath projectPath = project.getLocation();
- IResource member = null;
+ IResource member = null;
- for (int i = 0; resources != null && i < resources.length; i++) {
- IPath runtimePath = resources[i].getRuntimePath();
- IPath sourcePath = resources[i].getSourcePath();
+ for (int i = 0; resources != null && i < resources.length; i++) {
+ IPath runtimePath = resources[i].getRuntimePath();
+ IPath sourcePath = resources[i].getSourcePath();
- // Look in source environment
- member = project.getFolder(sourcePath).findMember(path);
- if (member != null) {
- if (((IFile) member).exists())
- return (IFile) member;
- }
+ // Look in source environment
+ member = project.getFolder(sourcePath).findMember(path);
+ if (member != null) {
+ if (((IFile) member).exists())
+ return (IFile) member;
+ }
- // Look in runtime environment
- member = project.getFolder(runtimePath).findMember(path);
- if (member != null) {
- if (((IFile) member).exists())
- return (IFile) member;
- }
+ // Look in runtime environment
+ member = project.getFolder(runtimePath).findMember(path);
+ if (member != null) {
+ if (((IFile) member).exists())
+ return (IFile) member;
}
- } catch (Exception x) {
- //ignore
}
return null;
}
@@ -266,8 +245,7 @@
f.setParent(root);
JarEntryEditorInput jarEditorInput = new JarEntryEditorInput(f) {
public boolean equals(Object arg) {
- try {return this.toString().equals(arg.toString());}
- catch (Exception x) {return false;}
+ return this.toString().equals(arg.toString());
}
};
return jarEditorInput;
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/AbstractHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -13,7 +13,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.IExtension;
import org.eclipse.jface.text.IDocument;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
@@ -125,9 +124,6 @@
return Utils.getParentAxisForNode(xmlDocument, attr) + attr.getName() +
"/";
}
return Utils.getParentAxisForNode(xmlDocument, node);
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/CSSClassHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/CSSClassHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/CSSClassHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink;
+import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.text.MessageFormat;
@@ -19,12 +20,14 @@
import org.eclipse.core.resources.IFile;
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.core.runtime.QualifiedName;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.ui.IEditorPart;
@@ -85,7 +88,7 @@
openFileFailed();
}
- } catch (Exception x) {
+ } catch (CoreException x) {
// could not open editor
openFileFailed();
}
@@ -94,7 +97,7 @@
private String getStyleName(IRegion region) {
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
}
@@ -120,7 +123,7 @@
if(file != null && file.exists()) return file;
}
return null;
- } catch (Exception x) {
+ } catch (CoreException x) {
//ignore
return null;
}
@@ -195,7 +198,7 @@
}
return null;
- } catch (Exception x) {
+ } catch (CoreException x) {
//ignore
return null;
} finally {
@@ -247,14 +250,8 @@
token = scanner.nextToken();
}
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error while looking for style region
" + styleName, x);
} finally {
- try {
reader.close();
- } catch (Exception x) {
- //ignore
- }
}
return null;
}
@@ -294,12 +291,12 @@
token = scanner.nextToken();
}
- } catch (Exception x) {
+ } catch (CoreException x) {
ExtensionsPlugin.getPluginLog().logError("Error while looking for style region
", x);
} finally {
try {
stream.close();
- } catch (Exception x) {
+ } catch (IOException x) {
//ignore
}
}
@@ -308,9 +305,7 @@
private List<Node> findStyleLinks (NodeList list) {
List<Node> styleLinks = new ArrayList<Node>();
- try {
for (int i = 0; list != null && i < list.getLength(); i++) {
- try {
IDOMElement element = (IDOMElement)list.item(i);
String axis = JSPRootHyperlinkPartitioner.computeAxis(getDocument(),
element.getStartOffset());
axis = axis.toLowerCase();
@@ -338,16 +333,8 @@
if (add != null)
styleLinks.addAll(add);
}
- } catch (Exception x) {
- // Probably not an XMLElement
- //ignore
- }
}
return styleLinks;
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error while looking for style
links", x);
- return null;
- }
}
protected IRegion getRegion (int offset) {
@@ -419,7 +406,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -34,6 +34,7 @@
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
import org.eclipse.jdt.internal.core.SourceType;
import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -72,7 +73,7 @@
// could not open editor
openFileFailed();
}
- } catch (Exception x) {
+ } catch (CoreException x) {
// could not open editor
openFileFailed();
}
@@ -81,7 +82,7 @@
private String getClassName(IRegion region) {
try {
return getDocument().get(region.getOffset(), region.getLength());
- } catch (Exception x) {
+ } catch (BadLocationException x) {
return null;
} finally {
}
@@ -122,23 +123,18 @@
}
private String getQualifiedClassName(IJavaElement element) {
- try {
- String classQualifiedName = null;
- if (element instanceof SourceType || element instanceof BinaryType ) {
- classQualifiedName = element.getElementName();
+ String classQualifiedName = null;
+ if (element instanceof SourceType || element instanceof BinaryType ) {
+ classQualifiedName = element.getElementName();
+ }
+ while ( element != null && !(element instanceof PackageFragmentRoot)) {
+ element = element.getParent();
+ if (element instanceof PackageFragment) {
+ classQualifiedName = element.getElementName() + "." + classQualifiedName;
}
- while ( element != null && !(element instanceof PackageFragmentRoot)) {
- element = element.getParent();
- if (element instanceof PackageFragment) {
- classQualifiedName = element.getElementName() + "." + classQualifiedName;
- }
- }
-
- return classQualifiedName;
- } catch (Exception x) {
- //ignore
- return null;
}
+
+ return classQualifiedName;
}
private IJavaElement searchForClass(String className) {
@@ -168,7 +164,7 @@
IJavaProject javaProject = JavaCore.create(project);
return searchForClass(javaProject, className);
- } catch (Exception x) {
+ } catch (CoreException x) {
ExtensionsPlugin.getPluginLog().logError("Error while looking for class " +
className, x);
return null;
}
@@ -269,7 +265,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassMethodHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassMethodHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/ClassMethodHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -29,6 +29,7 @@
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -77,7 +78,7 @@
} else {
openFileFailed();
}
- } catch (Exception x) {
+ } catch (CoreException x) {
openFileFailed();
}
}
@@ -129,7 +130,7 @@
if (propStart > offset || propStart + propLength < offset) return null;
IRegion region = new HyperlinkRegion(propStart, propLength);
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
@@ -195,7 +196,7 @@
IJavaProject javaProject = JavaCore.create(project);
return searchForClassMethod(javaProject, className, methodName);
- } catch (Exception x) {
+ } catch (CoreException x) {
ExtensionsPlugin.getPluginLog().logError("Error while looking for method " +
methodName + " of class " + className, x);
return null;
}
@@ -206,7 +207,7 @@
try {
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(getDocument(), attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
}
@@ -228,7 +229,7 @@
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(getDocument(), attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/HyperlinkDetector.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/HyperlinkDetector.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/HyperlinkDetector.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -33,13 +33,11 @@
protected String[] getPartitionTypes(IDocument document, int offset) {
String documentRegionType = null;
ITypedRegion region = null;
- try {
+
region = (document instanceof IDocumentExtension3 ?
((IDocumentExtension3)document).getDocumentPartitioner("org.eclipse.wst.sse.core.default_structured_text_partitioning").getPartition(offset)
:
document.getDocumentPartitioner().getPartition(offset));
- } catch (Exception x) {
- //ignore
- }
+
if (region != null) {
documentRegionType = region.getType();
} else {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/HyperlinkPartitionerDefinition.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/HyperlinkPartitionerDefinition.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/HyperlinkPartitionerDefinition.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -132,7 +132,7 @@
public void run() {
try {
result[0] = element.createExecutableExtension(name);
- } catch (Exception e) {
+ } catch (CoreException e) {
handleCreateExecutableException(result, e);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/JumpToHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/JumpToHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/JumpToHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -13,11 +13,11 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.xml.XMLRootHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.RegionHolder;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
@@ -39,7 +39,6 @@
*/
protected void doHyperlink(IRegion region) {
- try {
RegionHolder holder = getRegionHolder(getName(region), region);
if (holder != null) {
StructuredSelectionHelper.setSelectionAndRevealInActiveEditor(holder.region);
@@ -47,16 +46,12 @@
openFileFailed();
}
- } catch (Exception x) {
- // could not open editor
- openFileFailed();
- }
}
protected String getName(IRegion region) {
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
}
@@ -74,9 +69,6 @@
if (xmlDocument == null) return null;
return xmlDocument.getChildNodes();
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -104,16 +96,12 @@
}
}
return null;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
}
protected String getElementText(Node element) {
- try {
if (element instanceof IDOMText)
return ((IDOMText)element).getData();
@@ -130,18 +118,13 @@
String result = text.toString();
if (result == null || result.length() == 0) return null;
return result;
- } catch (Exception x) {
- //ignore
- return null;
- }
+
}
protected List<Node> findElementsByAxis (NodeList list, String axis) {
String requiredAxis = axis.toLowerCase();
List<Node> elements = new ArrayList<Node>();
- try {
for (int i = 0; list != null && i < list.getLength(); i++) {
- try {
IDOMElement element = (IDOMElement)list.item(i);
String currentAxis = XMLRootHyperlinkPartitioner.computeAxis(getDocument(),
element.getStartOffset()) + "/";
currentAxis = currentAxis.toLowerCase();
@@ -155,28 +138,16 @@
if (add != null)
elements.addAll(add);
}
- } catch (Exception x) {
- // Probably not an XMLElement
- //ignore
- }
+
}
return elements;
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in looking elements for axis
" + axis, x);
- return null;
- }
}
/**
* @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
*/
protected IRegion doGetHyperlinkRegion(int offset) {
- try {
return getRegion(offset);
- } catch (Exception x) {
- //ignore
- return null;
- }
}
protected IRegion getRegion(int offset) {
@@ -236,15 +207,13 @@
return true;
}
};
-
return region;
- } catch (Exception x) {
- //ignore
- return null;
+ } catch (BadLocationException e) {
+ openFileFailed();
} finally {
smw.dispose();
}
-
+ return null;
}
/*
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/LinkHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/LinkHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/LinkHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,11 +10,12 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink;
-import java.io.FileNotFoundException;
import java.text.MessageFormat;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.ide.IDE;
@@ -44,9 +45,9 @@
IWorkbenchPage workbenchPage =
ExtensionsPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(workbenchPage,fileToOpen,true);
} else {
- throw new FileNotFoundException((fileToOpen == null ? "" :
fileToOpen.toString()));
+ openFileFailed();
}
- } catch (Exception x) {
+ } catch (CoreException x) {
// could not open editor
openFileFailed();
}
@@ -55,11 +56,10 @@
private String getFilePath(IRegion region) {
try {
return getDocument().get(region.getOffset(), region.getLength());
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
- } finally {
- }
+ }
}
protected String updateFilenameForModel(String filename, IProject project) {
@@ -129,7 +129,7 @@
if (propStart > offset + 1 || propStart + propLength < offset) return null;
IRegion region = new HyperlinkRegion(propStart, propLength);
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/RelativeLinkHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/RelativeLinkHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/RelativeLinkHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,11 +10,12 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink;
-import java.io.FileNotFoundException;
import java.text.MessageFormat;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.ide.IDE;
@@ -36,7 +37,6 @@
* @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
*/
protected void doHyperlink(IRegion region) {
-
try {
String fileName = getFilePath(region);
IFile fileToOpen = getFileFromProject(fileName);
@@ -44,9 +44,9 @@
IWorkbenchPage workbenchPage =
ExtensionsPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(workbenchPage,fileToOpen,true);
} else {
- throw new FileNotFoundException((fileToOpen == null ? "" :
fileToOpen.toString()));
+ openFileFailed();
}
- } catch (Exception x) {
+ } catch (CoreException x) {
// could not open editor
openFileFailed();
}
@@ -55,11 +55,10 @@
private String getFilePath(IRegion region) {
try {
return getDocument().get(region.getOffset(), region.getLength());
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
- } finally {
- }
+ }
}
protected String updateFilenameForModel(String filename, IProject project) {
@@ -69,13 +68,8 @@
protected IFile getFileFromProject(String fileName) {
IFile documentFile = getFile();
- try {
IProject project = documentFile.getProject();
return super.getFileFromProject(updateFilenameForModel(fileName, project));
- } catch (Exception x) {
- //ignore
- return null;
- }
}
IRegion fLastRegion = null;
@@ -153,7 +147,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/TLDAttributeNameHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/TLDAttributeNameHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/TLDAttributeNameHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -52,38 +52,29 @@
return null;
return tagElement.getChildNodes();
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
}
private boolean validAxis(Node n, String validAxisEnding) {
- try {
- if (validAxisEnding == null || validAxisEnding.lastIndexOf('/') == -1) return
false;
- StringTokenizer st = new StringTokenizer(validAxisEnding, "/");
- List<String> tokens = new ArrayList<String>();
- while (st.hasMoreTokens()) {
- tokens.add(st.nextToken());
- }
- if (tokens.size() == 0) return false;
- Node currentElement = n;
- for (int i = tokens.size() - 1; i >= 0; i--) {
- if (currentElement == null || !(currentElement instanceof Element))
- return false;
- String token = (String)tokens.get(i);
- if (!token.equals(currentElement.getNodeName()))
- return false;
- currentElement = currentElement.getParentNode();
- }
- return true;
-
- } catch (Exception x) {
- //ignore
- return false;
+ if (validAxisEnding == null || validAxisEnding.lastIndexOf('/') == -1) return
false;
+ StringTokenizer st = new StringTokenizer(validAxisEnding, "/");
+ List<String> tokens = new ArrayList<String>();
+ while (st.hasMoreTokens()) {
+ tokens.add(st.nextToken());
}
+ if (tokens.size() == 0) return false;
+ Node currentElement = n;
+ for (int i = tokens.size() - 1; i >= 0; i--) {
+ if (currentElement == null || !(currentElement instanceof Element))
+ return false;
+ String token = (String)tokens.get(i);
+ if (!token.equals(currentElement.getNodeName()))
+ return false;
+ currentElement = currentElement.getParentNode();
+ }
+ return true;
}
/*
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/XModelBasedHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/XModelBasedHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/XModelBasedHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -14,6 +14,7 @@
import java.util.Properties;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.project.IPromptingProvider;
@@ -38,7 +39,6 @@
XModel xModel = getXModel(documentFile);
if (xModel == null) return;
- try {
IPromptingProvider provider = PromptingProviderFactory.WEB;
Properties p = getRequestProperties(region);
@@ -53,9 +53,6 @@
if ( error != null && error.length() > 0) {
openFileFailed();
}
- } catch (Exception x) {
- openFileFailed();
- }
}
protected abstract String getRequestMethod();
@@ -133,7 +130,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -12,11 +12,12 @@
import java.text.MessageFormat;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.IEditorPart;
-import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.ClassMethodHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
@@ -91,7 +92,7 @@
} else {
openFileFailed();
}
- } catch (Exception x) {
+ } catch (CoreException x) {
openFileFailed();
}
}
@@ -113,9 +114,6 @@
element = findElementByIDBackward(xmlDocument.getChildNodes(), id, endOffset,
tagname);
}
return element;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -130,7 +128,6 @@
for (int i = list.getLength() - 1; list != null && i >= 0; i--) {
if(!(list.item(i) instanceof Element)) continue;
- try {
Element element = (Element)list.item(i);
int start = Utils.getValueStart(element);
if (start < 0 || start >= endOffset) continue;
@@ -151,13 +148,8 @@
Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
tagName);
if (child != null) return child;
}
- } catch (Exception x) {
- // Probably not an XMLElement
- //ignore
- }
+
}
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in finding element by id " +
id, x);
} finally {
smw.dispose();
}
@@ -167,7 +159,7 @@
String getPropertyName(IRegion region) {
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
}
@@ -187,9 +179,6 @@
Node node = ((Attr)n).getOwnerElement();
return getAttributeValue(node, NAME_ATTRNAME);
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -53,9 +53,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -87,9 +84,6 @@
return false;
return true;
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -51,9 +51,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -85,9 +82,6 @@
return false;
return true;
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink.jsp;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -50,9 +51,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -107,7 +105,7 @@
IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null,
null);
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -39,14 +39,11 @@
*/
protected void doHyperlink(IRegion region) {
- try {
- XModelObject object = getFilename(region);
- if(object != null) FindObjectHelper.findModelObject(object,
FindObjectHelper.IN_EDITOR_ONLY);
-
- } catch (Exception x) {
- // could not open editor
- openFileFailed();
+ XModelObject object = getFilename(region);
+ if(object != null) {
+ FindObjectHelper.findModelObject(object, FindObjectHelper.IN_EDITOR_ONLY);
}
+
}
protected final String JAR_FILE_PROTOCOL = "jar:file:/";//$NON-NLS-1$
@@ -93,15 +90,8 @@
ITaglibMapping tm = wp.getTaglibMapping();
if (tm == null) return null;
- try {
- tm.invalidate();
- } catch (Exception x) {
- //ignore
- }
+ tm.invalidate();
return tm.getTaglibObject(uri);
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in getting file name from
region", x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -57,9 +57,6 @@
Map trackers = JSPRootHyperlinkPartitioner.getTrackersMap(document,
region.getOffset());
return (trackers != null && trackers.containsKey(nodePrefix));
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -12,9 +12,9 @@
import java.text.MessageFormat;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
@@ -39,7 +39,6 @@
*/
protected void doHyperlink(IRegion region) {
- try {
String forID = getForId(region);
IRegion elementByID = findElementByIDBackward(forID, region.getOffset(),
USEBEAN_TAGNAME);
if (elementByID != null) {
@@ -47,9 +46,6 @@
} else {
openFileFailed();
}
- } catch (Exception x) {
- openFileFailed();
- }
}
private IRegion findElementByIDBackward (String id, int endOffset, String tagname) {
@@ -96,9 +92,6 @@
return "IRegion [" + getOffset() +", " + getLength()+
"]";
}
};
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -113,7 +106,6 @@
for (int i = list.getLength() - 1; list != null && i >= 0; i--) {
if(!(list.item(i) instanceof Element)) continue;
- try {
Element element = (Element)list.item(i);
int start = Utils.getValueStart(element);
if (start < 0 || start >= endOffset) continue;
@@ -134,14 +126,7 @@
Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
tagName);
if (child != null) return child;
}
- } catch (Exception x) {
- // Probably not an XMLElement
- //ignore
- }
}
- } catch (Exception x) {
- Exception e = x instanceof Exception ? (Exception)x : new Exception(x);
- ExtensionsPlugin.getPluginLog().logError(e);
} finally {
smw.dispose();
}
@@ -152,7 +137,7 @@
String getForId(IRegion region) {
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
}
@@ -232,7 +217,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink.jsp;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -50,9 +51,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -107,7 +105,7 @@
IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null,
null);
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -19,13 +19,6 @@
import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
@@ -36,6 +29,11 @@
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.tld.ITaglibMapping;
import org.jboss.tools.jst.web.tld.WebProjectFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -100,7 +98,6 @@
public static String extractName (String name, Map trackersMap, ITaglibMapping tm) {
if (trackersMap == null || trackersMap.size() == 0) return name;
if (name == null) return null;
- try {
int column = name.indexOf(":");
if (column == -1) return name;
String prefix = name.substring(0, column);
@@ -112,10 +109,6 @@
String resolvedUri = (tm == null ? uri : tm.resolveURI(uri));
return "[" + resolvedUri + "]" + name.substring(column);
- } catch (Exception x) {
- //ignore
- return name;
- }
}
public static Map getTrackersMap(IDocument document, int offset) {
@@ -144,10 +137,6 @@
map = addAlternativeTrackersMap(map, document, offset);
return map;
- } catch (Exception x) {
- //ignore
- //TODO narrow catch after study
- return null;
} finally {
smw.dispose();
}
@@ -189,9 +178,6 @@
}
return map;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -212,9 +198,6 @@
if (n == null) return false;
return true;
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -20,7 +20,6 @@
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.FindObjectHelper;
-import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
@@ -42,14 +41,8 @@
* @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
*/
protected void doHyperlink(IRegion region) {
-
- try {
XModelObject object = getFilename(region);
if(object != null) FindObjectHelper.findModelObject(object,
FindObjectHelper.IN_EDITOR_ONLY);
- } catch (Exception x) {
- // could not open editor
- openFileFailed();
- }
}
protected final String JAR_FILE_PROTOCOL = "jar:file:/";//$NON-NLS-1$
@@ -58,7 +51,6 @@
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlink#openFileInEditor(java.lang.String)
*/
protected void openFileInEditor(String fileString) {
- try {
if (fileString.startsWith(JAR_FILE_PROTOCOL)) {
fileString = fileString.substring(JAR_FILE_PROTOCOL.length());
IEditorInput jarEditorInput = createEditorInput(fileString);
@@ -67,9 +59,6 @@
} else {
super.openFileInEditor(fileString);
}
- } catch (Exception x) {
- openFileFailed();
- }
}
private XModelObject getFilename(IRegion region) {
@@ -99,9 +88,6 @@
ITaglibMapping tm = wp.getTaglibMapping();
if (tm == null) return null;
return tm.getTaglibObject(uri);
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in obtaining file name from
region", x);
- return null;
} finally {
smw.dispose();
}
@@ -129,9 +115,6 @@
if (uri == null || uri.trim().length() == 0) return null;
return uri;
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in obtaining file name from
region", x);
- return null;
} finally {
smw.dispose();
}
@@ -185,9 +168,6 @@
};
return region;
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in obtaining region", x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -12,18 +12,16 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -56,9 +54,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in parsing region", x);
- return null;
} finally {
smw.dispose();
}
@@ -82,9 +77,6 @@
Element rootElem = xmlnsAttr.getOwnerElement();
if (!(rootElem.getNodeName().equals("jsp:root") ||
rootElem.getNodeName().equalsIgnoreCase("html"))) return false;
return true;
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLClassHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLClassHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLClassHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink.xml;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -51,9 +52,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -99,7 +97,7 @@
IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null,
null);
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLContextParamLinkHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLContextParamLinkHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLContextParamLinkHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink.xml;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Document;
@@ -51,9 +52,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -121,7 +119,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLDoctypeHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLDoctypeHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLDoctypeHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,17 +10,16 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink.xml;
-import org.eclipse.jdt.internal.core.ModelUpdater;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
+import org.jboss.tools.common.text.ext.ExtensionsPlugin;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.Utils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Node;
-import org.jboss.tools.common.text.ext.ExtensionsPlugin;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.common.text.ext.util.Utils;
-
public class XMLDoctypeHyperlink extends XMLXmlNsHyperlink {
protected IRegion getRegion(int offset) {
@@ -44,7 +43,7 @@
String text = "";
try {
text = getDocument().get(start, end - start);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
ExtensionsPlugin.getPluginLog().logError(x);
};
String publicId = (node.getPublicId() == null ? "" : node.getPublicId());
@@ -100,9 +99,6 @@
}
};
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -123,13 +119,9 @@
DocumentType node = (DocumentType)n;
return node.getPublicId();
- } catch (Exception x) {
- //ignore
} finally {
smw.dispose();
}
-
- return null;
}
protected String getSystemId(IRegion region) {
@@ -146,13 +138,9 @@
DocumentType node = (DocumentType)n;
return node.getSystemId();
- } catch (Exception x) {
- //ignore
} finally {
smw.dispose();
}
-
- return null;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLDoctypeHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLDoctypeHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLDoctypeHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -54,9 +54,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -74,9 +71,6 @@
return "/@DOCTYPE/" + node.getNodeName() + "/";
}
return Utils.getParentAxisForNode(xmlDocument, node);
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -96,9 +90,6 @@
if (!(n instanceof DocumentType)) return false;
return true;
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLElementHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLElementHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLElementHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -56,9 +56,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -78,9 +75,6 @@
if (!(n instanceof Attr || n instanceof Element)) return false;
return true;
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLElementNameHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLElementNameHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLElementNameHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -12,16 +12,14 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -52,9 +50,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error while parsing region", x);
- return null;
} finally {
smw.dispose();
}
@@ -80,9 +75,6 @@
IHyperlinkRegion region = new HyperlinkRegion(nameStart, nameEnd - nameStart, null,
null, null);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -108,9 +100,6 @@
int nameStart = start + (elem.isEndTag() ? "<" :
"</").length();
int nameEnd = nameStart + tagName.length();
return (region.getOffset() > nameStart && region.getOffset() <=
nameEnd);
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLJumpToHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLJumpToHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLJumpToHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -14,6 +14,7 @@
import java.util.List;
import java.util.StringTokenizer;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Document;
@@ -61,9 +62,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -129,7 +127,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
@@ -143,7 +141,6 @@
}
private boolean validAxis(Node n, String validAxisEnding) {
- try {
if (validAxisEnding == null || validAxisEnding.lastIndexOf('/') == -1) return
false;
StringTokenizer st = new StringTokenizer(validAxisEnding, "/");
List<String> tokens = new ArrayList<String>();
@@ -161,11 +158,6 @@
currentElement = currentElement.getParentNode();
}
return true;
-
- } catch (Exception x) {
- //ignore
- return false;
- }
}
/**
@@ -189,9 +181,6 @@
return true;
}
return false;
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLLinkHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLLinkHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLLinkHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink.xml;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
@@ -51,8 +52,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- return null;
} finally {
smw.dispose();
}
@@ -129,7 +128,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
return null;
} finally {
smw.dispose();
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLRootHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLRootHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLRootHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -14,18 +14,16 @@
import java.util.Map;
import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -76,8 +74,6 @@
parent = parent.getParentNode();
}
}
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError(x);
} finally {
smw.dispose();
}
@@ -89,19 +85,15 @@
public static String extractName (String name, Map trackersMap) {
if (trackersMap == null || trackersMap.size() == 0) return name;
if (name == null) return null;
- try {
- int column = name.indexOf(":");
- if (column == -1) return name;
- String prefix = name.substring(0, column);
- if (prefix == null || prefix.trim().length() == 0) return name;
-
- String uri = (String)trackersMap.get(prefix);
- if (uri == null || uri.length() == 0) return name;
-
- return "[" + uri + "]" + name.substring(column);
- } catch (Exception x) {
- return name;
- }
+ int column = name.indexOf(":");
+ if (column == -1) return name;
+ String prefix = name.substring(0, column);
+ if (prefix == null || prefix.trim().length() == 0) return name;
+
+ String uri = (String)trackersMap.get(prefix);
+ if (uri == null || uri.length() == 0) return name;
+
+ return "[" + uri + "]" + name.substring(column);
}
/**
@@ -117,8 +109,6 @@
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
return n != null;
- } catch (Exception x) {
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLTagAttributeValueHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLTagAttributeValueHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLTagAttributeValueHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.text.ext.hyperlink.xml;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
@@ -48,9 +49,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -116,7 +114,7 @@
}
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
//ignore
return null;
} finally {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLTextHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLTextHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLTextHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -53,9 +53,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- //ignore
- return null;
} finally {
smw.dispose();
}
@@ -73,9 +70,6 @@
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
return (n != null && n instanceof Text);
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlink.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlink.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -12,8 +12,10 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.StringTokenizer;
@@ -25,6 +27,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.pde.internal.ui.editor.JarEntryEditorInput;
import org.eclipse.pde.internal.ui.editor.JarEntryFile;
@@ -107,7 +110,7 @@
public InputStream getContents() throws CoreException {
try {
return new FileInputStream(fFile);
- } catch (Exception x) {
+ } catch (FileNotFoundException x) {
//ignore
return null;
}
@@ -155,22 +158,19 @@
String uri = getURI(region);
if (uri != null && uri.toLowerCase().startsWith("http:")) {
URL url = null;
- try {
- url = new URL(uri);
- IWorkbenchBrowserSupport browserSupport =
PlatformUI.getWorkbench().getBrowserSupport();
- IWebBrowser browser =
browserSupport.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR |
IWorkbenchBrowserSupport.NAVIGATION_BAR, null, null, null);
- browser.openURL(url);
- } catch (Exception e) {
- openFileFailed();
- }
-
- } else
+ url = new URL(uri);
+ IWorkbenchBrowserSupport browserSupport =
PlatformUI.getWorkbench().getBrowserSupport();
+ IWebBrowser browser =
browserSupport.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR |
IWorkbenchBrowserSupport.NAVIGATION_BAR, null, null, null);
+ browser.openURL(url);
+ } else {
openFileFailed();
+ }
}
-
- } catch (Exception x) {
+ } catch (MalformedURLException x) {
// could not open editor
openFileFailed();
+ } catch (PartInitException x) {
+ openFileFailed();
}
}
@@ -207,23 +207,19 @@
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlink#openFileInEditor(java.lang.String)
*/
protected void openFileInEditor(String fileString) {
- try {
- if (fileString.startsWith(JAR_FILE_PROTOCOL)) {
- fileString = fileString.substring(JAR_FILE_PROTOCOL.length());
- IEditorInput jarEditorInput = createEditorInput(fileString);
+ if (fileString.startsWith(JAR_FILE_PROTOCOL)) {
+ fileString = fileString.substring(JAR_FILE_PROTOCOL.length());
+ IEditorInput jarEditorInput = createEditorInput(fileString);
+ IEditorPart part = openFileInEditor(jarEditorInput, fileString);
+ if (part == null) openFileFailed();
+ } else if (fileString.startsWith(JAR_FILE)) {
+ fileString = fileString.substring(JAR_FILE.length());
+ IEditorInput jarEditorInput = createEditorInputAlternate(fileString);
IEditorPart part = openFileInEditor(jarEditorInput, fileString);
if (part == null) openFileFailed();
- } else if (fileString.startsWith(JAR_FILE)) {
- fileString = fileString.substring(JAR_FILE.length());
- IEditorInput jarEditorInput = createEditorInputAlternate(fileString);
- IEditorPart part = openFileInEditor(jarEditorInput, fileString);
- if (part == null) openFileFailed();
- } else {
- super.openFileInEditor(fileString);
- }
- } catch (Exception x) {
- openFileFailed();
- }
+ } else {
+ super.openFileInEditor(fileString);
+ }
}
protected IEditorInput createEditorInputAlternate(String fileString) {
@@ -240,8 +236,7 @@
JarEntryEditorInput jarEditorInput = new JarEntryEditorInput(jarEntryFile) {
public boolean equals(Object arg) {
- try {return this.toString().equals(arg.toString());}
- catch (Exception x) {return false;}
+ return this.toString().equals(arg.toString());
}
};
return jarEditorInput;
@@ -250,38 +245,28 @@
String getURI(IRegion region) {
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
- //ignore
+ } catch (BadLocationException x) {
return null;
}
+
}
protected String getPublicId(IRegion region) {
- try {
- String text = getURI(region);
- if (text == null) return null;
- int spacer = text.indexOf(" ");
- if (spacer == -1) spacer = text.indexOf("\t");
- return (spacer == -1 ? text : text.substring(0, spacer));
- } catch (Exception x) {
- //ignore
- return null;
- }
+ String text = getURI(region);
+ if (text == null) return null;
+ int spacer = text.indexOf(" ");
+ if (spacer == -1) spacer = text.indexOf("\t");
+ return (spacer == -1 ? text : text.substring(0, spacer));
}
protected String getSystemId(IRegion region) {
- try {
- String text = getURI(region);
- if (text == null) return null;
- int spacer = text.indexOf(" ");
- if (spacer == -1) spacer = text.indexOf("\t");
- if (spacer == -1) spacer = 0;
-
- return text.substring(spacer).trim();
- } catch (Exception x) {
- //ignore
- return null;
- }
+ String text = getURI(region);
+ if (text == null) return null;
+ int spacer = text.indexOf(" ");
+ if (spacer == -1) spacer = text.indexOf("\t");
+ if (spacer == -1) spacer = 0;
+
+ return text.substring(spacer).trim();
}
private String getMappedSystemIdFromCatalog(String publicId, String systemId) {
@@ -293,8 +278,8 @@
mappedSystemId =
XMLCorePlugin.getDefault().getDefaultXMLCatalog().resolveSystem(systemId);
if (mappedSystemId == null && systemId != null)
mappedSystemId =
XMLCorePlugin.getDefault().getDefaultXMLCatalog().resolveURI(systemId);
- } catch (Exception e) {
- // Ignore, just return null as result
+ } catch (IOException e) {
+ return null;
}
return mappedSystemId;
}
@@ -308,8 +293,8 @@
fileName = file.getAbsolutePath();
}
}
- } catch (Exception x) {
- //ignore
+ } catch (MalformedURLException x) {
+ return null;
}
return fileName;
}
@@ -386,10 +371,6 @@
};
return region;
-
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error while obtaining region",
x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlinkPartitioner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/XMLXmlNsHyperlinkPartitioner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -11,22 +11,17 @@
package org.jboss.tools.common.text.ext.hyperlink.xml;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -61,9 +56,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error while parsing region", x);
- return null;
} finally {
smw.dispose();
}
@@ -91,9 +83,6 @@
Element rootElement = xmlnsAttr.getOwnerElement();
if(!(rootElement instanceof IDOMElement)) return false;
return true;
- } catch (Exception x) {
- //ignore
- return false;
} finally {
smw.dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/HyperlinkDefinition.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/HyperlinkDefinition.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xpl/HyperlinkDefinition.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -137,8 +137,7 @@
public void run() {
try {
result[0] = element.createExecutableExtension(name);
- }
- catch (Exception e) {
+ } catch (CoreException e) {
handleCreateExecutableException(result, e);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredModelWrapper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredModelWrapper.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredModelWrapper.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -15,7 +15,6 @@
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredSelectionHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredSelectionHelper.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/StructuredSelectionHelper.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -18,8 +18,6 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
-
-import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.jboss.tools.common.text.ext.IEditorWrapper;
import org.jboss.tools.common.text.ext.IMultiPageEditor;
@@ -30,22 +28,13 @@
public class StructuredSelectionHelper {
public static IndexedRegion getSourceElement(StructuredTextEditor editor, int offset) {
- try {
- return editor.getModel().getIndexedRegion(offset);
- } catch (Exception x) {
- return null;
- }
+ return editor.getModel().getIndexedRegion(offset);
}
public static void setSelectionAndRevealInActiveEditor(IRegion region) {
- try {
- setSelectionAndReveal(null, region);
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in setting selection to active
text editor", x);
- }
+ setSelectionAndReveal(null, region);
}
public static StructuredTextEditor getStructuredTextEditor (IEditorPart editorPart) {
- try {
IEditorPart activeEditorPart = editorPart;
if (activeEditorPart == null) {
IWorkbenchPage workbenchPage =
ExtensionsPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
@@ -58,29 +47,22 @@
IEditorWrapper editorPartWraper = (IEditorWrapper)activeEditorPart;
return getStructuredTextEditor(editorPartWraper.getEditor());
} else if (activeEditorPart instanceof StructuredTextEditor) {
- return (StructuredTextEditor)activeEditorPart;
-
+ return (StructuredTextEditor)activeEditorPart;
}
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in obtaining structured text
editor", x);
- }
+
return null;
}
public static void setSelectionAndReveal(IEditorPart editorPart, IRegion region) {
- try {
- StructuredTextEditor sourceEditor = getStructuredTextEditor(editorPart);
- if (sourceEditor == null) {
- if (editorPart instanceof ITextEditor) {
- ((ITextEditor)editorPart).selectAndReveal(region.getOffset(), region.getLength());
- }
- return;
+ StructuredTextEditor sourceEditor = getStructuredTextEditor(editorPart);
+ if (sourceEditor == null) {
+ if (editorPart instanceof ITextEditor) {
+ ((ITextEditor)editorPart).selectAndReveal(region.getOffset(), region.getLength());
}
- ISelectionProvider provider = sourceEditor.getSelectionProvider();
- provider.setSelection(new TextSelection(region.getOffset(), region.getLength()));
- } catch (Exception x) {
- ExtensionsPlugin.getPluginLog().logError("Error in setting selection", x);
+ return;
}
+ ISelectionProvider provider = sourceEditor.getSelectionProvider();
+ provider.setSelection(new TextSelection(region.getOffset(), region.getLength()));
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/TextScanner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/TextScanner.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/TextScanner.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.text.ext.util;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
@@ -129,7 +130,7 @@
} else {
try {
ch = reader.read();
- } catch (Exception x) {
+ } catch (IOException x) {
return ICharacterScanner.EOF;
}
if ( ch == -1 ) return ICharacterScanner.EOF;
@@ -258,7 +259,7 @@
length--;
}
return d.get(0, length);
- } catch (Exception ex) {
+ } catch (BadLocationException ex) {
return text;
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/Utils.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/Utils.java 2008-07-23
22:58:18 UTC (rev 9256)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/util/Utils.java 2008-07-24
00:31:39 UTC (rev 9257)
@@ -19,7 +19,6 @@
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
import org.jboss.tools.common.text.ext.ExtensionsPlugin;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -39,25 +38,20 @@
int bEnd = word.length() - 1;
StringBuffer sb = new StringBuffer(attrText);
- try {
- //find start and end of path property
- while (bStart < bEnd &&
- (sb.charAt(bStart) == '\'' || sb.charAt(bStart) == '\"' ||
- Character.isWhitespace(sb.charAt(bStart)))) {
- bStart++;
- }
- while (bEnd >= 0 &&
- (sb.charAt(bEnd) == '\'' || sb.charAt(bEnd) == '\"' ||
- Character.isWhitespace(sb.charAt(bEnd)))) {
- bEnd--;
- }
- bEnd++;
- if (bEnd < bStart) bEnd = bStart;
- return sb.substring(bStart, bEnd);
- } catch (Exception x) {
- //TODO remove that catch after study safety of code
- return word;
- }
+ //find start and end of path property
+ while (bStart < bEnd &&
+ (sb.charAt(bStart) == '\'' || sb.charAt(bStart) == '\"' ||
+ Character.isWhitespace(sb.charAt(bStart)))) {
+ bStart++;
+ }
+ while (bEnd >= 0 &&
+ (sb.charAt(bEnd) == '\'' || sb.charAt(bEnd) == '\"' ||
+ Character.isWhitespace(sb.charAt(bEnd)))) {
+ bEnd--;
+ }
+ bEnd++;
+ if (bEnd < bStart) bEnd = bStart;
+ return sb.substring(bStart, bEnd);
}
static public Node findNodeForOffset(Node node, int offset) {