Author: dazarov
Date: 2012-08-24 15:01:19 -0400 (Fri, 24 Aug 2012)
New Revision: 43225
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/NonRuntimeBindingType.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/TestEvents.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/TestEvents.qfxresult
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
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
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CDIHyperlinkTestUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/EventAndObserverMethodHyperlinkDetectorTest.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.core/src/org/jboss/tools/cdi/core/CDIUtil.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2012-08-24
16:20:04 UTC (rev 43224)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2012-08-24
19:01:19 UTC (rev 43225)
@@ -1266,7 +1266,7 @@
public static ICDIProject getCDIProject(IFile file, CDICoreNature cdiNature, boolean
asYouType){
ICDIProject cdiProject = cdiNature.getDelegate();
- if(asYouType){
+ if(asYouType && file != null){
return new CDIProjectAsYouType(cdiProject, file);
}else{
return cdiProject;
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-24
16:20:04 UTC (rev 43224)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.text.ext/src/org/jboss/tools/cdi/seam/text/ext/hyperlink/XMLInjectedPointHyperlinkDetector.java 2012-08-24
19:01:19 UTC (rev 43225)
@@ -65,7 +65,7 @@
if(!(input instanceof FileEditorInput))
return null;
- IFile file = ((FileEditorInput)input).getFile();
+ file = ((FileEditorInput)input).getFile();
if(file == null)
return null;
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-24
16:20:04 UTC (rev 43224)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/EventAndObserverMethodHyperlinkDetector.java 2012-08-24
19:01:19 UTC (rev 43225)
@@ -56,9 +56,6 @@
if(textEditor.getEditorInput() instanceof IFileEditorInput){
file = ((IFileEditorInput)textEditor.getEditorInput()).getFile();
}
- if(file == null){
- return null;
- }
int offset= region.getOffset();
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-24
16:20:04 UTC (rev 43224)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InjectedPointHyperlinkDetector.java 2012-08-24
19:01:19 UTC (rev 43225)
@@ -58,9 +58,6 @@
if(textEditor.getEditorInput() instanceof IFileEditorInput){
file = ((IFileEditorInput)textEditor.getEditorInput()).getFile();
}
- if(file == null){
- return null;
- }
int offset= region.getOffset();
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-24
16:20:04 UTC (rev 43224)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/ProducerDisposerHyperlinkDetector.java 2012-08-24
19:01:19 UTC (rev 43225)
@@ -55,9 +55,6 @@
if(textEditor.getEditorInput() instanceof IFileEditorInput){
file = ((IFileEditorInput)textEditor.getEditorInput()).getFile();
}
- if(file == null){
- return null;
- }
int offset= region.getOffset();
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/NonRuntimeBindingType.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/NonRuntimeBindingType.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/NonRuntimeBindingType.java 2012-08-24
19:01:19 UTC (rev 43225)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.jbt.openon;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@SuppressWarnings("cdi-target")
+@Target( { FIELD, PARAMETER })
+@Qualifier
+(a)Retention(RetentionPolicy.CLASS)
+@interface NonRuntimeBindingType
+{
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/NonRuntimeBindingType.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/TestEvents.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/TestEvents.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/TestEvents.java 2012-08-24
19:01:19 UTC (rev 43225)
@@ -0,0 +1,5 @@
+package org.jboss.jsr299.tck.tests.jbt.openon;
+
+
+public class TestEvents {
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/TestEvents.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/TestEvents.qfxresult
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/TestEvents.qfxresult
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/openon/TestEvents.qfxresult 2012-08-24
19:01:19 UTC (rev 43225)
@@ -0,0 +1,31 @@
+package org.jboss.jsr299.tck.tests.jbt.openon;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+
+public class TestEvents {
+ @Inject @Any Event<EventType> stringEvent;
+
+ @Inject @Any @NonRuntimeBindingType Event<EventType>
stringEventWithAnyAndNonRuntimeBindingType;
+
+ @Inject @NonRuntimeBindingType Event<EventType>
stringEventWithOnlyNonRuntimeBindingType;
+
+ public void fireEvent()
+ {
+ stringEvent.fire(new EventType());
+ }
+
+ public void fireEventWithNonRuntimeBindingType()
+ {
+ stringEventWithAnyAndNonRuntimeBindingType.fire(new EventType());
+ }
+
+ class EventType{
+ public EventType(){
+
+ }
+ }
+}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CDIHyperlinkTestUtil.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CDIHyperlinkTestUtil.java 2012-08-24
16:20:04 UTC (rev 43224)
+++
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CDIHyperlinkTestUtil.java 2012-08-24
19:01:19 UTC (rev 43225)
@@ -14,11 +14,13 @@
import java.util.Collection;
import java.util.List;
+import junit.framework.Assert;
import junit.framework.TestCase;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
@@ -55,6 +57,7 @@
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkDetector;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.AxisUtil;
+import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditorPart;
import org.jboss.tools.jst.text.ext.hyperlink.ELHyperlinkDetector;
@@ -76,6 +79,15 @@
checkRegions(fullyQualifiedName, editorInput, editorPart, regionList, hlDetector);
}
+ protected static ISourceViewer getViewer(IEditorPart editor){
+ if(editor instanceof JavaEditor){
+ return ((JavaEditor)editor).getViewer();
+ }else{
+ Assert.fail("editor must be instanceof JavaEditor");
+ }
+ return null;
+ }
+
public static void checkRegions(IProject project, String fileName,
List<TestRegion> regionList, AbstractHyperlinkDetector hlDetector) throws Exception
{
IFile file = project.getFile(fileName);
@@ -88,6 +100,35 @@
checkRegions(fileName, editorInput, editorPart, regionList, hlDetector);
}
+ public static void checkRegionsForAsYouType(IProject project, String fileName, String
newContent, List<TestRegion> regionList, AbstractHyperlinkDetector hlDetector)
throws Exception {
+ IFile file = project.getFile(fileName);
+ IFile nFile = project.getFile(newContent);
+
+ assertNotNull("The file \"" + fileName + "\" is not
found", file);
+ assertTrue("The file \"" + fileName + "\" is not found",
file.isAccessible());
+
+ assertNotNull("The file \"" + newContent + "\" is not
found", nFile);
+ assertTrue("The file \"" + newContent + "\" is not
found", nFile.isAccessible());
+
+ IEditorInput editorInput = new FileEditorInput(file);
+ IEditorPart editorPart = openFileInEditor(file);
+ try{
+ ISourceViewer viewer = getViewer(editorPart);
+
+ IDocument document = viewer.getDocument();
+
+ String text = FileUtil.getContentFromEditorOrFile(nFile);
+
+ document.set(text);
+
+ checkRegions(fileName, editorInput, editorPart, regionList, hlDetector);
+ }finally{
+ if(editorPart.isDirty()){
+ editorPart.doSave(new NullProgressMonitor());
+ }
+ }
+ }
+
private static void checkRegions(String fileName, IEditorInput editorInput, IEditorPart
editorPart, List<TestRegion> regionList, AbstractHyperlinkDetector hlDetector)
throws Exception {
ISourceViewer viewer = null;
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/EventAndObserverMethodHyperlinkDetectorTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/EventAndObserverMethodHyperlinkDetectorTest.java 2012-08-24
16:20:04 UTC (rev 43224)
+++
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/EventAndObserverMethodHyperlinkDetectorTest.java 2012-08-24
19:01:19 UTC (rev 43225)
@@ -16,10 +16,9 @@
import org.jboss.tools.cdi.text.ext.CDIExtensionsMessages;
import org.jboss.tools.cdi.text.ext.hyperlink.EventAndObserverMethodHyperlinkDetector;
import org.jboss.tools.cdi.text.ext.hyperlink.EventListHyperlink;
-import org.jboss.tools.cdi.text.ext.hyperlink.InjectedPointHyperlink;
import org.jboss.tools.cdi.text.ext.hyperlink.ObserverMethodListHyperlink;
+import org.jboss.tools.cdi.text.ext.test.CDIHyperlinkTestUtil.TestHyperlink;
import org.jboss.tools.cdi.text.ext.test.CDIHyperlinkTestUtil.TestRegion;
-import org.jboss.tools.cdi.text.ext.test.CDIHyperlinkTestUtil.TestHyperlink;
public class EventAndObserverMethodHyperlinkDetectorTest extends TCKTest {
@@ -62,6 +61,34 @@
CDIHyperlinkTestUtil.checkRegions(tckProject,
"JavaSource/org/jboss/jsr299/tck/tests/event/bindingTypes/EventEmitter.java",
regionList, new EventAndObserverMethodHyperlinkDetector());
}
+
+ public void testEventHyperlinkDetectorForAsYouType() throws Exception {
+ String[] elementPaths = new String[]{
+ "/tck/JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/observers/ClassFragmentLogger.java",
+ "/tck/JavaSource/org/jboss/jsr299/tck/tests/event/eventTypes/EventTypeFamilyObserver.java"
+ };
+
+ ArrayList<TestRegion> regionList = new ArrayList<TestRegion>();
+
+ regionList.add(new TestRegion(/*959, 6*/"Inject", new TestHyperlink[]{new
TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*967, 16*/"Any Event<EventType", new
TestHyperlink[]{new TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*985, 11*/"stringEvent", new
TestHyperlink[]{new TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*1006, 6*/"Inject", new TestHyperlink[]{new
TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*1014, 3*/"Any", new TestHyperlink[]{new
TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*1019, 34*/"NonRuntimeBindingType
Event<EventType", new TestHyperlink[]{new
TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*1055,
42*/"stringEventWithAnyAndNonRuntimeBindingType", new TestHyperlink[]{new
TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*1107, 6*/"Inject", new TestHyperlink[]{new
TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*1115, 34*/"NonRuntimeBindingType
Event<EventType", new TestHyperlink[]{new
TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*1151,
36*/"stringEventWithOnlyNonRuntimeBindingType", new TestHyperlink[]{new
TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*1235, 11*/"stringEvent", new
TestHyperlink[]{new TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+ regionList.add(new TestRegion(/*1334,
42*/"stringEventWithAnyAndNonRuntimeBindingType", new TestHyperlink[]{new
TestHyperlink(ObserverMethodListHyperlink.class,
CDIExtensionsMessages.CDI_EVENT_LIST_HYPERLINK_OPEN_OBSERVER_METHODS, elementPaths)}));
+
+ CDIHyperlinkTestUtil.checkRegionsForAsYouType(tckProject,
+ "JavaSource/org/jboss/jsr299/tck/tests/jbt/openon/TestEvents.java",
+ "JavaSource/org/jboss/jsr299/tck/tests/jbt/openon/TestEvents.qfxresult",
+ regionList,
+ new EventAndObserverMethodHyperlinkDetector());
+ }
public void testObserverMethodHyperlinkDetector() throws Exception {
String[] elementPaths = new String[]{