Author: dazarov
Date: 2011-10-14 20:43:08 -0400 (Fri, 14 Oct 2011)
New Revision: 35682
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/XMLInjectedPointHyperlinkDetector.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ProducerDisposerHyperlinkDetector.java
Log:
Updated in order to work with binary files
https://issues.jboss.org/browse/JBIDE-9764
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/XMLInjectedPointHyperlinkDetector.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/XMLInjectedPointHyperlinkDetector.java 2011-10-15
00:34:31 UTC (rev 35681)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/XMLInjectedPointHyperlinkDetector.java 2011-10-15
00:43:08 UTC (rev 35682)
@@ -105,7 +105,7 @@
}
if(elementFile != null)
- findInjectedBeans(cdiNature, element, offset, elementFile, hyperlinks);
+ findInjectedBeans(cdiNature, element, offset, elementFile.getFullPath(), hyperlinks);
if (hyperlinks != null && !hyperlinks.isEmpty()) {
return (IHyperlink[])hyperlinks.toArray(new IHyperlink[hyperlinks.size()]);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java 2011-10-15
00:34:31 UTC (rev 35681)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java 2011-10-15
00:43:08 UTC (rev 35682)
@@ -14,14 +14,14 @@
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.ICodeAssist;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
@@ -53,31 +53,23 @@
int offset= region.getOffset();
- IJavaElement input= EditorUtility.getEditorInputJavaElement(textEditor, false);
+ IJavaElement input= EditorUtility.getEditorInputJavaElement(textEditor, true);
if (input == null)
return null;
- if (input.getResource() == null || input.getResource().getProject() == null)
- return null;
-
IDocument document=
textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
IRegion wordRegion= JavaWordFinder.findWord(document, offset);
if (wordRegion == null)
return null;
- IFile file = null;
+ IProject project = null;
- try {
- IResource resource = input.getCorrespondingResource();
- if (resource instanceof IFile)
- file = (IFile) resource;
- } catch (JavaModelException e) {
- CDIExtensionsPlugin.log(e);
- }
+ project = input.getJavaProject().getProject();
- if(file == null)
+ if(project == null)
return null;
- CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(file.getProject());
+
+ CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(project);
if(cdiNature == null)
return null;
@@ -93,8 +85,10 @@
ArrayList<IHyperlink> hyperlinks = new ArrayList<IHyperlink>();
int position = 0;
if(elements[0] instanceof IType){
- ICompilationUnit cUnit = (ICompilationUnit)input;
- elements[0] = cUnit.getElementAt(wordRegion.getOffset());
+ if(input instanceof ITypeRoot){
+ ITypeRoot cUnit = (ITypeRoot)input;
+ elements[0] = cUnit.getElementAt(wordRegion.getOffset());
+ }
if(elements[0] == null)
return null;
@@ -104,8 +98,8 @@
}
ICDIProject cdiProject = cdiNature.getDelegate();
if(cdiProject != null){
- IInjectionPoint injectionPoint = findInjectedPoint(cdiProject, elements[0], position,
file);
- Set<IParameter> param = findObserverParameter(cdiProject, elements[0], offset,
file);
+ IInjectionPoint injectionPoint = findInjectedPoint(cdiProject, elements[0], position,
input.getPath());
+ Set<IParameter> param = findObserverParameter(cdiProject, elements[0], offset,
input.getPath());
if(injectionPoint != null){
Set<IObserverMethod> observerMethods =
cdiProject.resolveObserverMethods(injectionPoint);
@@ -137,15 +131,15 @@
return null;
}
- private IInjectionPoint findInjectedPoint(ICDIProject cdiProject, IJavaElement element,
int offset, IFile file){
- Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+ private IInjectionPoint findInjectedPoint(ICDIProject cdiProject, IJavaElement element,
int offset, IPath path){
+ Set<IBean> beans = cdiProject.getBeans(path);
return CDIUtil.findInjectionPoint(beans, element, offset);
}
- private Set<IParameter> findObserverParameter(ICDIProject cdiProject, IJavaElement
element, int offset, IFile file) throws JavaModelException {
+ private Set<IParameter> findObserverParameter(ICDIProject cdiProject, IJavaElement
element, int offset, IPath path) throws JavaModelException {
HashSet<IParameter> result = new HashSet<IParameter>();
- Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+ Set<IBean> beans = cdiProject.getBeans(path);
for (IBean bean: beans) {
if(bean instanceof IClassBean) {
Set<IObserverMethod> observers = ((IClassBean)bean).getObserverMethods();
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java 2011-10-15
00:34:31 UTC (rev 35681)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java 2011-10-15
00:43:08 UTC (rev 35682)
@@ -14,13 +14,13 @@
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.ICodeAssist;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
@@ -54,31 +54,23 @@
int offset= region.getOffset();
- IJavaElement input= EditorUtility.getEditorInputJavaElement(textEditor, false);
+ IJavaElement input= EditorUtility.getEditorInputJavaElement(textEditor, true);
if (input == null)
return null;
- if (input.getResource() == null || input.getResource().getProject() == null)
- return null;
-
document= textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
IRegion wordRegion= JavaWordFinder.findWord(document, offset);
if (wordRegion == null)
return null;
- IFile file = null;
+ IProject project = null;
- try {
- IResource resource = input.getCorrespondingResource();
- if (resource instanceof IFile)
- file = (IFile) resource;
- } catch (JavaModelException e) {
- CDIExtensionsPlugin.log(e);
- }
+ project = input.getJavaProject().getProject();
- if(file == null)
+ if(project == null)
return null;
- CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(file.getProject());
+
+ CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(project);
if(cdiNature == null)
return null;
@@ -94,17 +86,20 @@
ArrayList<IHyperlink> hyperlinks = new ArrayList<IHyperlink>();
int position = 0;
if(elements[0] instanceof IType){
- ICompilationUnit cUnit = (ICompilationUnit)input;
- elements[0] = cUnit.getElementAt(wordRegion.getOffset());
+ if(input instanceof ITypeRoot){
+ ITypeRoot cUnit = (ITypeRoot)input;
+ elements[0] = cUnit.getElementAt(wordRegion.getOffset());
+ }
if(elements[0] == null)
return null;
+
if(elements[0] instanceof IMethod){
position = offset;
}
}
- findInjectedBeans(cdiNature, elements[0], position, file, hyperlinks);
+ findInjectedBeans(cdiNature, elements[0], position, input.getPath(), hyperlinks);
if (hyperlinks != null && !hyperlinks.isEmpty()) {
return (IHyperlink[])hyperlinks.toArray(new IHyperlink[hyperlinks.size()]);
@@ -115,14 +110,14 @@
return null;
}
- protected void findInjectedBeans(CDICoreNature nature, IJavaElement element, int offset,
IFile file, ArrayList<IHyperlink> hyperlinks){
+ protected void findInjectedBeans(CDICoreNature nature, IJavaElement element, int offset,
IPath path, ArrayList<IHyperlink> hyperlinks){
ICDIProject cdiProject = nature.getDelegate();
if(cdiProject == null){
return;
}
- Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+ Set<IBean> beans = cdiProject.getBeans(path);
IInjectionPoint injectionPoint = CDIUtil.findInjectionPoint(beans, element, offset);
if(injectionPoint == null){
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ProducerDisposerHyperlinkDetector.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ProducerDisposerHyperlinkDetector.java 2011-10-15
00:34:31 UTC (rev 35681)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ProducerDisposerHyperlinkDetector.java 2011-10-15
00:43:08 UTC (rev 35682)
@@ -14,13 +14,13 @@
import java.util.List;
import java.util.Set;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.ICodeAssist;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
@@ -52,32 +52,23 @@
int offset= region.getOffset();
- IJavaElement input= EditorUtility.getEditorInputJavaElement(textEditor, false);
+ IJavaElement input= EditorUtility.getEditorInputJavaElement(textEditor, true);
if (input == null)
return null;
- if (input.getResource() == null || input.getResource().getProject() == null)
- return null;
-
IDocument document=
textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
IRegion wordRegion= JavaWordFinder.findWord(document, offset);
if (wordRegion == null)
return null;
- IFile file = null;
+ IProject project = null;
- try {
- IResource resource = input.getCorrespondingResource();
- if (resource instanceof IFile)
- file = (IFile) resource;
- } catch (JavaModelException e) {
- CDIExtensionsPlugin.log(e);
- }
+ project = input.getJavaProject().getProject();
- if(file == null)
+ if(project == null)
return null;
- Set<IBean> beans = getBeans(file);
+ Set<IBean> beans = getBeans(project, input.getPath());
if(beans == null)
return null;
@@ -94,8 +85,10 @@
ArrayList<IHyperlink> hyperlinks = new ArrayList<IHyperlink>();
if(elements[0] instanceof IType){
if(CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME.equals(((IType)
elements[0]).getFullyQualifiedName())){
- ICompilationUnit cUnit = (ICompilationUnit)input;
- elements[0] = cUnit.getElementAt(wordRegion.getOffset());
+ if(input instanceof ITypeRoot){
+ ITypeRoot cUnit = (ITypeRoot)input;
+ elements[0] = cUnit.getElementAt(wordRegion.getOffset());
+ }
if(elements[0] == null)
return null;
}
@@ -132,8 +125,8 @@
return null;
}
- private Set<IBean> getBeans(IFile file){
- CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(file.getProject());
+ private Set<IBean> getBeans(IProject project, IPath path){
+ CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(project);
if(cdiNature == null)
return null;
@@ -145,7 +138,7 @@
return null;
- Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+ Set<IBean> beans = cdiProject.getBeans(path);
return beans;
}