Author: scabanovich
Date: 2012-01-06 20:39:07 -0500 (Fri, 06 Jan 2012)
New Revision: 37706
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java
Log:
JBIDE-10601
https://issues.joss.org/browse/JBIDE-10601
When detecting hyperlinks, use safe methods, that do not require current file to be in the
class path.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java 2012-01-07
00:27:05 UTC (rev 37705)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/CDISeamResourceLoadingHyperlinkDetector.java 2012-01-07
01:39:07 UTC (rev 37706)
@@ -14,7 +14,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMemberValuePair;
@@ -33,7 +32,6 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.seam.text.ext.CDISeamExtPlugin;
-import org.jboss.tools.common.EclipseUtil;
public class CDISeamResourceLoadingHyperlinkDetector extends AbstractHyperlinkDetector{
public static final String RESOURCE_ANNOTATION =
"org.jboss.seam.solder.resourceLoader.Resource";
@@ -54,24 +52,15 @@
IDocument document=
textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- IFile file = null;
-
- try {
- IResource resource = input.getCorrespondingResource();
- if (resource instanceof IFile)
- file = (IFile) resource;
- } catch (JavaModelException e) {
- CDISeamExtPlugin.log(e);
+ IResource r = input.getResource();
+ if(!(r instanceof IFile) || !r.exists() || r.getName().endsWith(".jar")) {
+ return null;
}
+ IFile file = (IFile)r;
- if(file == null)
- return null;
-
try {
- ICompilationUnit cu = EclipseUtil.getCompilationUnit(file);
-
- IJavaElement element = cu == null ? null : cu.getElementAt(offset);
+ IJavaElement element = input.getElementAt(offset);
if(element != null){
if(element instanceof IField){
IAnnotation annotation = CDIMarkerResolutionUtils.findAnnotation(element,
RESOURCE_ANNOTATION);