Skip to content
Browse files

test helpers for code completion, TestCompletionRequestor moved to dl…

…tk.core
  • Loading branch information...
1 parent a24d8b6 commit 259a0bf31395007441c42d5de01e8aad6e689c59 @panchenko committed
View
7 ...ests/src/org/eclipse/dltk/javascript/core/tests/contentassist/AbstractCompletionTest.java
@@ -28,6 +28,7 @@
import org.eclipse.dltk.compiler.env.IModuleSource;
import org.eclipse.dltk.core.CompletionProposal;
import org.eclipse.dltk.core.DLTKLanguageManager;
+import org.eclipse.dltk.core.tests.TestCompletionRequestor;
import org.eclipse.dltk.core.tests.util.StringList;
import org.eclipse.dltk.javascript.core.JavaScriptNature;
import org.eclipse.dltk.javascript.internal.core.codeassist.JSCompletionEngine;
@@ -89,6 +90,11 @@ protected ICompletionEngine createEngine(List<CompletionProposal> results,
return engine;
}
+ protected ICompletionEngine createEngine() {
+ return createEngine(Collections.<CompletionProposal> emptyList(),
+ JSCompletionEngine.OPTION_NONE);
+ }
+
private boolean isAllowed(ICompletionEngine engine,
Collection<Class<? extends ICompletionEngine>> allowedEngines) {
if (allowedEngines.isEmpty()) {
@@ -123,6 +129,7 @@ protected static boolean compareProposalNames(
}
Collections.sort(proposals, new Comparator<CompletionProposal>() {
+ @Override
public int compare(CompletionProposal pr, CompletionProposal pr1) {
return pr.getName().compareTo(pr1.getName());
}
View
5 ...s/src/org/eclipse/dltk/javascript/core/tests/contentassist/AbstractContentAssistTest.java
@@ -15,6 +15,7 @@
import junit.framework.TestCase;
import org.eclipse.dltk.compiler.env.IModuleSource;
+import org.eclipse.dltk.core.tests.CodeAssistUtil;
import org.eclipse.osgi.util.NLS;
public abstract class AbstractContentAssistTest extends TestCase {
@@ -23,6 +24,10 @@ protected IModuleSource createModule(String moduleName) {
return new TestModule(getClass().getResource(moduleName));
}
+ protected CodeAssistUtil getModule(String moduleName) {
+ return CodeAssistUtil.on(createModule(moduleName));
+ }
+
public static int lastPositionInFile(String string, IModuleSource source) {
return lastPositionInFile(string, source, true);
}
View
36 ...sts/src/org/eclipse/dltk/javascript/core/tests/contentassist/TestCompletionRequestor.java
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 xored software, Inc.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * xored software, Inc. - initial API and Implementation (Alex Panchenko)
- *******************************************************************************/
-package org.eclipse.dltk.javascript.core.tests.contentassist;
-
-import java.util.List;
-
-import org.eclipse.dltk.core.CompletionProposal;
-import org.eclipse.dltk.core.CompletionRequestor;
-
-class TestCompletionRequestor extends CompletionRequestor {
- final List<CompletionProposal> results;
-
- public TestCompletionRequestor(List<CompletionProposal> results) {
- this.results = results;
- }
-
- @Override
- public void accept(CompletionProposal proposal) {
- if (!isIgnored(proposal.getKind())) {
- final int value = evaluateFilters(proposal);
- if (value != CompletionProposalFilter.IGNORE
- && value != CompletionProposalFilter.DISCOURAGED) {
- results.add(proposal);
- }
- }
- }
-}

0 comments on commit 259a0bf

Please sign in to comment.
Something went wrong with that request. Please try again.