[jbosstools-commits] JBoss Tools SVN: r43201 - in trunk/cdi/plugins: org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Aug 23 15:26:22 EDT 2012
Author: dazarov
Date: 2012-08-23 15:26:22 -0400 (Thu, 23 Aug 2012)
New Revision: 43201
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:
CDI hyper links should work on modified files correctly https://issues.jboss.org/browse/JBIDE-12404
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 2012-08-23 16:40:25 UTC (rev 43200)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/XMLInjectedPointHyperlinkDetector.java 2012-08-23 19:26:22 UTC (rev 43201)
@@ -105,11 +105,7 @@
}
if(elementFile != null)
- try {
- findInjectedBeans(cdiNature, element, offset, elementFile.getFullPath(), hyperlinks, editor.isDirty());
- } catch (JavaModelException ex) {
- CDISeamExtPlugin.getDefault().logError(ex);
- }
+ findInjectedBeans(cdiNature, element, offset, elementFile.getFullPath(), hyperlinks, editor.isDirty());
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 2012-08-23 16:40:25 UTC (rev 43200)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java 2012-08-23 19:26:22 UTC (rev 43201)
@@ -32,6 +32,7 @@
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDIUtil;
@@ -44,7 +45,7 @@
import org.jboss.tools.cdi.text.ext.CDIExtensionsPlugin;
public class EventAndObserverMethodHyperlinkDetector extends AbstractHyperlinkDetector{
-
+ protected IFile file;
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
IRegion region, boolean canShowMultipleHyperlinks) {
@@ -52,6 +53,13 @@
if (region == null || !(textEditor instanceof JavaEditor))
return null;
+ if(textEditor.getEditorInput() instanceof IFileEditorInput){
+ file = ((IFileEditorInput)textEditor.getEditorInput()).getFile();
+ }
+ if(file == null){
+ return null;
+ }
+
int offset= region.getOffset();
ITypeRoot input= EditorUtility.getEditorInputJavaElement(textEditor, true);
@@ -98,7 +106,7 @@
position = offset;
}
}
- ICDIProject cdiProject = CDIUtil.getCDIProject((IFile)input.getUnderlyingResource(), cdiNature, textEditor.isDirty());
+ ICDIProject cdiProject = CDIUtil.getCDIProject(file, cdiNature, textEditor.isDirty());
if(cdiProject != null){
IInjectionPoint injectionPoint = findInjectedPoint(cdiProject, elements[0], position, input.getPath());
Set<IParameter> param = findObserverParameter(cdiProject, elements[0], offset, input.getPath());
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 2012-08-23 16:40:25 UTC (rev 43200)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java 2012-08-23 19:26:22 UTC (rev 43201)
@@ -31,6 +31,7 @@
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDIUtil;
@@ -43,6 +44,7 @@
private IRegion region;
protected IDocument document;
protected ITextViewer viewer;
+ protected IFile file;
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
IRegion region, boolean canShowMultipleHyperlinks) {
@@ -53,6 +55,13 @@
if (region == null || !(textEditor instanceof JavaEditor))
return null;
+ if(textEditor.getEditorInput() instanceof IFileEditorInput){
+ file = ((IFileEditorInput)textEditor.getEditorInput()).getFile();
+ }
+ if(file == null){
+ return null;
+ }
+
int offset= region.getOffset();
ITypeRoot input= EditorUtility.getEditorInputJavaElement(textEditor, true);
@@ -110,8 +119,8 @@
return null;
}
- protected void findInjectedBeans(CDICoreNature nature, IJavaElement element, int offset, IPath path, ArrayList<IHyperlink> hyperlinks, boolean dirty) throws JavaModelException{
- ICDIProject cdiProject = CDIUtil.getCDIProject((IFile)element.getUnderlyingResource(), nature, dirty);
+ protected void findInjectedBeans(CDICoreNature nature, IJavaElement element, int offset, IPath path, ArrayList<IHyperlink> hyperlinks, boolean dirty){
+ ICDIProject cdiProject = CDIUtil.getCDIProject(file, nature, dirty);
if(cdiProject == null){
return;
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 2012-08-23 16:40:25 UTC (rev 43200)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ProducerDisposerHyperlinkDetector.java 2012-08-23 19:26:22 UTC (rev 43201)
@@ -30,6 +30,7 @@
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDICoreNature;
@@ -43,6 +44,7 @@
import org.jboss.tools.cdi.text.ext.CDIExtensionsPlugin;
public class ProducerDisposerHyperlinkDetector extends AbstractHyperlinkDetector {
+ protected IFile file;
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
IRegion region, boolean canShowMultipleHyperlinks) {
@@ -50,6 +52,13 @@
if (region == null || !(textEditor instanceof JavaEditor))
return null;
+ if(textEditor.getEditorInput() instanceof IFileEditorInput){
+ file = ((IFileEditorInput)textEditor.getEditorInput()).getFile();
+ }
+ if(file == null){
+ return null;
+ }
+
int offset= region.getOffset();
ITypeRoot input= EditorUtility.getEditorInputJavaElement(textEditor, true);
@@ -68,12 +77,7 @@
if(project == null)
return null;
- Collection<IBean> beans=null;
- try {
- beans = getBeans(project, input.getPath(), (IFile)input.getUnderlyingResource(), textEditor.isDirty());
- } catch (JavaModelException jme) {
- CDIExtensionsPlugin.getDefault().logError(jme);
- }
+ Collection<IBean> beans = getBeans(project, input.getPath(), textEditor.isDirty());
if(beans == null)
return null;
@@ -129,7 +133,7 @@
return null;
}
- private Collection<IBean> getBeans(IProject project, IPath path, IFile file, boolean dirty){
+ private Collection<IBean> getBeans(IProject project, IPath path, boolean dirty){
CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(project);
if(cdiNature == null)
More information about the jbosstools-commits
mailing list