aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalsolatragus2012-12-21 10:21:56 (EST)
committerMarcel Bruch2012-12-21 10:21:56 (EST)
commit378e6a530faed531e4e878dc99b3753d7344df95 (patch)
tree25ba2a63ebad49dab31d271a106bba157aac979b
parent6d4480a24349267ba0fe49ba10c0688bef77bcbc (diff)
downloadorg.eclipse.recommenders-378e6a530faed531e4e878dc99b3753d7344df95.zip
org.eclipse.recommenders-378e6a530faed531e4e878dc99b3753d7344df95.tar.gz
org.eclipse.recommenders-378e6a530faed531e4e878dc99b3753d7344df95.tar.bz2
[tests] added new smoke test scenarios with generic typesrefs/changes/40/9240/4
-rw-r--r--plugins/org.eclipse.recommenders.completion.rcp/src/org/eclipse/recommenders/internal/completion/rcp/BaseRecommendersCompletionContext.java18
-rw-r--r--plugins/org.eclipse.recommenders.utils.rcp/src/org/eclipse/recommenders/utils/rcp/CompilerBindings.java5
-rw-r--r--tests/org.eclipse.recommenders.tests.completion.rcp/src/org/eclipse/recommenders/tests/completion/rcp/CompilerBindingsTest.java2
-rw-r--r--tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend7
-rw-r--r--tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java23
5 files changed, 45 insertions, 10 deletions
diff --git a/plugins/org.eclipse.recommenders.completion.rcp/src/org/eclipse/recommenders/internal/completion/rcp/BaseRecommendersCompletionContext.java b/plugins/org.eclipse.recommenders.completion.rcp/src/org/eclipse/recommenders/internal/completion/rcp/BaseRecommendersCompletionContext.java
index 01218c6..6223fe2 100644
--- a/plugins/org.eclipse.recommenders.completion.rcp/src/org/eclipse/recommenders/internal/completion/rcp/BaseRecommendersCompletionContext.java
+++ b/plugins/org.eclipse.recommenders.completion.rcp/src/org/eclipse/recommenders/internal/completion/rcp/BaseRecommendersCompletionContext.java
@@ -64,12 +64,16 @@ import org.eclipse.recommenders.utils.names.ITypeName;
import org.eclipse.recommenders.utils.names.VmTypeName;
import org.eclipse.recommenders.utils.rcp.CompilerBindings;
import org.eclipse.recommenders.utils.rcp.JdtUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
import com.google.common.collect.Sets;
public abstract class BaseRecommendersCompletionContext implements IRecommendersCompletionContext {
+ private static Logger log = LoggerFactory.getLogger(BaseRecommendersCompletionContext.class);
+
public static ASTNode NULL = new ASTNode() {
@Override
@@ -122,7 +126,7 @@ public abstract class BaseRecommendersCompletionContext implements IRecommenders
compilationUnitDeclaration = (CompilationUnitDeclaration) fCompilationUnitDeclaration.get(extCoreContext);
} catch (Exception e) {
- e.printStackTrace();
+ log.error("reflection initalizer failed.", e);
}
}
@@ -336,9 +340,15 @@ public abstract class BaseRecommendersCompletionContext implements IRecommenders
Set<ITypeName> res = Sets.newHashSet();
// keys contain '/' instead of dots and may end with ';'
for (char[] key : keys) {
- String descriptor = new String(key);
- descriptor = StringUtils.substringBeforeLast(descriptor, ";");
- res.add(VmTypeName.get(descriptor));
+ try {
+ String descriptor = new String(key);
+ descriptor = StringUtils.substringBeforeLast(descriptor, ";");
+ res.add(VmTypeName.get(descriptor));
+ } catch (Exception e) {
+ // this fails sometimes on method argument completion.
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=396595
+ log.error("Couldn't parse type name: '" + String.valueOf(key) + "'", e);
+ }
}
return res;
}
diff --git a/plugins/org.eclipse.recommenders.utils.rcp/src/org/eclipse/recommenders/utils/rcp/CompilerBindings.java b/plugins/org.eclipse.recommenders.utils.rcp/src/org/eclipse/recommenders/utils/rcp/CompilerBindings.java
index 7a93a7e..ba21f33 100644
--- a/plugins/org.eclipse.recommenders.utils.rcp/src/org/eclipse/recommenders/utils/rcp/CompilerBindings.java
+++ b/plugins/org.eclipse.recommenders.utils.rcp/src/org/eclipse/recommenders/utils/rcp/CompilerBindings.java
@@ -93,7 +93,7 @@ public class CompilerBindings {
}
}
- String signature = String.valueOf(binding.computeUniqueKey());
+ String signature = String.valueOf(binding.genericTypeSignature());
// if (binding instanceof BinaryTypeBinding) {
// signature = StringUtils.substringBeforeLast(signature, ";");
// }
@@ -116,8 +116,7 @@ public class CompilerBindings {
try {
final String uniqueKey = String.valueOf(binding.computeUniqueKey());
String qualifiedMethodName = StringUtils.substringBefore(uniqueKey, "(").replace(";.", ".");
- if (qualifiedMethodName.endsWith("."))
- qualifiedMethodName += new String(TypeConstants.INIT);
+ if (qualifiedMethodName.endsWith(".")) qualifiedMethodName += new String(TypeConstants.INIT);
final String[] parameterTypes = Signature.getParameterTypes(uniqueKey);
final String returnType = Signature.getReturnType(uniqueKey);
final StringBuilder sb = new StringBuilder();
diff --git a/tests/org.eclipse.recommenders.tests.completion.rcp/src/org/eclipse/recommenders/tests/completion/rcp/CompilerBindingsTest.java b/tests/org.eclipse.recommenders.tests.completion.rcp/src/org/eclipse/recommenders/tests/completion/rcp/CompilerBindingsTest.java
index be5a7b5..cdfa076 100644
--- a/tests/org.eclipse.recommenders.tests.completion.rcp/src/org/eclipse/recommenders/tests/completion/rcp/CompilerBindingsTest.java
+++ b/tests/org.eclipse.recommenders.tests.completion.rcp/src/org/eclipse/recommenders/tests/completion/rcp/CompilerBindingsTest.java
@@ -94,7 +94,7 @@ public class CompilerBindingsTest {
private ReferenceBinding createTypeBinding(final String type) {
final ReferenceBinding mock = mock(ReferenceBinding.class);
- when(mock.computeUniqueKey()).thenReturn(type.toCharArray());
+ when(mock.genericTypeSignature()).thenReturn(type.toCharArray());
return mock;
}
diff --git a/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend b/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend
index f12e0d6..c6c5deb 100644
--- a/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend
+++ b/tests/org.eclipse.recommenders.tests/src/org/eclipse/recommenders/tests/SmokeTestScenarios.xtend
@@ -12,7 +12,7 @@ class SmokeTestScenarios {
PACKAGE_01, PACKAGE_02, PACKAGE_03,
CLASSBODY_01, CLASSBODY_02, CLASSBODY_03, CLASSBODY_04, CLASSBODY_05,
METHOD_STMT_01, METHOD_STMT_02, METHOD_STMT_03, METHOD_STMT_04, METHOD_STMT_05,METHOD_STMT_06,
- METHOD_STMT_07, METHOD_STMT_08, METHOD_STMT_09, METHOD_STMT_10,
+ METHOD_STMT_07, METHOD_STMT_08, METHOD_STMT_09, METHOD_STMT_10, METHOD_STMT_11, METHOD_STMT_12,
COMMENTS_01, COMMENTS_02
)
}
@@ -93,6 +93,11 @@ class SmokeTestScenarios {
public static CharSequence METHOD_STMT_10 = method('''undef$inedMethod($).$call($)''')
+ public static CharSequence METHOD_STMT_11 = method('''java.util.Arrays.asList(get$)''')
+
+ public static CharSequence METHOD_STMT_12 = method('''List<?> l = new java.util.ArrayList();
+ l.$subList(0, 1).$''')
+
public static CharSequence COMMENTS_01 =
'''
/**
diff --git a/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java b/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java
index 5af6174..67aaea1 100644
--- a/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java
+++ b/tests/org.eclipse.recommenders.tests/xtend-gen/org/eclipse/recommenders/tests/SmokeTestScenarios.java
@@ -14,7 +14,7 @@ public class SmokeTestScenarios {
SmokeTestScenarios.PACKAGE_01, SmokeTestScenarios.PACKAGE_02, SmokeTestScenarios.PACKAGE_03,
SmokeTestScenarios.CLASSBODY_01, SmokeTestScenarios.CLASSBODY_02, SmokeTestScenarios.CLASSBODY_03, SmokeTestScenarios.CLASSBODY_04, SmokeTestScenarios.CLASSBODY_05,
SmokeTestScenarios.METHOD_STMT_01, SmokeTestScenarios.METHOD_STMT_02, SmokeTestScenarios.METHOD_STMT_03, SmokeTestScenarios.METHOD_STMT_04, SmokeTestScenarios.METHOD_STMT_05, SmokeTestScenarios.METHOD_STMT_06,
- SmokeTestScenarios.METHOD_STMT_07, SmokeTestScenarios.METHOD_STMT_08, SmokeTestScenarios.METHOD_STMT_09, SmokeTestScenarios.METHOD_STMT_10,
+ SmokeTestScenarios.METHOD_STMT_07, SmokeTestScenarios.METHOD_STMT_08, SmokeTestScenarios.METHOD_STMT_09, SmokeTestScenarios.METHOD_STMT_10, SmokeTestScenarios.METHOD_STMT_11, SmokeTestScenarios.METHOD_STMT_12,
SmokeTestScenarios.COMMENTS_01, SmokeTestScenarios.COMMENTS_02);
return _asList;
}
@@ -243,6 +243,27 @@ public class SmokeTestScenarios {
}
}.apply();
+ public static CharSequence METHOD_STMT_11 = new Function0<CharSequence>() {
+ public CharSequence apply() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("java.util.Arrays.asList(get$)");
+ CharSequence _method = CodeBuilder.method(_builder);
+ return _method;
+ }
+ }.apply();
+
+ public static CharSequence METHOD_STMT_12 = new Function0<CharSequence>() {
+ public CharSequence apply() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("List<?> l = new java.util.ArrayList();");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("l.$subList(0, 1).$");
+ CharSequence _method = CodeBuilder.method(_builder);
+ return _method;
+ }
+ }.apply();
+
public static CharSequence COMMENTS_01 = new Function0<CharSequence>() {
public CharSequence apply() {
StringConcatenation _builder = new StringConcatenation();