Use target platform interface instead of psi platform
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jetbrains.jet.completion;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
public abstract class AbstractJavaCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
@NotNull
|
||||
@@ -28,7 +29,7 @@ public abstract class AbstractJavaCompletionTest extends JetFixtureCompletionBas
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpectedCompletionUtils.Platform getPlatform() {
|
||||
return ExpectedCompletionUtils.Platform.JAVA;
|
||||
public TargetPlatform getPlatform() {
|
||||
return TargetPlatform.JVM;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
import org.jetbrains.jet.testing.ConfigLibraryUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -79,7 +80,7 @@ public abstract class AbstractJavaWithLibCompletionTest extends JetFixtureComple
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpectedCompletionUtils.Platform getPlatform() {
|
||||
return ExpectedCompletionUtils.Platform.JAVA;
|
||||
public TargetPlatform getPlatform() {
|
||||
return TargetPlatform.JVM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.completion;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetStdJSProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
public abstract class AbstractJetJSCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
@NotNull
|
||||
@@ -28,7 +29,7 @@ public abstract class AbstractJetJSCompletionTest extends JetFixtureCompletionBa
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpectedCompletionUtils.Platform getPlatform() {
|
||||
return ExpectedCompletionUtils.Platform.JS;
|
||||
public TargetPlatform getPlatform() {
|
||||
return TargetPlatform.JS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,23 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.completion;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.module.StdModuleTypes;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetLightProjectDescriptor;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
|
||||
import java.io.File;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
public abstract class AbstractKeywordCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||
@Override
|
||||
public ExpectedCompletionUtils.Platform getPlatform() {
|
||||
return ExpectedCompletionUtils.Platform.JAVA;
|
||||
public TargetPlatform getPlatform() {
|
||||
return TargetPlatform.JVM;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -27,6 +27,7 @@ import junit.framework.Assert;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.InTextDirectivesUtils;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -42,12 +43,6 @@ public class ExpectedCompletionUtils {
|
||||
private ExpectedCompletionUtils() {
|
||||
}
|
||||
|
||||
enum Platform {
|
||||
JAVA,
|
||||
JS,
|
||||
ALL
|
||||
}
|
||||
|
||||
public static class CompletionProposal {
|
||||
public static final Pattern PATTERN = Pattern.compile("([^~@]*)(@([^~]*))?(~(.*))?");
|
||||
public static final int LOOKUP_STRING_GROUP_INDEX = 1;
|
||||
@@ -97,6 +92,8 @@ public class ExpectedCompletionUtils {
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String UNSUPPORTED_PLATFORM_MESSAGE = String.format("Only %s and %s platforms are supported", TargetPlatform.JVM, TargetPlatform.JS);
|
||||
|
||||
private static final String EXIST_LINE_PREFIX = "EXIST:";
|
||||
|
||||
@@ -128,41 +125,45 @@ public class ExpectedCompletionUtils {
|
||||
WITH_ORDER_PREFIX);
|
||||
|
||||
@NotNull
|
||||
public static CompletionProposal[] itemsShouldExist(String fileText, Platform platform) {
|
||||
switch (platform) {
|
||||
case ALL:
|
||||
return processProposalAssertions(fileText, EXIST_LINE_PREFIX);
|
||||
case JAVA:
|
||||
return processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JAVA_ONLY_LINE_PREFIX);
|
||||
case JS:
|
||||
return processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JS_ONLY_LINE_PREFIX);
|
||||
public static CompletionProposal[] itemsShouldExist(String fileText, @Nullable TargetPlatform platform) {
|
||||
if (platform == null) {
|
||||
return processProposalAssertions(fileText, EXIST_LINE_PREFIX);
|
||||
}
|
||||
else if (platform == TargetPlatform.JVM) {
|
||||
return processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JAVA_ONLY_LINE_PREFIX);
|
||||
}
|
||||
else if (platform == TargetPlatform.JS) {
|
||||
return processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JS_ONLY_LINE_PREFIX);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(UNSUPPORTED_PLATFORM_MESSAGE);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("platform");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static CompletionProposal[] itemsShouldAbsent(String fileText, Platform platform) {
|
||||
switch (platform) {
|
||||
case ALL:
|
||||
return processProposalAssertions(fileText, ABSENT_LINE_PREFIX);
|
||||
case JAVA:
|
||||
return processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JAVA_LINE_PREFIX, EXIST_JS_ONLY_LINE_PREFIX);
|
||||
case JS:
|
||||
return processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JS_LINE_PREFIX, EXIST_JAVA_ONLY_LINE_PREFIX);
|
||||
public static CompletionProposal[] itemsShouldAbsent(String fileText, @Nullable TargetPlatform platform) {
|
||||
if (platform == null) {
|
||||
return processProposalAssertions(fileText, ABSENT_LINE_PREFIX);
|
||||
}
|
||||
else if (platform == TargetPlatform.JVM) {
|
||||
return processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JAVA_LINE_PREFIX, EXIST_JS_ONLY_LINE_PREFIX);
|
||||
}
|
||||
else if (platform == TargetPlatform.JS) {
|
||||
return processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JS_LINE_PREFIX, EXIST_JAVA_ONLY_LINE_PREFIX);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(UNSUPPORTED_PLATFORM_MESSAGE);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("platform");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static CompletionProposal[] itemsShouldExist(String fileText) {
|
||||
return itemsShouldExist(fileText, Platform.ALL);
|
||||
return itemsShouldExist(fileText, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static CompletionProposal[] itemsShouldAbsent(String fileText) {
|
||||
return itemsShouldAbsent(fileText, Platform.ALL);
|
||||
return itemsShouldAbsent(fileText, null);
|
||||
}
|
||||
|
||||
public static CompletionProposal[] processProposalAssertions(String fileText, String... prefixes) {
|
||||
@@ -180,21 +181,23 @@ public class ExpectedCompletionUtils {
|
||||
|
||||
@Nullable
|
||||
public static Integer getExpectedNumber(String fileText) {
|
||||
return getExpectedNumber(fileText, Platform.ALL);
|
||||
return getExpectedNumber(fileText, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Integer getExpectedNumber(String fileText, Platform platform) {
|
||||
switch (platform) {
|
||||
case ALL:
|
||||
return InTextDirectivesUtils.getPrefixedInt(fileText, NUMBER_LINE_PREFIX);
|
||||
case JAVA:
|
||||
return getPlatformExpectedNumber(fileText, NUMBER_JAVA_LINE_PREFIX);
|
||||
case JS:
|
||||
return getPlatformExpectedNumber(fileText, NUMBER_JS_LINE_PREFIX);
|
||||
public static Integer getExpectedNumber(String fileText, @Nullable TargetPlatform platform) {
|
||||
if (platform == null) {
|
||||
return InTextDirectivesUtils.getPrefixedInt(fileText, NUMBER_LINE_PREFIX);
|
||||
}
|
||||
else if (platform == TargetPlatform.JVM) {
|
||||
return getPlatformExpectedNumber(fileText, NUMBER_JAVA_LINE_PREFIX);
|
||||
}
|
||||
else if (platform == TargetPlatform.JS) {
|
||||
return getPlatformExpectedNumber(fileText, NUMBER_JS_LINE_PREFIX);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(UNSUPPORTED_PLATFORM_MESSAGE);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("platform");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||
|
||||
public abstract class JetFixtureCompletionBaseTestCase extends LightCodeInsightFixtureTestCase {
|
||||
private boolean autocompleteSetting;
|
||||
@@ -39,7 +40,7 @@ public abstract class JetFixtureCompletionBaseTestCase extends LightCodeInsightF
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public abstract ExpectedCompletionUtils.Platform getPlatform();
|
||||
public abstract TargetPlatform getPlatform();
|
||||
|
||||
public void doTest(String testPath) {
|
||||
myFixture.configureByFile(testPath);
|
||||
|
||||
Reference in New Issue
Block a user