summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakosyakov2013-07-09 08:51:01 (EDT)
committer Gerrit Code Review @ Eclipse.org2013-07-09 13:35:56 (EDT)
commitf2c61ff59a7faf8b43f1d2cfe4ff113858083e23 (patch)
treeb201dbac8bc0babd92fcbaf0df88d29ecd2a4a46
parentc4ba7cb50a4518b6838490bf9733fa0394f421b6 (diff)
downloadorg.eclipse.xtext-f2c61ff59a7faf8b43f1d2cfe4ff113858083e23.zip
org.eclipse.xtext-f2c61ff59a7faf8b43f1d2cfe4ff113858083e23.tar.gz
org.eclipse.xtext-f2c61ff59a7faf8b43f1d2cfe4ff113858083e23.tar.bz2
[408935]: the javadoc window shows documentation based on type of sourcerefs/changes/00/14400/3
element, e.g.: 1. If source element's type is XtendClass then it will show the documentation which was declared for this xtend class; 2. If source element's type is JvmType (so it's a reference to java class) then it will show the documentation which was declared for this java class (it's not matter java class was derived from xtend class during active annotations processing or was written manually) Change-Id: I24cc40e2adedf32e5a9e435548959942d7842595 Signed-off-by: akosyakov <anton.kosyakov@itemis.de>
-rw-r--r--plugins/org.eclipse.xtend.ide/src/org/eclipse/xtend/ide/hover/XtendHoverDocumentationProvider.java16
-rw-r--r--tests/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.xtend72
-rw-r--r--tests/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.java216
3 files changed, 25 insertions, 279 deletions
diff --git a/plugins/org.eclipse.xtend.ide/src/org/eclipse/xtend/ide/hover/XtendHoverDocumentationProvider.java b/plugins/org.eclipse.xtend.ide/src/org/eclipse/xtend/ide/hover/XtendHoverDocumentationProvider.java
index 87eca9b..63a122a 100644
--- a/plugins/org.eclipse.xtend.ide/src/org/eclipse/xtend/ide/hover/XtendHoverDocumentationProvider.java
+++ b/plugins/org.eclipse.xtend.ide/src/org/eclipse/xtend/ide/hover/XtendHoverDocumentationProvider.java
@@ -11,7 +11,6 @@ import static org.eclipse.xtext.xbase.ui.hover.HoverLinkHelper.*;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
@@ -153,21 +152,6 @@ public class XtendHoverDocumentationProvider extends XbaseHoverDocumentationProv
return Lists.newArrayList();
}
- @Override
- protected String resolveDocumentation(EObject sourceElement) {
- Set<EObject> jvmElements = associations.getJvmElements(sourceElement);
- if (jvmElements == null) {
- return super.resolveDocumentation(sourceElement);
- }
- for (EObject jvmElement : jvmElements) {
- String documentation = resolveDocumentationForJvmElement(jvmElement);
- if (documentation != null) {
- return documentation;
- }
- }
- return super.resolveDocumentation(sourceElement);
- }
-
protected String resolveDocumentationForJvmElement(EObject jvmElement) {
String documentation = documentationProvider.getDocumentation(jvmElement);
if (documentation != null) {
diff --git a/tests/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.xtend b/tests/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.xtend
index 689d3d0..8eb3aed 100644
--- a/tests/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.xtend
+++ b/tests/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.xtend
@@ -13,15 +13,14 @@ import java.util.jar.Manifest
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IFolder
import org.eclipse.emf.common.util.URI
+import org.eclipse.emf.ecore.EObject
import org.eclipse.jdt.core.IJavaProject
import org.eclipse.jdt.core.JavaCore
import org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl
import org.eclipse.xtend.core.tests.macro.AbstractReusableActiveAnnotationTests
import org.eclipse.xtend.core.xtend.XtendClass
-import org.eclipse.xtend.core.xtend.XtendConstructor
import org.eclipse.xtend.core.xtend.XtendField
import org.eclipse.xtend.core.xtend.XtendFile
-import org.eclipse.xtend.core.xtend.XtendFunction
import org.eclipse.xtend.ide.tests.XtendIDEInjectorProvider
import org.eclipse.xtext.junit4.InjectWith
import org.eclipse.xtext.junit4.XtextRunner
@@ -97,74 +96,19 @@ class ActiveAnnotationsProcessingInIDETest extends AbstractReusableActiveAnnotat
@ChangeDoc
class UserClass {
- /**
- * Comment
- */
- @ChangeDoc
- private Object object
-
- /**
- * Comment
- */
- private Object object2
-
- /**
- * Comment
- */
- @ChangeDoc
- new() {
- this(new Object, new Object)
- }
-
- /**
- * Comment
- */
- new(Object object, Object object2) {
- this.object = object
- this.object2 = object2
- }
-
- /**
- * Comment
- */
- @ChangeDoc
- def op() {
- }
-
- /**
- * Comment
- */
- def op2() {
- }
+ private UserClass object
}
''') [
val xtendClass = xtendFile.xtendTypes.filter(XtendClass).head
- assertEquals(
- '''@<a href="eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1">ChangeDoc</a><br>Hello World!'''.
- toString, xtendClass.documentation)
- val objectField = xtendClass.members.filter(XtendField).filter[name.equals("object")].head
- assertEquals(
- '''@<a href="eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1">ChangeDoc</a><br>Hello World!'''.
- toString, objectField.documentation)
- val objectField2 = xtendClass.members.filter(XtendField).filter[name.equals("object2")].head
- assertEquals('''Comment'''.toString, objectField2.documentation)
- val constructor = xtendClass.members.filter(XtendConstructor).filter[parameters.empty].head
- assertEquals(
- '''@<a href="eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1">ChangeDoc</a><br>Hello World!'''.
- toString, constructor.documentation)
- val constructor2 = xtendClass.members.filter(XtendConstructor).filter[parameters.size == 2].head
- assertEquals(
- '''Comment<dl><dt>Parameters:</dt><dd><b>object</b> </dd><dd><b>object2</b> </dd></dl>'''.toString,
- constructor2.documentation)
- val opFunction = xtendClass.members.filter(XtendFunction).filter[name.equals("op")].head
- assertEquals(
- '''@<a href="eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1">ChangeDoc</a><br>Hello World!'''.
- toString, opFunction.documentation)
- val op2Function = xtendClass.members.filter(XtendFunction).filter[name.equals("op2")].head
- assertEquals('''Comment'''.toString, op2Function.documentation)
+ assertDocumentation('''@<a href="eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1">ChangeDoc</a><br>Comment''', xtendClass)
+ assertDocumentation('''Hello World!''', xtendClass.members.filter(XtendField).filter[name.equals("object")].head.type.type)
]
}
+
+ def assertDocumentation(CharSequence charSequence, EObject sourceElement) {
+ assertEquals(charSequence.toString, sourceElement.documentation)
+ }
@Test def void testFileSystemAccess() {
val userCodeContent = '''
diff --git a/tests/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.java b/tests/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.java
index 3d02946..a43ea53 100644
--- a/tests/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.java
+++ b/tests/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/macros/ActiveAnnotationsProcessingInIDETest.java
@@ -30,18 +30,17 @@ import org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl;
import org.eclipse.xtend.core.macro.fsaccess.IOUtils;
import org.eclipse.xtend.core.tests.macro.AbstractReusableActiveAnnotationTests;
import org.eclipse.xtend.core.xtend.XtendClass;
-import org.eclipse.xtend.core.xtend.XtendConstructor;
import org.eclipse.xtend.core.xtend.XtendField;
import org.eclipse.xtend.core.xtend.XtendFile;
-import org.eclipse.xtend.core.xtend.XtendFunction;
import org.eclipse.xtend.core.xtend.XtendMember;
-import org.eclipse.xtend.core.xtend.XtendParameter;
import org.eclipse.xtend.core.xtend.XtendTypeDeclaration;
import org.eclipse.xtend.ide.tests.WorkbenchTestHelper;
import org.eclipse.xtend.ide.tests.XtendIDEInjectorProvider;
import org.eclipse.xtend.lib.macro.services.FileHandle;
import org.eclipse.xtend.lib.macro.services.FolderHandle;
import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.common.types.JvmType;
+import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.junit4.InjectWith;
import org.eclipse.xtext.junit4.XtextRunner;
import org.eclipse.xtext.junit4.internal.StopwatchRule;
@@ -162,111 +161,7 @@ public class ActiveAnnotationsProcessingInIDETest extends AbstractReusableActive
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("\t");
- _builder_1.append("/** ");
- _builder_1.newLine();
- _builder_1.append("\t\t");
- _builder_1.append("* Comment");
- _builder_1.newLine();
- _builder_1.append("\t\t");
- _builder_1.append("*/");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("@ChangeDoc");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("private Object object");
- _builder_1.newLine();
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("/** ");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("* Comment");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("*/");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("private Object object2");
- _builder_1.newLine();
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("/** ");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("* Comment");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("*/");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("@ChangeDoc");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("new() {");
- _builder_1.newLine();
- _builder_1.append("\t\t");
- _builder_1.append("this(new Object, new Object)");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("}");
- _builder_1.newLine();
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("/** ");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("* Comment");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("*/");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("new(Object object, Object object2) {");
- _builder_1.newLine();
- _builder_1.append("\t\t");
- _builder_1.append("this.object = object");
- _builder_1.newLine();
- _builder_1.append("\t\t");
- _builder_1.append("this.object2 = object2");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("}");
- _builder_1.newLine();
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("/** ");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("* Comment");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("*/");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("@ChangeDoc");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("def op() {");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("}");
- _builder_1.newLine();
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("/** ");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("* Comment");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("*/");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("def op2() {");
- _builder_1.newLine();
- _builder_1.append("\t");
- _builder_1.append("}");
+ _builder_1.append("private UserClass object");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("}");
@@ -279,10 +174,10 @@ public class ActiveAnnotationsProcessingInIDETest extends AbstractReusableActive
Iterable<XtendClass> _filter = Iterables.<XtendClass>filter(_xtendTypes, XtendClass.class);
final XtendClass xtendClass = IterableExtensions.<XtendClass>head(_filter);
StringConcatenation _builder = new StringConcatenation();
- _builder.append("@<a href=\"eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1\">ChangeDoc</a><br>Hello World!");
- String _string = _builder.toString();
- String _documentation = ActiveAnnotationsProcessingInIDETest.this.documentationProvider.getDocumentation(xtendClass);
- Assert.assertEquals(_string, _documentation);
+ _builder.append("@<a href=\"eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1\">ChangeDoc</a><br>Comment");
+ ActiveAnnotationsProcessingInIDETest.this.assertDocumentation(_builder, xtendClass);
+ StringConcatenation _builder_1 = new StringConcatenation();
+ _builder_1.append("Hello World!");
EList<XtendMember> _members = xtendClass.getMembers();
Iterable<XtendField> _filter_1 = Iterables.<XtendField>filter(_members, XtendField.class);
final Function1<XtendField,Boolean> _function = new Function1<XtendField,Boolean>() {
@@ -293,98 +188,21 @@ public class ActiveAnnotationsProcessingInIDETest extends AbstractReusableActive
}
};
Iterable<XtendField> _filter_2 = IterableExtensions.<XtendField>filter(_filter_1, _function);
- final XtendField objectField = IterableExtensions.<XtendField>head(_filter_2);
- StringConcatenation _builder_1 = new StringConcatenation();
- _builder_1.append("@<a href=\"eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1\">ChangeDoc</a><br>Hello World!");
- String _string_1 = _builder_1.toString();
- String _documentation_1 = ActiveAnnotationsProcessingInIDETest.this.documentationProvider.getDocumentation(objectField);
- Assert.assertEquals(_string_1, _documentation_1);
- EList<XtendMember> _members_1 = xtendClass.getMembers();
- Iterable<XtendField> _filter_3 = Iterables.<XtendField>filter(_members_1, XtendField.class);
- final Function1<XtendField,Boolean> _function_1 = new Function1<XtendField,Boolean>() {
- public Boolean apply(final XtendField it) {
- String _name = it.getName();
- boolean _equals = _name.equals("object2");
- return Boolean.valueOf(_equals);
- }
- };
- Iterable<XtendField> _filter_4 = IterableExtensions.<XtendField>filter(_filter_3, _function_1);
- final XtendField objectField2 = IterableExtensions.<XtendField>head(_filter_4);
- StringConcatenation _builder_2 = new StringConcatenation();
- _builder_2.append("Comment");
- String _string_2 = _builder_2.toString();
- String _documentation_2 = ActiveAnnotationsProcessingInIDETest.this.documentationProvider.getDocumentation(objectField2);
- Assert.assertEquals(_string_2, _documentation_2);
- EList<XtendMember> _members_2 = xtendClass.getMembers();
- Iterable<XtendConstructor> _filter_5 = Iterables.<XtendConstructor>filter(_members_2, XtendConstructor.class);
- final Function1<XtendConstructor,Boolean> _function_2 = new Function1<XtendConstructor,Boolean>() {
- public Boolean apply(final XtendConstructor it) {
- EList<XtendParameter> _parameters = it.getParameters();
- boolean _isEmpty = _parameters.isEmpty();
- return Boolean.valueOf(_isEmpty);
- }
- };
- Iterable<XtendConstructor> _filter_6 = IterableExtensions.<XtendConstructor>filter(_filter_5, _function_2);
- final XtendConstructor constructor = IterableExtensions.<XtendConstructor>head(_filter_6);
- StringConcatenation _builder_3 = new StringConcatenation();
- _builder_3.append("@<a href=\"eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1\">ChangeDoc</a><br>Hello World!");
- String _string_3 = _builder_3.toString();
- String _documentation_3 = ActiveAnnotationsProcessingInIDETest.this.documentationProvider.getDocumentation(constructor);
- Assert.assertEquals(_string_3, _documentation_3);
- EList<XtendMember> _members_3 = xtendClass.getMembers();
- Iterable<XtendConstructor> _filter_7 = Iterables.<XtendConstructor>filter(_members_3, XtendConstructor.class);
- final Function1<XtendConstructor,Boolean> _function_3 = new Function1<XtendConstructor,Boolean>() {
- public Boolean apply(final XtendConstructor it) {
- EList<XtendParameter> _parameters = it.getParameters();
- int _size = _parameters.size();
- boolean _equals = (_size == 2);
- return Boolean.valueOf(_equals);
- }
- };
- Iterable<XtendConstructor> _filter_8 = IterableExtensions.<XtendConstructor>filter(_filter_7, _function_3);
- final XtendConstructor constructor2 = IterableExtensions.<XtendConstructor>head(_filter_8);
- StringConcatenation _builder_4 = new StringConcatenation();
- _builder_4.append("Comment<dl><dt>Parameters:</dt><dd><b>object</b> </dd><dd><b>object2</b> </dd></dl>");
- String _string_4 = _builder_4.toString();
- String _documentation_4 = ActiveAnnotationsProcessingInIDETest.this.documentationProvider.getDocumentation(constructor2);
- Assert.assertEquals(_string_4, _documentation_4);
- EList<XtendMember> _members_4 = xtendClass.getMembers();
- Iterable<XtendFunction> _filter_9 = Iterables.<XtendFunction>filter(_members_4, XtendFunction.class);
- final Function1<XtendFunction,Boolean> _function_4 = new Function1<XtendFunction,Boolean>() {
- public Boolean apply(final XtendFunction it) {
- String _name = it.getName();
- boolean _equals = _name.equals("op");
- return Boolean.valueOf(_equals);
- }
- };
- Iterable<XtendFunction> _filter_10 = IterableExtensions.<XtendFunction>filter(_filter_9, _function_4);
- final XtendFunction opFunction = IterableExtensions.<XtendFunction>head(_filter_10);
- StringConcatenation _builder_5 = new StringConcatenation();
- _builder_5.append("@<a href=\"eclipse-xtext-doc:platform:/resource/macroProject/src/annotation/ChangeDoc.xtend%23/1\">ChangeDoc</a><br>Hello World!");
- String _string_5 = _builder_5.toString();
- String _documentation_5 = ActiveAnnotationsProcessingInIDETest.this.documentationProvider.getDocumentation(opFunction);
- Assert.assertEquals(_string_5, _documentation_5);
- EList<XtendMember> _members_5 = xtendClass.getMembers();
- Iterable<XtendFunction> _filter_11 = Iterables.<XtendFunction>filter(_members_5, XtendFunction.class);
- final Function1<XtendFunction,Boolean> _function_5 = new Function1<XtendFunction,Boolean>() {
- public Boolean apply(final XtendFunction it) {
- String _name = it.getName();
- boolean _equals = _name.equals("op2");
- return Boolean.valueOf(_equals);
- }
- };
- Iterable<XtendFunction> _filter_12 = IterableExtensions.<XtendFunction>filter(_filter_11, _function_5);
- final XtendFunction op2Function = IterableExtensions.<XtendFunction>head(_filter_12);
- StringConcatenation _builder_6 = new StringConcatenation();
- _builder_6.append("Comment");
- String _string_6 = _builder_6.toString();
- String _documentation_6 = ActiveAnnotationsProcessingInIDETest.this.documentationProvider.getDocumentation(op2Function);
- Assert.assertEquals(_string_6, _documentation_6);
+ XtendField _head = IterableExtensions.<XtendField>head(_filter_2);
+ JvmTypeReference _type = _head.getType();
+ JvmType _type_1 = _type.getType();
+ ActiveAnnotationsProcessingInIDETest.this.assertDocumentation(_builder_1, _type_1);
}
};
this.assertProcessing(_mappedTo, _mappedTo_1, _function);
}
+ public void assertDocumentation(final CharSequence charSequence, final EObject sourceElement) {
+ String _string = charSequence.toString();
+ String _documentation = this.documentationProvider.getDocumentation(sourceElement);
+ Assert.assertEquals(_string, _documentation);
+ }
+
@Test
public void testFileSystemAccess() {
StringConcatenation _builder = new StringConcatenation();