Minor: code clean, remove obsolete functions
This commit is contained in:
+6
@@ -79,6 +79,12 @@ public class AndroidXml2KConversionTestGenerated extends AbstractAndroidXml2KCon
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("severalResDirs")
|
||||||
|
public void testSeveralResDirs() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/android/converter/simple/severalResDirs/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("singleFile")
|
@TestMetadata("singleFile")
|
||||||
public void testSingleFile() throws Exception {
|
public void testSingleFile() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/");
|
String fileName = JetTestUtils.navigationMetadata("plugins/android-compiler-plugin/testData/android/converter/simple/singleFile/");
|
||||||
|
|||||||
-2
@@ -24,8 +24,6 @@ import org.jetbrains.kotlin.idea.project.TargetPlatform
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
public abstract class AbstractAndroidCompletionTest : KotlinAndroidTestCase() {
|
public abstract class AbstractAndroidCompletionTest : KotlinAndroidTestCase() {
|
||||||
private var kotlinInternalModeOriginalValue: Boolean = false
|
|
||||||
|
|
||||||
private var codeCompletionOldValue: Boolean = false
|
private var codeCompletionOldValue: Boolean = false
|
||||||
private var smartTypeCompletionOldValue: Boolean = false
|
private var smartTypeCompletionOldValue: Boolean = false
|
||||||
|
|
||||||
|
|||||||
+2
-41
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.android;
|
|||||||
import com.android.SdkConstants;
|
import com.android.SdkConstants;
|
||||||
import com.android.ide.common.rendering.RenderSecurityManager;
|
import com.android.ide.common.rendering.RenderSecurityManager;
|
||||||
import com.intellij.analysis.AnalysisScope;
|
import com.intellij.analysis.AnalysisScope;
|
||||||
import com.intellij.codeInspection.GlobalInspectionTool;
|
|
||||||
import com.intellij.codeInspection.InspectionManager;
|
import com.intellij.codeInspection.InspectionManager;
|
||||||
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
|
import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
|
||||||
import com.intellij.codeInspection.ex.InspectionManagerEx;
|
import com.intellij.codeInspection.ex.InspectionManagerEx;
|
||||||
@@ -64,7 +63,7 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
|||||||
protected Module myModule;
|
protected Module myModule;
|
||||||
protected List<Module> myAdditionalModules;
|
protected List<Module> myAdditionalModules;
|
||||||
|
|
||||||
private boolean myCreateManifest;
|
private final boolean myCreateManifest;
|
||||||
protected AndroidFacet myFacet;
|
protected AndroidFacet myFacet;
|
||||||
|
|
||||||
private boolean kotlinInternalModeOriginalValue;
|
private boolean kotlinInternalModeOriginalValue;
|
||||||
@@ -109,7 +108,7 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
|||||||
}
|
}
|
||||||
tuneModule(moduleFixtureBuilder, dirPath);
|
tuneModule(moduleFixtureBuilder, dirPath);
|
||||||
|
|
||||||
final ArrayList<MyAdditionalModuleData> modules = new ArrayList<MyAdditionalModuleData>();
|
final List<MyAdditionalModuleData> modules = new ArrayList<MyAdditionalModuleData>();
|
||||||
configureAdditionalModules(projectBuilder, modules);
|
configureAdditionalModules(projectBuilder, modules);
|
||||||
|
|
||||||
myFixture.setUp();
|
myFixture.setUp();
|
||||||
@@ -172,18 +171,6 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
|||||||
@NotNull List<MyAdditionalModuleData> modules) {
|
@NotNull List<MyAdditionalModuleData> modules) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addModuleWithAndroidFacet(@NotNull TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder,
|
|
||||||
@NotNull List<MyAdditionalModuleData> modules,
|
|
||||||
@NotNull String dirName,
|
|
||||||
boolean library) {
|
|
||||||
final JavaModuleFixtureBuilder moduleFixtureBuilder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
|
|
||||||
final String moduleDirPath = myFixture.getTempDirPath() + getContentRootPath(dirName);
|
|
||||||
//noinspection ResultOfMethodCallIgnored
|
|
||||||
new File(moduleDirPath).mkdirs();
|
|
||||||
tuneModule(moduleFixtureBuilder, moduleDirPath);
|
|
||||||
modules.add(new MyAdditionalModuleData(moduleFixtureBuilder, dirName, library));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static String getContentRootPath(@NotNull String moduleName) {
|
protected static String getContentRootPath(@NotNull String moduleName) {
|
||||||
return "/additionalModules/" + moduleName;
|
return "/additionalModules/" + moduleName;
|
||||||
}
|
}
|
||||||
@@ -202,11 +189,6 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
|||||||
|
|
||||||
protected void createManifest() throws IOException {
|
protected void createManifest() throws IOException {
|
||||||
myFixture.copyFileToProject("plugins/android-idea-plugin/testData/android/AndroidManifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML);
|
myFixture.copyFileToProject("plugins/android-idea-plugin/testData/android/AndroidManifest.xml", SdkConstants.FN_ANDROID_MANIFEST_XML);
|
||||||
// myFixture.copyFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML, SdkConstants.FN_ANDROID_MANIFEST_XML);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createProjectProperties() throws IOException {
|
|
||||||
myFixture.copyFileToProject(SdkConstants.FN_PROJECT_PROPERTIES, SdkConstants.FN_PROJECT_PROPERTIES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deleteManifest() throws IOException {
|
protected void deleteManifest() throws IOException {
|
||||||
@@ -282,27 +264,6 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
|||||||
return facet;
|
return facet;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doGlobalInspectionTest(@NotNull GlobalInspectionTool inspection,
|
|
||||||
@NotNull String globalTestDir,
|
|
||||||
@NotNull AnalysisScope scope) {
|
|
||||||
doGlobalInspectionTest(new GlobalInspectionToolWrapper(inspection), globalTestDir, scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void doGlobalInspectionTest(@NotNull GlobalInspectionToolWrapper wrapper,
|
|
||||||
@NotNull String globalTestDir,
|
|
||||||
@NotNull AnalysisScope scope) {
|
|
||||||
myFixture.enableInspections(wrapper.getTool());
|
|
||||||
|
|
||||||
scope.invalidate();
|
|
||||||
|
|
||||||
final InspectionManagerEx inspectionManager = (InspectionManagerEx)InspectionManager.getInstance(getProject());
|
|
||||||
final GlobalInspectionContextForTests globalContext =
|
|
||||||
CodeInsightTestFixtureImpl.createGlobalContextForTool(scope, getProject(), inspectionManager, wrapper);
|
|
||||||
|
|
||||||
InspectionTestUtil.runTool(wrapper, scope, globalContext);
|
|
||||||
InspectionTestUtil.compareToolResults(globalContext, wrapper, false, getTestDataPath() + globalTestDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static class MyAdditionalModuleData {
|
protected static class MyAdditionalModuleData {
|
||||||
final JavaModuleFixtureBuilder myModuleFixtureBuilder;
|
final JavaModuleFixtureBuilder myModuleFixtureBuilder;
|
||||||
final String myDirName;
|
final String myDirName;
|
||||||
|
|||||||
-141
@@ -64,21 +64,6 @@ public abstract class KotlinAndroidTestCaseBase extends UsefulTestCase {
|
|||||||
IdeaTestCase.initPlatformPrefix();
|
IdeaTestCase.initPlatformPrefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAbsoluteTestDataPath() {
|
|
||||||
// The following code doesn't work right now that the Android
|
|
||||||
// plugin lives in a separate place:
|
|
||||||
//String androidHomePath = System.getProperty("android.home.path");
|
|
||||||
//if (androidHomePath == null) {
|
|
||||||
// androidHomePath = new File(PathManager.getHomePath(), "android/android").getPath();
|
|
||||||
//}
|
|
||||||
//return PathUtil.getCanonicalPath(androidHomePath + "/testData");
|
|
||||||
|
|
||||||
// getTestDataPath already gives the absolute path anyway:
|
|
||||||
String path = getTestDataPath();
|
|
||||||
assertTrue(new File(path).isAbsolute());
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getPluginTestDataPathBase() {
|
public static String getPluginTestDataPathBase() {
|
||||||
return JetTestUtils.getHomeDirectory() + TEST_DATA_PROJECT_RELATIVE;
|
return JetTestUtils.getHomeDirectory() + TEST_DATA_PROJECT_RELATIVE;
|
||||||
}
|
}
|
||||||
@@ -87,16 +72,6 @@ public abstract class KotlinAndroidTestCaseBase extends UsefulTestCase {
|
|||||||
return getPluginTestDataPathBase();
|
return getPluginTestDataPathBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAndroidPluginHome() {
|
|
||||||
// Now that the Android plugin is kept in a separate place, we need to look in
|
|
||||||
// a relative position instead
|
|
||||||
String adtPath = PathManager.getHomePath() + "/../adt/idea/android";
|
|
||||||
if (new File(adtPath).exists()) {
|
|
||||||
return adtPath;
|
|
||||||
}
|
|
||||||
return new File(PathManager.getHomePath(), "android/android").getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefaultTestSdkPath() {
|
public String getDefaultTestSdkPath() {
|
||||||
return getTestDataPath() + "/sdk1.5";
|
return getTestDataPath() + "/sdk1.5";
|
||||||
}
|
}
|
||||||
@@ -200,121 +175,5 @@ public abstract class KotlinAndroidTestCaseBase extends UsefulTestCase {
|
|||||||
protected Project getProject() {
|
protected Project getProject() {
|
||||||
return myFixture.getProject();
|
return myFixture.getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ensureSdkManagerAvailable() {
|
|
||||||
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
|
|
||||||
if (sdkData == null) {
|
|
||||||
sdkData = createTestSdkManager();
|
|
||||||
if (sdkData != null) {
|
|
||||||
AndroidSdkUtils.setSdkData(sdkData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertNotNull(sdkData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
protected AndroidSdkData createTestSdkManager() {
|
|
||||||
Sdk androidSdk = createAndroidSdk(getTestSdkPath(), getPlatformDir());
|
|
||||||
AndroidSdkAdditionalData data = (AndroidSdkAdditionalData)androidSdk.getSdkAdditionalData();
|
|
||||||
if (data != null) {
|
|
||||||
AndroidPlatform androidPlatform = data.getAndroidPlatform();
|
|
||||||
if (androidPlatform != null) {
|
|
||||||
// Put default platforms in the list before non-default ones so they'll be looked at first.
|
|
||||||
return androidPlatform.getSdkData();
|
|
||||||
} else {
|
|
||||||
fail("No getAndroidPlatform() associated with the AndroidSdkAdditionalData: " + data);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fail("Could not find data associated with the SDK: " + androidSdk.getName());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a description of the given elements, suitable as unit test golden file output */
|
|
||||||
public static String describeElements(@Nullable PsiElement[] elements) {
|
|
||||||
if (elements == null) {
|
|
||||||
return "Empty";
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (PsiElement target : elements) {
|
|
||||||
appendElementDescription(sb, target);
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Appends a description of the given element, suitable as unit test golden file output */
|
|
||||||
public static void appendElementDescription(@NotNull StringBuilder sb, @NotNull PsiElement element) {
|
|
||||||
if (element instanceof LazyValueResourceElementWrapper) {
|
|
||||||
LazyValueResourceElementWrapper wrapper = (LazyValueResourceElementWrapper)element;
|
|
||||||
XmlAttributeValue value = wrapper.computeElement();
|
|
||||||
if (value != null) {
|
|
||||||
element = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PsiFile file = element.getContainingFile();
|
|
||||||
int offset = element.getTextOffset();
|
|
||||||
TextRange segment = element.getTextRange();
|
|
||||||
appendSourceDescription(sb, file, offset, segment);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Appends a description of the given elements, suitable as unit test golden file output */
|
|
||||||
public static void appendSourceDescription(@NotNull StringBuilder sb, @Nullable PsiFile file, int offset, @Nullable Segment segment) {
|
|
||||||
if (file != null && segment != null) {
|
|
||||||
if (ResourceHelper.getFolderType(file) != null) {
|
|
||||||
assertNotNull(file.getParent());
|
|
||||||
sb.append(file.getParent().getName());
|
|
||||||
sb.append("/");
|
|
||||||
}
|
|
||||||
sb.append(file.getName());
|
|
||||||
sb.append(':');
|
|
||||||
String text = file.getText();
|
|
||||||
int lineNumber = 1;
|
|
||||||
for (int i = 0; i < offset; i++) {
|
|
||||||
if (text.charAt(i) == '\n') {
|
|
||||||
lineNumber++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sb.append(lineNumber);
|
|
||||||
sb.append(":");
|
|
||||||
sb.append('\n');
|
|
||||||
int startOffset = segment.getStartOffset();
|
|
||||||
int endOffset = segment.getEndOffset();
|
|
||||||
assertTrue(offset == -1 || offset >= startOffset);
|
|
||||||
assertTrue(offset == -1 || offset <= endOffset);
|
|
||||||
|
|
||||||
int lineStart = startOffset;
|
|
||||||
while (lineStart > 0 && text.charAt(lineStart - 1) != '\n') {
|
|
||||||
lineStart--;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip over leading whitespace
|
|
||||||
while (lineStart < startOffset && Character.isWhitespace(text.charAt(lineStart))) {
|
|
||||||
lineStart++;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lineEnd = startOffset;
|
|
||||||
while (lineEnd < text.length() && text.charAt(lineEnd) != '\n') {
|
|
||||||
lineEnd++;
|
|
||||||
}
|
|
||||||
String indent = " ";
|
|
||||||
sb.append(indent);
|
|
||||||
sb.append(text.substring(lineStart, lineEnd));
|
|
||||||
sb.append('\n');
|
|
||||||
sb.append(indent);
|
|
||||||
for (int i = lineStart; i < lineEnd; i++) {
|
|
||||||
if (i == offset) {
|
|
||||||
sb.append('|');
|
|
||||||
} else if (i >= startOffset && i <= endOffset) {
|
|
||||||
sb.append('~');
|
|
||||||
} else {
|
|
||||||
sb.append(' ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sb.append(offset);
|
|
||||||
sb.append(":?");
|
|
||||||
}
|
|
||||||
sb.append('\n');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -62,7 +62,8 @@ public abstract class AbstractAndroidJpsTestCase : JpsBuildTestCase() {
|
|||||||
addJdk(jdkName)
|
addJdk(jdkName)
|
||||||
val properties = JpsAndroidSdkProperties("android-21", jdkName)
|
val properties = JpsAndroidSdkProperties("android-21", jdkName)
|
||||||
val sdkPath = getHomePath() + "/../dependencies/androidSDK"
|
val sdkPath = getHomePath() + "/../dependencies/androidSDK"
|
||||||
val library = myModel!!.getGlobal().addSdk<JpsSimpleElement<JpsAndroidSdkProperties>>(SDK_NAME, sdkPath, "", JpsAndroidSdkType.INSTANCE, JpsSimpleElementImpl(properties))
|
val library = myModel!!.getGlobal().addSdk<JpsSimpleElement<JpsAndroidSdkProperties>>(SDK_NAME, sdkPath, "",
|
||||||
|
JpsAndroidSdkType.INSTANCE, JpsSimpleElementImpl(properties))
|
||||||
library!!.addRoot(File(sdkPath + "/platforms/android-21/android.jar"), JpsOrderRootType.COMPILED)
|
library!!.addRoot(File(sdkPath + "/platforms/android-21/android.jar"), JpsOrderRootType.COMPILED)
|
||||||
return library.getProperties()
|
return library.getProperties()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user