Merge remote-tracking branch 'origin/master'

Conflicts:
	js/js.tests/test/org/jetbrains/k2js/test/SingleFileTranslationTest.java
	js/js.tests/test/org/jetbrains/k2js/test/semantics/StdLibTestToJSTest.java
This commit is contained in:
Pavel V. Talanov
2012-07-04 18:32:24 +04:00
158 changed files with 4376 additions and 1097 deletions
+1
View File
@@ -3,6 +3,7 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Kotlin.iml" filepath="$PROJECT_DIR$/Kotlin.iml" />
<module fileurl="file://$PROJECT_DIR$/compiler/android-tests/android-tests.iml" filepath="$PROJECT_DIR$/compiler/android-tests/android-tests.iml" />
<module fileurl="file://$PROJECT_DIR$/compiler/backend/backend.iml" filepath="$PROJECT_DIR$/compiler/backend/backend.iml" />
<module fileurl="file://$PROJECT_DIR$/build-tools/build-tools.iml" filepath="$PROJECT_DIR$/build-tools/build-tools.iml" />
<module fileurl="file://$PROJECT_DIR$/compiler/cli/cli.iml" filepath="$PROJECT_DIR$/compiler/cli/cli.iml" />
+31
View File
@@ -0,0 +1,31 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Codegen Tests on Android" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<module name="android-tests" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="PACKAGE_NAME" value="org.jetbrains.jet.compiler.android" />
<option name="MAIN_CLASS_NAME" value="org.jetbrains.jet.compiler.android.AndroidRunner" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
</component>
+1
View File
@@ -4,6 +4,7 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="$MODULE_DIR$/libraries/out" />
<excludeFolder url="file://$MODULE_DIR$/android.tests.dependencies" />
<excludeFolder url="file://$MODULE_DIR$/dist" />
<excludeFolder url="file://$MODULE_DIR$/ideaSDK/config" />
<excludeFolder url="file://$MODULE_DIR$/ideaSDK/system" />
+5 -17
View File
@@ -382,29 +382,17 @@
</jar>
</target>
<target name="jdkHeaders">
<target name="jdkAnnotations">
<cleandir dir="${output}/classes/stdlib"/>
<java classname="org.jetbrains.jet.cli.jvm.K2JVMCompiler" failonerror="true">
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
<arg value="-src"/>
<arg value="${basedir}/jdk-headers/src"/>
<arg value="-output"/>
<arg value="${output}/classes/jdk-headers"/>
<arg value="-mode"/>
<arg value="jdkHeaders"/>
</java>
<jar destfile="${kotlin-home}/lib/alt/kotlin-jdk-headers.jar">
<fileset dir="${output}/classes/jdk-headers"/>
<jar destfile="${kotlin-home}/lib/alt/kotlin-jdk-annotations.jar">
<fileset dir="${basedir}/jdk-annotations"/>
<manifest>
<attribute name="Built-By" value="JetBrains"/>
<attribute name="Implementation-Vendor" value="JetBrains"/>
<attribute name="Implementation-Title" value="Kotlin Compiler JDK Headers"/>
<attribute name="Implementation-Title" value="Kotlin Compiler JDK Annotations"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
@@ -471,7 +459,7 @@
</target>
<target name="dist"
depends="init,prepareDist,injectorsGenerator,generateInjectors,compiler,compilerSources,antTools,jdkHeaders,runtime,lang,jslib"/>
depends="init,prepareDist,injectorsGenerator,generateInjectors,compiler,compilerSources,antTools,jdkAnnotations,runtime,lang,jslib"/>
<target name="zip" depends="dist">
<zip destfile="${output}/${output.name}.zip">
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.jetbrains.jet.compiler.android"
android:versionCode="1"
android:versionName="1.0">
<!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library,
which is needed when building test cases. -->
<application>
<uses-library android:name="android.test.runner" />
</application>
<!--
This declares that this application uses the instrumentation test runner targeting
the package of com.example. To execute the tests use the command:
"adb shell am instrument -w com.example.tests/android.test.InstrumentationTestRunner"
-->
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="org.jetbrains.jet.compiler.android"
android:label="Tests for org.jetbrains.jet.compiler.android"/>
</manifest>
@@ -0,0 +1,18 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.
tested.project.dir=tested-module
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="testsForAndroid" default="help" basedir="">
<property file="local.properties"/>
<property file="ant.properties"/>
<loadproperties srcFile="project.properties"/>
<import file="custom_rules.xml" optional="true"/>
<import file="${sdk.dir}/tools/ant/build.xml"/>
<target name="pack_libraries">
<jar basedir="libs/codegen-test-output" destfile="libs/test.jar"/>
<delete dir="libs/codegen-test-output"/>
</target>
</project>
@@ -0,0 +1,12 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
#sdk.dir=compiler/android-tests/android-module/android-sdk/android-sdk-windows
#sdk.dir.relative=android-sdk/android-sdk-windows
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt
# Project target.
target=android-10
@@ -0,0 +1,41 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.android;
import junit.framework.TestCase;
import java.lang.reflect.Method;
/**
* @author Natalia.Ukhorskaya
*/
public class AbstractCodegenTestCaseOnAndroid extends TestCase {
protected void invokeBoxMethod(String filePath) throws Exception {
try {
Class clazz;
clazz = Class.forName(filePath.replaceAll("\\\\|-|\\.|/", "_") + ".namespace");
Method method;
method = clazz.getMethod("box");
assertEquals("OK", method.invoke(null));
}
catch (Throwable e) {
throw new RuntimeException("File: " + filePath, e);
}
}
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="">
<application>
</application>
</manifest>
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="idea-full" level="project" />
<orderEntry type="module" module-name="cli" />
<orderEntry type="module" module-name="compiler-tests" />
<orderEntry type="module" module-name="frontend.java" />
<orderEntry type="module" module-name="frontend" />
<orderEntry type="module" module-name="backend" />
</component>
</module>
@@ -0,0 +1,221 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.io.FileUtil;
import junit.framework.*;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.compiler.ant.AntRunner;
import org.jetbrains.jet.compiler.download.SDKDownloader;
import org.jetbrains.jet.compiler.emulator.Emulator;
import org.jetbrains.jet.compiler.run.PermissionManager;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Natalia.Ukhorskaya
*/
public class CodegenTestsOnAndroidRunner {
private static final Pattern ERROR_IN_TEST_OUTPUT_PATTERN =
Pattern.compile("([\\s]+at .*| Caused .*| java.lang.RuntimeException: File: .*|[\\s]+\\.\\.\\. .* more| Error in .*)");
private static final Pattern NUMBER_OF_TESTS_IF_FAILED = Pattern.compile("Tests run: ([0-9]*), Failures: ([0-9]*), Errors: ([0-9]*)");
private static final Pattern NUMBER_OF_TESTS_OK = Pattern.compile(" OK \\(([0-9]*) tests\\)");
private final PathManager pathManager;
public static TestSuite getTestSuite(PathManager pathManager) {
return new CodegenTestsOnAndroidRunner(pathManager).generateTestSuite();
}
private CodegenTestsOnAndroidRunner(PathManager pathManager) {
this.pathManager = pathManager;
}
private TestSuite generateTestSuite() {
TestSuite suite = new TestSuite("MySuite");
String resultOutput = runTests();
// Test name -> stackTrace
final Map<String, String> resultMap = parseOutputForFailedTests(resultOutput);
final Statistics statistics;
// If map is empty => there are no failed tests
if (resultMap.isEmpty()) {
// Clear tmp folder where we run android tests
FileUtil.delete(new File(pathManager.getTmpFolder()));
statistics = parseOutputForTestsNumberIfTestsPassed(resultOutput);
}
else {
statistics = parseOutputForTestsNumberIfThereIsFailedTests(resultOutput);
for (final Map.Entry<String, String> entry : resultMap.entrySet()) {
suite.addTest(new TestCase("run") {
@Override
public String getName() {
return entry.getKey();
}
@Override
protected void runTest() throws Throwable {
Assert.fail(entry.getValue() + "See more information in log above.");
}
});
}
}
Assert.assertNotNull("Cannot parse number of failed tests from final line", statistics);
Assert.assertEquals("Number of stackTraces != failed tests on the final line", resultMap.size(),
statistics.failed + statistics.errors);
suite.addTest(new TestCase("run") {
@Override
public String getName() {
return "testAll: Total: " + statistics.total + ", Failures: " + statistics.failed + ", Errors: " + statistics.errors;
}
@Override
protected void runTest() throws Throwable {
Assert.assertTrue(true);
}
});
return suite;
}
/*
Output example:
[exec] Error in testKt344:
[exec] java.lang.RuntimeException: File: compiler\testData\codegen\regressions\kt344.jet
[exec] at org.jetbrains.jet.compiler.android.AbstractCodegenTestCaseOnAndroid.invokeBoxMethod(AbstractCodegenTestCaseOnAndroid.java:38)
[exec] at org.jetbrains.jet.compiler.android.CodegenTestCaseOnAndroid.testKt344(CodegenTestCaseOnAndroid.java:595)
[exec] at java.lang.reflect.Method.invokeNative(Native Method)
[exec] at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
[exec] Caused by: java.lang.reflect.InvocationTargetException
[exec] at java.lang.reflect.Method.invokeNative(Native Method)
[exec] at org.jetbrains.jet.compiler.android.AbstractCodegenTestCaseOnAndroid.invokeBoxMethod(AbstractCodegenTestCaseOnAndroid.java:35)
[exec] ... 13 more
[exec] Caused by: java.lang.VerifyError: compiler_testData_codegen_regressions_kt344_jet.namespace$t6$foo$1
[exec] at compiler_testData_codegen_regressions_kt344_jet.namespace.t6(dummy.jet:94)
[exec] at compiler_testData_codegen_regressions_kt344_jet.namespace.box(dummy.jet:185)
[exec] ... 16 more
[exec] ...............
[exec] Error in testKt529:
*/
private Map<String, String> parseOutputForFailedTests(String output) {
Map<String, String> result = new HashMap<String, String>();
StringBuilder builder = new StringBuilder();
String failedTestNamePrefix = " Error in ";
String lastFailedTestName = "";
Matcher matcher = ERROR_IN_TEST_OUTPUT_PATTERN.matcher(output);
while (matcher.find()) {
String groupValue = matcher.group();
if (groupValue.startsWith(failedTestNamePrefix)) {
if (builder.length() > 0) {
result.put(lastFailedTestName, builder.toString());
builder.delete(0, builder.length());
}
lastFailedTestName = groupValue.substring(failedTestNamePrefix.length());
}
builder.append(groupValue);
builder.append("\n");
}
if (builder.length() > 0) {
result.put(lastFailedTestName, builder.toString());
}
return result;
}
//[exec] Tests run: 225, Failures: 0, Errors: 2
@Nullable
private Statistics parseOutputForTestsNumberIfThereIsFailedTests(String output) {
Matcher matcher = NUMBER_OF_TESTS_IF_FAILED.matcher(output);
if (matcher.find()) {
return new Statistics(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)),
Integer.parseInt(matcher.group(3)));
}
return null;
}
//[exec] OK (223 tests)
@Nullable
private Statistics parseOutputForTestsNumberIfTestsPassed(String output) {
Matcher matcher = NUMBER_OF_TESTS_OK.matcher(output);
if (matcher.find()) {
return new Statistics(Integer.parseInt(matcher.group(1)), 0, 0);
}
return null;
}
public String runTests() {
ApplicationManager.setApplication(null, new Disposable() {
@Override
public void dispose() {
}
});
File rootForAndroidDependencies = new File(pathManager.getDependenciesRoot());
if (!rootForAndroidDependencies.exists()) {
rootForAndroidDependencies.mkdirs();
}
SDKDownloader downloader = new SDKDownloader(pathManager);
Emulator emulator = new Emulator(pathManager);
AntRunner antRunner = new AntRunner(pathManager);
downloader.downloadAll();
downloader.unzipAll();
PermissionManager.setPermissions(pathManager);
antRunner.packLibraries();
emulator.createEmulator();
emulator.startEmulator();
try {
emulator.waitEmulatorStart();
antRunner.cleanOutput();
antRunner.compileSources();
antRunner.installApplicationOnEmulator();
return antRunner.runTestsOnEmulator();
}
finally {
emulator.stopEmulator();
}
}
private static class Statistics {
public final int total;
public final int errors;
public final int failed;
private Statistics(int total, int failed, int errors) {
this.total = total;
this.failed = failed;
this.errors = errors;
}
}
}
@@ -0,0 +1,84 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler;
/**
* @author Natalia.Ukhorskaya
*/
public class PathManager {
private final String tmpFolder;
private final String rootFolder;
public PathManager(String rootFolder, String tmpFolder) {
this.tmpFolder = tmpFolder;
this.rootFolder = rootFolder;
}
public String getPlatformFolderInAndroidSdk() {
return getAndroidSdkRoot() + "/platforms";
}
public String getPlatformToolsFolderInAndroidSdk() {
return getAndroidSdkRoot() + "/platform-tools";
}
public String getToolsFolderInAndroidSdk() {
return getAndroidSdkRoot() + "/tools";
}
public String getOutputForCompiledFiles() {
return tmpFolder + "/libs/codegen-test-output";
}
public String getLibsFolderInAndroidTestedModuleTmpFolder() {
return tmpFolder + "/tested-module/libs";
}
public String getLibsFolderInAndroidTmpFolder() {
return tmpFolder + "/libs";
}
public String getSrcFolderInAndroidTmpFolder() {
return tmpFolder + "/src";
}
public String getAndroidSdkRoot() {
return getDependenciesRoot() + "/android-sdk";
}
public String getDependenciesRoot() {
return rootFolder + "/android.tests.dependencies";
}
public String getRootForDownload() {
return getDependenciesRoot() + "/download";
}
public String getAntBinDirectory() {
return getDependenciesRoot() + "/apache-ant-1.8.0/bin";
}
public String getAndroidModuleRoot() {
return rootFolder + "/compiler/android-tests/android-module";
}
public String getTmpFolder() {
return tmpFolder;
}
}
@@ -0,0 +1,116 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.ant;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.jet.compiler.PathManager;
import org.jetbrains.jet.compiler.run.RunUtils;
import org.jetbrains.jet.compiler.run.result.RunResult;
import java.util.ArrayList;
import java.util.List;
/**
* @author Natalia.Ukhorskaya
*/
public class AntRunner {
private final List<String> listOfAntCommands;
public AntRunner(PathManager pathManager) {
listOfAntCommands = new ArrayList<String>();
String antCmdName = SystemInfo.isWindows ? "ant.bat" : "ant";
listOfAntCommands.add(pathManager.getAntBinDirectory() + "/" + antCmdName);
listOfAntCommands.add("-Dsdk.dir=" + pathManager.getAndroidSdkRoot());
listOfAntCommands.add("-buildfile");
listOfAntCommands.add(pathManager.getTmpFolder() + "/build.xml");
}
/* Pack compiled sources on first step to one jar file */
public void packLibraries() {
System.out.println("Pack libraries...");
RunResult result = RunUtils.execute(generateCommandLine("pack_libraries"));
if (!result.getStatus()) {
throw new RuntimeException(result.getOutput());
}
}
/* Clean output directory */
public void cleanOutput() {
System.out.println("Clearing output directory...");
RunResult result = RunUtils.execute(generateCommandLine("clean"));
if (!result.getStatus()) {
throw new RuntimeException(result.getOutput());
}
}
public void compileSources() {
System.out.println("Compiling sources...");
RunResult result = RunUtils.execute(generateCommandLine("debug"));
if (!result.getStatus()) {
throw new RuntimeException(result.getOutput());
}
}
public void installApplicationOnEmulator() {
System.out.println("Installing apk...");
RunResult result = RunUtils.execute(generateCommandLine("installt"));
String resultOutput = result.getOutput();
if (!isInstallSuccessful(resultOutput)) {
installApplicationOnEmulator();
return;
} else {
System.out.println(resultOutput);
}
if (!result.getStatus()) {
throw new RuntimeException(resultOutput);
}
}
public String runTestsOnEmulator() {
System.out.println("Running tests...");
RunResult result = RunUtils.execute(generateCommandLine("test"));
String resultOutput = result.getOutput();
if (!result.getStatus()) {
throw new RuntimeException(resultOutput);
}
else {
return resultOutput;
}
}
private static boolean isInstallSuccessful(String output) {
if (output.contains("Is the system running?")) {
try {
System.out.println("Device not ready. Waiting for 20 sec.");
Thread.sleep(20000);
return false;
}
catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
return true;
}
private GeneralCommandLine generateCommandLine(String taskName) {
GeneralCommandLine commandLine = new GeneralCommandLine(listOfAntCommands);
commandLine.addParameter(taskName);
return commandLine;
}
}
@@ -0,0 +1,224 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.download;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.jet.compiler.PathManager;
import org.jetbrains.jet.compiler.run.RunUtils;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
/**
* @author Natalia.Ukhorskaya
*/
public class SDKDownloader {
private final String platformZipPath;
private final String platformToolsZipPath;
private final String toolsZipPath;
private final String antZipPath;
private final PathManager pathManager;
public SDKDownloader(PathManager pathManager) {
this.pathManager = pathManager;
platformZipPath = pathManager.getRootForDownload() + "/platforms.zip";
platformToolsZipPath = pathManager.getRootForDownload() + "/platform-tools.zip";
toolsZipPath = pathManager.getRootForDownload() + "/tools.zip";
antZipPath = pathManager.getRootForDownload() + "/apache-ant-1.8.0.zip";
}
public void downloadPlatform() {
download("https://dl-ssl.google.com/android/repository/android-2.3.3_r02-linux.zip", platformZipPath); //Same for all platforms
}
public void downloadPlatformTools() {
String downloadURL;
if (SystemInfo.isWindows) {
downloadURL = "http://dl-ssl.google.com/android/repository/platform-tools_r11-windows.zip";
}
else if (SystemInfo.isMac) {
downloadURL = "http://dl-ssl.google.com/android/repository/platform-tools_r11-macosx.zip";
}
else if (SystemInfo.isUnix) {
downloadURL = "http://dl-ssl.google.com/android/repository/platform-tools_r11-linux.zip";
}
else {
throw new IllegalStateException("Your operating system doesn't supported yet.");
}
download(downloadURL, platformToolsZipPath);
}
public void downloadTools() {
String downloadURL;
if (SystemInfo.isWindows) {
downloadURL = "http://dl.google.com/android/repository/tools_r19-windows.zip";
}
else if (SystemInfo.isMac) {
downloadURL = "http://dl.google.com/android/repository/tools_r19-macosx.zip";
}
else if (SystemInfo.isUnix) {
downloadURL = "http://dl.google.com/android/repository/tools_r19-linux.zip";
}
else {
throw new IllegalStateException("Your operating system doesn't supported yet.");
}
download(downloadURL, toolsZipPath);
}
public void downloadAnt() {
download("http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.0-bin.zip", antZipPath);
}
public void downloadAll() {
downloadTools();
downloadPlatform();
downloadPlatformTools();
downloadAnt();
}
public void unzipAll() {
unzip(platformZipPath, pathManager.getPlatformFolderInAndroidSdk());
unzip(platformToolsZipPath, pathManager.getAndroidSdkRoot());
unzip(toolsZipPath, pathManager.getAndroidSdkRoot());
unzip(antZipPath, pathManager.getDependenciesRoot());
}
public void deleteAll() {
delete(platformZipPath);
delete(platformToolsZipPath);
delete(toolsZipPath);
delete(antZipPath);
}
protected void download(String urlString, String output) {
System.out.println("Start downloading: " + urlString + " to " + output);
OutputStream outStream = null;
URLConnection urlConnection = null;
InputStream is = null;
try {
URL Url;
byte[] buf;
int read;
//int written = 0;
Url = new URL(urlString);
File outputFile = new File(output);
outputFile.getParentFile().mkdirs();
if (outputFile.exists()) {
System.out.println("File was already downloaded: " + output);
return;
}
outputFile.createNewFile();
FileOutputStream outputStream = new FileOutputStream(outputFile);
outStream = new BufferedOutputStream(outputStream);
urlConnection = Url.openConnection();
is = urlConnection.getInputStream();
buf = new byte[1024];
while ((read = is.read(buf)) != -1) {
outStream.write(buf, 0, read);
//written += read;
}
}
catch (Exception e) {
throw new RuntimeException(e);
}
finally {
RunUtils.close(outStream);
}
System.out.println("Finish downloading: " + urlString + " to " + output);
}
protected void unzip(String pathToFile, String outputFolder) {
System.out.println("Start unzipping: " + pathToFile + " to " + outputFolder);
String pathToUnzip;
if (outputFolder.equals(pathManager.getPlatformFolderInAndroidSdk())) {
pathToUnzip = outputFolder;
}
else {
pathToUnzip = outputFolder + "/" + FileUtil.getNameWithoutExtension(new File(pathToFile));
}
if (new File(pathToUnzip).listFiles() != null) {
System.out.println("File was already unzipped: " + pathToFile);
return;
}
try {
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(new FileInputStream(pathToFile));
zipentry = zipinputstream.getNextEntry();
try {
while (zipentry != null) {
String entryName = zipentry.getName();
int n;
File outputFile = new File(outputFolder + "/" + entryName);
if (zipentry.isDirectory()) {
outputFile.mkdirs();
zipinputstream.closeEntry();
zipentry = zipinputstream.getNextEntry();
continue;
}
else {
File parentFile = outputFile.getParentFile();
if (parentFile != null && !parentFile.exists()) {
parentFile.mkdirs();
}
outputFile.createNewFile();
}
FileOutputStream fileoutputstream = new FileOutputStream(outputFile);
try {
while ((n = zipinputstream.read(buf, 0, 1024)) > -1) {
fileoutputstream.write(buf, 0, n);
}
}
finally {
fileoutputstream.close();
}
zipinputstream.closeEntry();
zipentry = zipinputstream.getNextEntry();
}
zipinputstream.close();
}
catch (IOException e) {
System.err.println("Entry name: " + zipentry.getName());
e.printStackTrace();
}
}
catch (Exception e) {
e.printStackTrace();
}
System.out.println("Finish unzipping: " + pathToFile + " to " + outputFolder);
}
protected void delete(String filePath) {
File file = new File(filePath);
file.delete();
}
}
@@ -0,0 +1,123 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.emulator;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.jet.compiler.PathManager;
import org.jetbrains.jet.compiler.run.RunUtils;
import org.jetbrains.jet.compiler.run.result.RunResult;
/**
* @author Natalia.Ukhorskaya
*/
public class Emulator {
private final PathManager pathManager;
public Emulator(PathManager pathManager) {
this.pathManager = pathManager;
}
private GeneralCommandLine getCreateCommand() {
GeneralCommandLine commandLine = new GeneralCommandLine();
String androidCmdName = SystemInfo.isWindows ? "android.bat" : "android";
commandLine.setExePath(pathManager.getToolsFolderInAndroidSdk() + "/" + androidCmdName);
commandLine.addParameter("create");
commandLine.addParameter("avd");
commandLine.addParameter("--force");
commandLine.addParameter("-n");
commandLine.addParameter("my_avd");
commandLine.addParameter("-t");
commandLine.addParameter("1");
return commandLine;
}
private GeneralCommandLine getStartCommand() {
GeneralCommandLine commandLine = new GeneralCommandLine();
String emulatorCmdName = SystemInfo.isWindows ? "emulator.exe" : "emulator";
commandLine.setExePath(pathManager.getToolsFolderInAndroidSdk() + "/" + emulatorCmdName);
commandLine.addParameter("-avd");
commandLine.addParameter("my_avd");
commandLine.addParameter("-no-audio");
commandLine.addParameter("-no-window");
return commandLine;
}
private GeneralCommandLine getWaitCommand() {
GeneralCommandLine commandLine = new GeneralCommandLine();
String adbCmdName = SystemInfo.isWindows ? "adb.exe" : "adb";
commandLine.setExePath(pathManager.getPlatformToolsFolderInAndroidSdk() + "/" + adbCmdName);
commandLine.addParameter("wait-for-device");
return commandLine;
}
private GeneralCommandLine getStopCommandForAdb() {
GeneralCommandLine commandLine = new GeneralCommandLine();
String adbCmdName = SystemInfo.isWindows ? "adb.exe" : "adb";
commandLine.setExePath(pathManager.getPlatformToolsFolderInAndroidSdk() + "/" + adbCmdName);
commandLine.addParameter("kill-server");
return commandLine;
}
private GeneralCommandLine getStopCommand() {
GeneralCommandLine commandLine = new GeneralCommandLine();
if (SystemInfo.isWindows) {
commandLine.setExePath("taskkill");
commandLine.addParameter("/F");
commandLine.addParameter("/IM");
commandLine.addParameter("emulator-arm.exe");
}
else {
commandLine.setExePath(pathManager.getPlatformToolsFolderInAndroidSdk() + "/adb");
commandLine.addParameter("emu");
commandLine.addParameter("kill");
}
return commandLine;
}
public void createEmulator() {
System.out.println("Creating emulator...");
checkResult(RunUtils.execute(getCreateCommand(), "no"));
}
public void startEmulator() {
System.out.println("Starting emulator...");
checkResult(RunUtils.executeOnSeparateThread(getStartCommand(), false));
}
public void waitEmulatorStart() {
System.out.println("Waiting for emulator start...");
checkResult(RunUtils.execute(getWaitCommand()));
}
public void stopEmulator() {
System.out.println("Stopping emulator...");
checkResult(RunUtils.execute(getStopCommand()));
System.out.println("Stopping adb...");
checkResult(RunUtils.execute(getStopCommandForAdb()));
}
private static void checkResult(RunResult result) {
if (!result.getStatus()) {
throw new RuntimeException(result.getOutput());
}
}
}
@@ -0,0 +1,52 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.run;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.jet.compiler.PathManager;
/**
* @author Natalia.Ukhorskaya
*/
public class PermissionManager {
private PermissionManager() {
}
public static void setPermissions(PathManager pathManager) {
if (!SystemInfo.isWindows) {
RunUtils.execute(generateChmodCmd(pathManager.getPlatformToolsFolderInAndroidSdk() + "/aapt"));
RunUtils.execute(generateChmodCmd(pathManager.getPlatformToolsFolderInAndroidSdk() + "/adb"));
RunUtils.execute(generateChmodCmd(pathManager.getPlatformToolsFolderInAndroidSdk() + "/dx"));
RunUtils.execute(generateChmodCmd(pathManager.getToolsFolderInAndroidSdk() + "/emulator"));
RunUtils.execute(generateChmodCmd(pathManager.getToolsFolderInAndroidSdk() + "/tools/ddms"));
RunUtils.execute(generateChmodCmd(pathManager.getToolsFolderInAndroidSdk() + "/tools/android"));
RunUtils.execute(generateChmodCmd(pathManager.getToolsFolderInAndroidSdk() + "/tools/emulator-arm"));
RunUtils.execute(generateChmodCmd(pathManager.getToolsFolderInAndroidSdk() + "/tools/zipalign"));
RunUtils.execute(generateChmodCmd(pathManager.getAntBinDirectory() + "/ant"));
}
}
private static GeneralCommandLine generateChmodCmd(String path) {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath("chmod");
commandLine.addParameter("u+x");
commandLine.addParameter(path);
return commandLine;
}
}
@@ -0,0 +1,184 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.run;
import com.google.common.base.Charsets;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.process.OSProcessHandler;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Ref;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.compiler.run.result.RunResult;
import java.io.Closeable;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
/**
* @author Natalia.Ukhorskaya
*/
public class RunUtils {
private RunUtils() {
}
public static RunResult execute(final GeneralCommandLine commandLine) {
return run(commandLine, null);
}
public static RunResult execute(final GeneralCommandLine commandLine, @Nullable String input) {
return run(commandLine, input);
}
public static RunResult executeOnSeparateThread(final GeneralCommandLine commandLine, boolean waitForEnd) {
return executeOnSeparateThread(commandLine, waitForEnd, null);
}
public static RunResult executeOnSeparateThread(final GeneralCommandLine commandLine,
boolean waitForEnd,
@Nullable final String input) {
final Ref<RunResult> resultRef = new Ref<RunResult>();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
resultRef.set(RunUtils.run(commandLine, input));
}
});
t.start();
if (waitForEnd) {
try {
t.wait(300000);
return resultRef.get();
}
catch (InterruptedException e) {
new RunResult(false, getStackTrace(e));
}
}
return new RunResult(true, "OK");
}
private static RunResult run(final GeneralCommandLine commandLine, @Nullable final String input) {
final StringBuilder stdOut = new StringBuilder();
final StringBuilder stdErr = new StringBuilder();
final OSProcessHandler handler;
try {
handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString(), Charsets.UTF_8);
if (input != null) {
handler.getProcessInput().write(input.getBytes());
}
close(handler.getProcessInput());
}
catch (ExecutionException e) {
return new RunResult(false, getStackTrace(e));
}
catch (IOException e) {
return new RunResult(false, getStackTrace(e));
}
final ProcessAdapter listener = new ProcessAdapter() {
@Override
public void onTextAvailable(final ProcessEvent event, final Key outputType) {
String str = event.getText();
if (outputType == ProcessOutputTypes.STDOUT || outputType == ProcessOutputTypes.SYSTEM) {
stdOut.append(str);
if (!commandLine.getCommandLineString().contains("install")) {
System.out.print(str);
}
}
else if (outputType == ProcessOutputTypes.STDERR) {
stdErr.append(str);
System.err.print(str);
}
}
};
handler.addProcessListener(listener);
handler.startNotify();
try {
handler.waitFor(300000);
}
catch (ProcessCanceledException e) {
return new RunResult(false, getStackTrace(e));
}
if (!handler.isProcessTerminated()) {
return new RunResult(false, "Timeout exception: execution was terminated after 5 min.");
}
handler.removeProcessListener(listener);
int exitCode = handler.getProcess().exitValue();
if (exitCode != 0) {
return new RunResult(false, builderToString(stdOut) + builderToString(stdErr));
}
else {
String output = builderToString(stdOut) + builderToString(stdErr);
if (!isResultOk(output)) {
return new RunResult(false, output);
}
return new RunResult(true, output);
}
}
private static String builderToString(StringBuilder builder) {
return builder.length() > 0 ? builder.toString() : "";
}
public static void close(Closeable closeable) {
try {
if (closeable != null) {
closeable.close();
}
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
public static String getStackTrace(Throwable t) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
try {
printWriter.write(t.getMessage());
printWriter.write("\n");
t.printStackTrace(printWriter);
}
finally {
close(printWriter);
}
return writer.toString();
}
public static boolean isResultOk(String output) {
if (output.contains("BUILD FAILED")
|| output.contains("Build failed")) {
return false;
}
return true;
}
}
@@ -0,0 +1,41 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.run.result;
/**
* @author Natalia.Ukhorskaya
*/
public class RunResult {
private final boolean status;
private final String output;
public RunResult(boolean ok, String output) {
status = ok;
this.output = output;
}
//true - ok
//false - fail
public boolean getStatus() {
return status;
}
public String getOutput() {
return output;
}
}
@@ -0,0 +1,53 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.android;
import com.google.common.io.Files;
import com.intellij.openapi.util.io.FileUtil;
import junit.framework.TestSuite;
import org.jetbrains.jet.compiler.CodegenTestsOnAndroidRunner;
import org.jetbrains.jet.compiler.PathManager;
import java.io.File;
/**
* @author Natalia.Ukhorskaya
*/
public class AndroidRunner extends TestSuite {
public static TestSuite suite() throws Throwable {
File tmpFolder = Files.createTempDir();
System.out.println("Created temporary folder for running android tests: " + tmpFolder.getAbsolutePath());
File rootFolder = new File("");
PathManager pathManager = new PathManager(rootFolder.getAbsolutePath(), tmpFolder.getAbsolutePath());
FileUtil.copyDir(new File(pathManager.getAndroidModuleRoot()), new File(pathManager.getTmpFolder()));
try {
CodegenTestsOnAndroidGenerator.generate(pathManager);
}
catch(Throwable e) {
FileUtil.delete(new File(pathManager.getTmpFolder()));
throw new RuntimeException(e);
}
System.out.println("Run tests on android...");
return CodegenTestsOnAndroidRunner.getTestSuite(pathManager);
}
}
@@ -0,0 +1,203 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.android;
import com.google.common.collect.Lists;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testFramework.UsefulTestCase;
import junit.framework.Assert;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.codegen.*;
import org.jetbrains.jet.compiler.PathManager;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetPsiFactory;
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
import org.jetbrains.jet.test.generator.Printer;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Natalia.Ukhorskaya
*/
public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
private final PathManager pathManager;
private final String testClassPackage = "org.jetbrains.jet.compiler.android";
private final String testClassName = "CodegenTestCaseOnAndroid";
private final String baseTestClassPackage = "org.jetbrains.jet.compiler.android";
private final String baseTestClassName = "AbstractCodegenTestCaseOnAndroid";
private final String generatorName = "CodegenTestsOnAndroidGenerator";
private JetCoreEnvironment environmentWithMockJdk = JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable, CompilerSpecialMode.JDK_HEADERS);
private JetCoreEnvironment environmentWithFullJdk = JetTestUtils.createEnvironmentWithFullJdk(myTestRootDisposable);
private final Pattern packagePattern = Pattern.compile("package (.*)");
private final List<String> generatedTestNames = Lists.newArrayList();
public static void generate(PathManager pathManager) throws Throwable {
new CodegenTestsOnAndroidGenerator(pathManager).generateOutputFiles();
}
private CodegenTestsOnAndroidGenerator(PathManager pathManager) {
this.pathManager = pathManager;
}
private void generateOutputFiles() throws Throwable {
prepareAndroidModule();
generateAndSave();
}
private void prepareAndroidModule() throws IOException {
System.out.println("Copying kotlin-runtime.jar in android module...");
copyKotlinRuntimeJar();
System.out.println("Check \"libs\" folder in tested android module...");
File libsFolderInTestedModule = new File(pathManager.getLibsFolderInAndroidTestedModuleTmpFolder());
if (!libsFolderInTestedModule.exists()) {
libsFolderInTestedModule.mkdirs();
}
}
private void copyKotlinRuntimeJar() throws IOException {
File kotlinRuntimeJar = new File(pathManager.getLibsFolderInAndroidTmpFolder() + "/kotlin-runtime.jar");
File kotlinRuntimeInDist = new File("dist/kotlinc/lib/kotlin-runtime.jar");
Assert.assertTrue("kotlin-runtime.jar in dist/kotlnc/lib/ doesn't exists. Run dist ant task before generating test for android.",
kotlinRuntimeInDist.exists());
FileUtil.copy(kotlinRuntimeInDist, kotlinRuntimeJar);
}
private void generateAndSave() throws Throwable {
System.out.println("Generating test files...");
StringBuilder out = new StringBuilder();
Printer p = new Printer(out);
p.print(FileUtil.loadFile(new File("injector-generator/copyright.txt")));
p.println("package " + testClassPackage + ";");
p.println();
p.println("import ", baseTestClassPackage, ".", baseTestClassName, ";");
p.println();
p.println("/* This class is generated by " + generatorName + ". DO NOT MODIFY MANUALLY */");
p.println("public class ", testClassName, " extends ", baseTestClassName, " {");
p.pushIndent();
File testDataSources = new File("compiler/testData/codegen/");
generateTestMethodsForDirectory(p, testDataSources);
p.popIndent();
p.println("}");
String testSourceFilePath =
pathManager.getSrcFolderInAndroidTmpFolder() + "/" + testClassPackage.replace(".", "/") + "/" + testClassName + ".java";
FileUtil.writeToFile(new File(testSourceFilePath), out.toString());
}
private void generateTestMethodsForDirectory(Printer p, File dir) throws IOException {
File[] files = dir.listFiles();
Assert.assertNotNull("Folder with testData is empty: " + dir.getAbsolutePath(), files);
Set<String> excludedFiles = SpecialFiles.getExcludedFiles();
Set<String> filesCompiledWithoutStdLib = SpecialFiles.getFilesCompiledWithoutStdLib();
for (File file : files) {
if (excludedFiles.contains(file.getName())) {
continue;
}
if (file.isDirectory()) {
generateTestMethodsForDirectory(p, file);
}
else {
String text = FileUtil.loadFile(file, true);
if (hasBoxMethod(text)) {
String generatedTestName = generateTestName(file.getName());
String packageName = file.getPath().replaceAll("\\\\|-|\\.|/", "_");
text = changePackage(packageName, text);
final ClassFileFactory factory;
if (filesCompiledWithoutStdLib.contains(file.getName())) {
factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithMockJdk);
}
else {
factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithFullJdk);
}
generateTestMethod(p, generatedTestName, StringUtil.escapeStringCharacters(file.getPath()));
File outputDir = new File(pathManager.getOutputForCompiledFiles());
if (!outputDir.exists()) {
outputDir.mkdirs();
}
Assert.assertTrue("Cannot create directory for compiled files", outputDir.exists());
CompileEnvironmentUtil.writeToOutputDirectory(factory, outputDir);
}
}
}
}
private ClassFileFactory getFactoryFromText(String filePath, String text, JetCoreEnvironment jetEnvironment) {
JetFile psiFile = JetPsiFactory.createFile(jetEnvironment.getProject(), text);
ClassFileFactory factory;
try {
factory = GenerationUtils.compileFileGetClassFileFactoryForTest(psiFile, jetEnvironment.getCompilerDependencies().getCompilerSpecialMode());
}
catch (Throwable e) {
throw new RuntimeException("Cannot compile: " + filePath + "\n" + text, e);
}
return factory;
}
private boolean hasBoxMethod(String text) {
return text.contains("fun box()");
}
private String changePackage(String testName, String text) {
if (text.contains("package ")) {
Matcher matcher = packagePattern.matcher(text);
return matcher.replaceAll("package " + testName);
}
else {
return "package " + testName + ";\n" + text;
}
}
private void generateTestMethod(Printer p, String testName, String namespace) {
p.println("public void test" + testName + "() throws Exception {");
p.pushIndent();
p.println("invokeBoxMethod(\"" + namespace + "\");");
p.popIndent();
p.println("}");
p.println();
}
private String generateTestName(String fileName) {
String result = FileUtil.getNameWithoutExtension(StringUtil.capitalize(fileName));
int i = 0;
while (generatedTestNames.contains(result)) {
result += "_" + i++;
}
generatedTestNames.add(result);
return result;
}
}
@@ -0,0 +1,95 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.compiler.android;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author Natalia.Ukhorskaya
*/
public class SpecialFiles {
private static final Set<String> excludedFiles = Sets.newHashSet();
private static final Set<String> filesCompiledWithoutStdLib = Sets.newHashSet();
static {
fillExcludedFiles();
fillFilesCompiledWithoutStdLib();
}
public static Set<String> getExcludedFiles() {
return excludedFiles;
}
public static Set<String> getFilesCompiledWithoutStdLib() {
return filesCompiledWithoutStdLib;
}
private static void fillFilesCompiledWithoutStdLib() {
filesCompiledWithoutStdLib.add("kt1953_class.kt"); // Exception in code
filesCompiledWithoutStdLib.add("basicmethodSuperClass.jet"); // Exception in code
filesCompiledWithoutStdLib.add("kt1980.kt"); // OVERLOAD_RESOLUTION_AMBIGUITY
filesCompiledWithoutStdLib.add("kt503.jet"); // OVERLOAD_RESOLUTION_AMBIGUITY
filesCompiledWithoutStdLib.add("kt504.jet"); // OVERLOAD_RESOLUTION_AMBIGUITY
filesCompiledWithoutStdLib.add("kt772.jet"); // OVERLOAD_RESOLUTION_AMBIGUITY
filesCompiledWithoutStdLib.add("kt773.jet"); // OVERLOAD_RESOLUTION_AMBIGUITY
filesCompiledWithoutStdLib.add("kt796_797.jet"); // OVERLOAD_RESOLUTION_AMBIGUITY
filesCompiledWithoutStdLib.add("kt950.jet"); // OVERLOAD_RESOLUTION_AMBIGUITY
}
private static void fillExcludedFiles() {
excludedFiles.add("referencesStaticInnerClassMethod.kt"); // Must compile Java files before
excludedFiles.add("referencesStaticInnerClassMethodL2.kt"); // Must compile Java files before
excludedFiles.add("namespaceQualifiedMethod.jet"); // Cannot change package name
excludedFiles.add("kt1482_2279.kt"); // Cannot change package name
excludedFiles.add("kt1482.kt"); // Cannot change package name
excludedFiles.add("importFromClassObject.jet"); // Cannot find usages in Codegen tests
excludedFiles.add("withtypeparams.jet"); // Cannot find usages in Codegen tests
excludedFiles.add("kt1113.kt"); // Commented
excludedFiles.add("kt326.jet"); // Commented
excludedFiles.add("kt694.jet"); // Commented
excludedFiles.add("kt285.jet"); // Commented
excludedFiles.add("kt857.jet"); // Commented
excludedFiles.add("kt1120.kt"); // Commented
excludedFiles.add("kt1213.kt"); // Commented
excludedFiles.add("kt882.jet"); // Commented
excludedFiles.add("kt789.jet"); // Commented
excludedFiles.add("isTypeParameter.jet"); // Commented
excludedFiles.add("nullability.jet"); // Commented
excludedFiles.add("genericFunction.jet"); // Commented
excludedFiles.add("forwardTypeParameter.jet"); // Commented
excludedFiles.add("kt259.jet"); // Commented
excludedFiles.add("classObjectMethod.jet"); // Commented
excludedFiles.add("kt1592.kt"); // Codegen don't execute blackBoxFile() on it
excludedFiles.add("box.kt"); // MultiFileTest
excludedFiles.add("kt684.jet"); // StackOverflow with StringBuilder (escape())
excludedFiles.add("kt1199.kt"); // Bug KT-2202
excludedFiles.add("kt344.jet"); // Bug KT-2251
excludedFiles.add("kt529.kt"); // Bug
}
private SpecialFiles() {
}
}
@@ -71,7 +71,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments, K2JSCompile
return ExitCode.INTERNAL_ERROR;
}
JetCoreEnvironment environmentForJS = JetCoreEnvironment.getCoreEnvironmentForJS(rootDisposable);
JetCoreEnvironment environmentForJS = JetCoreEnvironment.createCoreEnvironmentForJS(rootDisposable);
for (String sourceFile : arguments.sourceFiles) {
environmentForJS.addSources(sourceFile);
@@ -37,7 +37,6 @@ import org.jetbrains.jet.utils.PathUtil;
import java.io.File;
import java.io.PrintStream;
import java.util.Collections;
import java.util.List;
import static org.jetbrains.jet.cli.common.ExitCode.*;
@@ -58,17 +57,17 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
protected ExitCode doExecute(K2JVMCompilerArguments arguments, PrintingMessageCollector messageCollector, Disposable rootDisposable) {
CompilerSpecialMode mode = parseCompilerSpecialMode(arguments);
File jdkHeadersJar;
if (mode.includeJdkHeaders()) {
if (arguments.jdkHeaders != null) {
jdkHeadersJar = new File(arguments.jdkHeaders);
File jdkAnnotationsJar;
if (mode.includeJdkAnnotations()) {
if (arguments.jdkAnnotations != null) {
jdkAnnotationsJar = new File(arguments.jdkAnnotations);
}
else {
jdkHeadersJar = PathUtil.getAltHeadersPath();
jdkAnnotationsJar = PathUtil.getJdkAnnotationsPath();
}
}
else {
jdkHeadersJar = null;
jdkAnnotationsJar = null;
}
File runtimeJar;
@@ -84,7 +83,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
runtimeJar = null;
}
CompilerDependencies dependencies = new CompilerDependencies(mode, CompilerDependencies.findRtJar(), jdkHeadersJar, runtimeJar);
CompilerDependencies dependencies = new CompilerDependencies(mode, CompilerDependencies.findRtJar(), jdkAnnotationsJar, runtimeJar);
final List<String> argumentsSourceDirs = arguments.getSourceDirs();
if (!arguments.script &&
@@ -97,7 +96,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
return ExitCode.OK;
}
JetCoreEnvironment environment = JetCoreEnvironment.getCoreEnvironmentForJVM(rootDisposable, dependencies);
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, dependencies);
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(environment, messageCollector, arguments.script);
messageCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment",
@@ -206,6 +205,12 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
List<File> classpath = getClasspath(arguments);
CompileEnvironmentUtil.addToClasspath(configuration.getEnvironment(), Iterables.toArray(classpath, File.class));
}
if (arguments.annotations != null) {
for (String root : Splitter.on(File.pathSeparatorChar).split(arguments.annotations)) {
configuration.getEnvironment().addExternalAnnotationsRoot(PathUtil.jarFileOrDirectoryToVirtualFile(new File(root)));
}
}
}
@NotNull
@@ -48,14 +48,17 @@ public class K2JVMCompilerArguments extends CompilerArguments {
@Argument(value = "classpath", description = "classpath to use when compiling")
public String classpath;
@Argument(value = "annotations", description = "paths to external annotations")
public String annotations;
@Argument(value = "includeRuntime", description = "include Kotlin runtime in to resulting jar")
public boolean includeRuntime;
@Argument(value = "stdlib", description = "Path to the stdlib.jar")
public String stdlib;
@Argument(value = "jdkHeaders", description = "Path to the kotlin-jdk-headers.jar")
public String jdkHeaders;
@Argument(value = "jdkAnnotations", description = "Path to the kotlin-jdk-annotations.jar")
public String jdkAnnotations;
@Argument(value = "mode", description = "Special compiler modes: stubs or jdkHeaders")
public String mode;
@@ -140,7 +140,7 @@ public class CompileEnvironmentUtil {
}
};
CompilerDependencies dependencies = CompilerDependencies.compilerDependenciesForProduction(CompilerSpecialMode.REGULAR);
JetCoreEnvironment scriptEnvironment = JetCoreEnvironment.getCoreEnvironmentForJVM(disposable, dependencies);
JetCoreEnvironment scriptEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(disposable, dependencies);
scriptEnvironment.addSources(moduleScriptFile);
GenerationState generationState = KotlinToJVMBytecodeCompiler
@@ -33,6 +33,8 @@ import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
import org.jetbrains.jet.lang.resolve.java.extAnnotations.CoreAnnotationsProvider;
import org.jetbrains.jet.lang.resolve.java.extAnnotations.ExternalAnnotationsProvider;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.plugin.JetFileType;
@@ -47,14 +49,15 @@ import java.util.List;
*/
public class JetCoreEnvironment extends JavaCoreEnvironment {
private final List<JetFile> sourceFiles = new ArrayList<JetFile>();
private final CoreAnnotationsProvider annotationsProvider;
@NotNull
public static JetCoreEnvironment getCoreEnvironmentForJS(Disposable disposable) {
public static JetCoreEnvironment createCoreEnvironmentForJS(Disposable disposable) {
return new JetCoreEnvironment(disposable, CompilerDependencies.compilerDependenciesForProduction(CompilerSpecialMode.JS));
}
@NotNull
public static JetCoreEnvironment getCoreEnvironmentForJVM(Disposable disposable, @NotNull CompilerDependencies dependencies) {
public static JetCoreEnvironment createCoreEnvironmentForJVM(Disposable disposable, @NotNull CompilerDependencies dependencies) {
return new JetCoreEnvironment(disposable, dependencies);
}
@@ -86,11 +89,15 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
addToClasspath(compilerDependencies.getJdkJar());
}
if (compilerSpecialMode.includeJdkHeaders()) {
for (VirtualFile root : compilerDependencies.getJdkHeaderRoots()) {
addLibraryRoot(root);
annotationsProvider = new CoreAnnotationsProvider();
if (compilerSpecialMode.includeJdkAnnotations()) {
for (VirtualFile root : compilerDependencies.getJdkAnnotationsRoots()) {
annotationsProvider.addExternalAnnotationsRoot(root);
}
}
myProject.registerService(ExternalAnnotationsProvider.class, annotationsProvider);
if (compilerSpecialMode.includeKotlinRuntime()) {
addToClasspath(compilerDependencies.getRuntimeJar());
}
@@ -98,6 +105,10 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
JetStandardLibrary.initialize(getProject());
}
public void addExternalAnnotationsRoot(VirtualFile root) {
annotationsProvider.addExternalAnnotationsRoot(root);
}
public MockApplication getApplication() {
return myApplication;
}
@@ -44,6 +44,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.plugin.JetLanguage;
import org.jetbrains.jet.plugin.JetMainDetector;
import org.jetbrains.jet.utils.ExceptionUtils;
import org.jetbrains.jet.utils.PathUtil;
import org.jetbrains.jet.utils.Progress;
import java.io.File;
@@ -79,6 +80,10 @@ public class KotlinToJVMBytecodeCompiler {
configuration.getEnvironment().addToClasspath(new File(classpathRoot));
}
for (String annotationsRoot : moduleBuilder.getAnnotationsRoots()) {
configuration.getEnvironment().addExternalAnnotationsRoot(PathUtil.jarFileOrDirectoryToVirtualFile(new File(annotationsRoot)));
}
GenerationState generationState = analyzeAndGenerate(configuration);
if (generationState == null) {
return null;
@@ -30,13 +30,16 @@ import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.resolve.DescriptorRenderer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Evgeny Gerashchenko
@@ -53,6 +56,9 @@ class AlternativeSignatureData {
private JetType altReturnType;
private List<TypeParameterDescriptor> altTypeParameters;
private Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters =
new HashMap<TypeParameterDescriptor, TypeParameterDescriptorImpl>();
AlternativeSignatureData(
@NotNull PsiMethodWrapper method,
@NotNull JavaDescriptorResolver.ValueParameterDescriptors valueParameterDescriptors,
@@ -68,12 +74,18 @@ class AlternativeSignatureData {
Project project = method.getPsiMethod().getProject();
altFunDeclaration = JetPsiFactory.createFunction(project, signature);
for (TypeParameterDescriptor tp : methodTypeParameters) {
originalToAltTypeParameters.put(tp, TypeParameterDescriptorImpl
.createForFurtherModification(tp.getContainingDeclaration(), tp.getAnnotations(),
tp.isReified(), tp.getVariance(), tp.getName(), tp.getIndex()));
}
try {
checkForSyntaxErrors();
computeTypeParameters(methodTypeParameters);
computeValueParameters(valueParameterDescriptors);
computeReturnType(returnType);
computeTypeParameters(methodTypeParameters);
}
catch (AlternativeSignatureMismatchException e) {
error = e.getMessage();
@@ -113,7 +125,7 @@ class AlternativeSignatureData {
return altTypeParameters;
}
static JetType computeType(JetTypeElement alternativeTypeElement, final JetType autoType) {
JetType computeType(JetTypeElement alternativeTypeElement, final JetType autoType) {
//noinspection NullableProblems
return alternativeTypeElement.accept(new JetVisitor<JetType, Void>() {
@Override
@@ -154,7 +166,8 @@ class AlternativeSignatureData {
}
private JetType visitCommonType(@NotNull String expectedFqNamePostfix, @NotNull JetTypeElement type) {
ClassifierDescriptor declarationDescriptor = autoType.getConstructor().getDeclarationDescriptor();
TypeConstructor originalTypeConstructor = autoType.getConstructor();
ClassifierDescriptor declarationDescriptor = originalTypeConstructor.getDeclarationDescriptor();
assert declarationDescriptor != null;
String fqName = DescriptorUtils.getFQName(declarationDescriptor).toSafe().getFqName();
if (!fqName.endsWith(expectedFqNamePostfix)) {
@@ -196,8 +209,26 @@ class AlternativeSignatureData {
}
altArguments.add(new TypeProjection(variance, alternativeType));
}
return new JetTypeImpl(autoType.getAnnotations(), autoType.getConstructor(), false,
altArguments, autoType.getMemberScope());
TypeConstructor typeConstructor = originalTypeConstructor;
ClassifierDescriptor typeConstructorClassifier = typeConstructor.getDeclarationDescriptor();
if (typeConstructorClassifier instanceof TypeParameterDescriptor
&& originalToAltTypeParameters.containsKey(typeConstructorClassifier)) {
typeConstructor = originalToAltTypeParameters.get(typeConstructorClassifier).getTypeConstructor();
}
JetScope memberScope;
if (typeConstructorClassifier instanceof TypeParameterDescriptor) {
memberScope = ((TypeParameterDescriptor) typeConstructorClassifier).getUpperBoundsAsType().getMemberScope();
}
else if (typeConstructorClassifier instanceof ClassDescriptor) {
memberScope = ((ClassDescriptor) typeConstructorClassifier).getMemberScope(altArguments);
}
else {
throw new AssertionError("Unexpected class of type constructor classifier "
+ (typeConstructorClassifier == null ? "null" : typeConstructorClassifier.getClass().getName()));
}
return new JetTypeImpl(autoType.getAnnotations(), typeConstructor, false,
altArguments, memberScope);
}
@Override
@@ -274,10 +305,7 @@ class AlternativeSignatureData {
altTypeParameters = new ArrayList<TypeParameterDescriptor>();
for (int i = 0, size = typeParameters.size(); i < size; i++) {
TypeParameterDescriptor pd = typeParameters.get(i);
DeclarationDescriptor containingDeclaration = pd.getContainingDeclaration();
TypeParameterDescriptorImpl altParamDescriptor = TypeParameterDescriptorImpl
.createForFurtherModification(containingDeclaration, pd.getAnnotations(),
pd.isReified(), pd.getVariance(), pd.getName(), pd.getIndex());
TypeParameterDescriptorImpl altParamDescriptor = originalToAltTypeParameters.get(pd);
int upperBoundIndex = 0;
for (JetType upperBound : pd.getUpperBounds()) {
JetTypeElement altTypeElement;
@@ -1,3 +1,4 @@
/*
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
@@ -35,14 +36,14 @@ public class CompilerDependencies {
@Nullable
private final File jdkJar;
@Nullable
private final File jdkHeadersJar;
private final File jdkAnnotationsJar;
@Nullable
private final File runtimeJar;
public CompilerDependencies(@NotNull CompilerSpecialMode compilerSpecialMode, @Nullable File jdkJar, @Nullable File jdkHeadersJar, @Nullable File runtimeJar) {
public CompilerDependencies(@NotNull CompilerSpecialMode compilerSpecialMode, @Nullable File jdkJar, @Nullable File jdkAnnotationsJar, @Nullable File runtimeJar) {
this.compilerSpecialMode = compilerSpecialMode;
this.jdkJar = jdkJar;
this.jdkHeadersJar = jdkHeadersJar;
this.jdkAnnotationsJar = jdkAnnotationsJar;
this.runtimeJar = runtimeJar;
if (compilerSpecialMode.includeJdk()) {
@@ -50,9 +51,9 @@ public class CompilerDependencies {
throw new IllegalArgumentException("jdk must be included for mode " + compilerSpecialMode);
}
}
if (compilerSpecialMode.includeJdkHeaders()) {
if (jdkHeadersJar == null) {
throw new IllegalArgumentException("jdkHeaders must be included for mode " + compilerSpecialMode);
if (compilerSpecialMode.includeJdkAnnotations()) {
if (jdkAnnotationsJar == null) {
throw new IllegalArgumentException("jdkAnnotations must be included for mode " + compilerSpecialMode);
}
}
if (compilerSpecialMode.includeKotlinRuntime()) {
@@ -72,20 +73,15 @@ public class CompilerDependencies {
return jdkJar;
}
@Nullable
public File getJdkHeadersJar() {
return jdkHeadersJar;
}
@Nullable
public File getRuntimeJar() {
return runtimeJar;
}
@NotNull
public List<VirtualFile> getJdkHeaderRoots() {
if (compilerSpecialMode.includeJdkHeaders()) {
return Collections.singletonList(PathUtil.jarFileOrDirectoryToVirtualFile(jdkHeadersJar));
public List<VirtualFile> getJdkAnnotationsRoots() {
if (compilerSpecialMode.includeJdkAnnotations()) {
return Collections.singletonList(PathUtil.jarFileOrDirectoryToVirtualFile(jdkAnnotationsJar));
}
else {
return Collections.emptyList();
@@ -107,7 +103,7 @@ public class CompilerDependencies {
return new CompilerDependencies(
compilerSpecialMode,
compilerSpecialMode.includeJdk() ? findRtJar() : null,
compilerSpecialMode.includeJdkHeaders() ? PathUtil.getAltHeadersPath() : null,
compilerSpecialMode.includeJdkAnnotations() ? PathUtil.getJdkAnnotationsPath() : null,
compilerSpecialMode.includeKotlinRuntime() ? PathUtil.getDefaultRuntimePath() : null);
}
@@ -28,7 +28,7 @@ public enum CompilerSpecialMode {
JS,
;
public boolean includeJdkHeaders() {
public boolean includeJdkAnnotations() {
return this == REGULAR || this == STDLIB || this == IDEA;
}
@@ -27,12 +27,11 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.psi.JetNamedFunction;
import org.jetbrains.jet.lang.psi.JetPsiFactory;
import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.lang.resolve.*;
import org.jetbrains.jet.lang.resolve.constants.*;
import org.jetbrains.jet.lang.resolve.constants.StringValue;
import org.jetbrains.jet.lang.resolve.java.extAnnotations.ExternalAnnotationsProvider;
import org.jetbrains.jet.lang.resolve.java.kt.JetClassAnnotation;
import org.jetbrains.jet.lang.resolve.java.kt.PsiAnnotationWithFlags;
import org.jetbrains.jet.lang.resolve.name.FqName;
@@ -873,7 +872,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
if (parameter.getJetValueParameter().nullable()) {
transformedType = TypeUtils.makeNullableAsSpecified(outType, parameter.getJetValueParameter().nullable());
}
else if (parameter.getPsiParameter().getModifierList().findAnnotation(JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null) {
else if (findAnnotation(parameter.getPsiParameter(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null) {
transformedType = TypeUtils.makeNullableAsSpecified(outType, false);
}
else {
@@ -1151,7 +1150,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
}
else {
propertyType = semanticServices.getTypeTransformer().transformToType(anyMember.getType().getPsiType(), typeVariableResolverForPropertyInternals);
if (anyMember.getType().getPsiNotNullOwner().getModifierList().findAnnotation(JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null) {
if (findAnnotation(anyMember.getType().getPsiNotNullOwner(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null) {
propertyType = TypeUtils.makeNullableAsSpecified(propertyType, false);
}
else if (members.getter == null && members.setter == null && members.field.getMember().isFinal() && members.field.getMember().isStatic()) {
@@ -1420,7 +1419,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
}
private List<AnnotationDescriptor> resolveAnnotations(PsiModifierListOwner owner, @NotNull List<Runnable> tasks) {
PsiAnnotation[] psiAnnotations = owner.getModifierList().getAnnotations();
PsiAnnotation[] psiAnnotations = getAllAnnotations(owner);
List<AnnotationDescriptor> r = Lists.newArrayListWithCapacity(psiAnnotations.length);
for (PsiAnnotation psiAnnotation : psiAnnotations) {
AnnotationDescriptor annotation = resolveAnnotation(psiAnnotation, tasks);
@@ -1549,7 +1548,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
if (method.getJetMethod().returnTypeNullable()) {
return TypeUtils.makeNullableAsSpecified(transformedType, true);
}
else if (method.getPsiMethod().getModifierList().findAnnotation(JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null) {
else if (findAnnotation(method.getPsiMethod(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null) {
return TypeUtils.makeNullableAsSpecified(transformedType, false);
}
else {
@@ -1608,4 +1607,34 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
}
return r;
}
@NotNull
public static PsiAnnotation[] getAllAnnotations(@NotNull PsiModifierListOwner owner) {
List<PsiAnnotation> result = new ArrayList<PsiAnnotation>();
PsiModifierList list = owner.getModifierList();
if (list != null) {
result.addAll(Arrays.asList(list.getAnnotations()));
}
PsiAnnotation[] externalAnnotations = ExternalAnnotationsProvider.getInstance(owner.getProject()).findExternalAnnotations(owner);
if (externalAnnotations != null) {
result.addAll(Arrays.asList(externalAnnotations));
}
return result.toArray(new PsiAnnotation[result.size()]);
}
@Nullable
public static PsiAnnotation findAnnotation(@NotNull PsiModifierListOwner owner, @NotNull String fqName) {
PsiModifierList list = owner.getModifierList();
if (list != null) {
PsiAnnotation found = list.findAnnotation(fqName);
if (found != null) {
return found;
}
}
return ExternalAnnotationsProvider.getInstance(owner.getProject()).findExternalAnnotation(owner, fqName);
}
}
@@ -59,7 +59,7 @@ public class PsiClassFinderForJvm implements PsiClassFinder {
@PostConstruct
public void initialize() {
this.altClassFinder = new AltClassFinder(project, compilerDependencies.getJdkHeaderRoots());
this.altClassFinder = new AltClassFinder(project, compilerDependencies.getJdkAnnotationsRoots());
this.javaSearchScope = new DelegatingGlobalSearchScope(GlobalSearchScope.allScope(project)) {
@Override
public boolean contains(VirtualFile file) {
@@ -104,8 +104,8 @@ public class PsiClassFinderForJvm implements PsiClassFinder {
return null;
}
PsiAnnotation assertInvisibleAnnotation = result.getModifierList().findAnnotation(
JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().getFqName());
PsiAnnotation assertInvisibleAnnotation = JavaDescriptorResolver
.findAnnotation(result, JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().getFqName());
if (assertInvisibleAnnotation != null) {
if (runtimeClassesHandleMode == RuntimeClassesHandleMode.IGNORE) {
return null;
@@ -0,0 +1,203 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.java.extAnnotations;
import com.intellij.openapi.util.Comparing;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.StringBuilderSpinAllocator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This class is copied from IDEA.
* This class should be eliminated when Kotlin will depend on IDEA 12.x (KT-2326)
* @author Evgeny Gerashchenko
* @since 6/26/12
*/
@Deprecated
public class ClassUtil {
private ClassUtil() {}
public static void formatClassName(@NotNull final PsiClass aClass, final StringBuilder buf) {
final String qName = aClass.getQualifiedName();
if (qName != null) {
buf.append(qName);
}
else {
final PsiClass parentClass = getContainerClass(aClass);
if (parentClass != null) {
formatClassName(parentClass, buf);
buf.append("$");
buf.append(getNonQualifiedClassIdx(aClass));
final String name = aClass.getName();
if (name != null) {
buf.append(name);
}
}
}
}
@Nullable
private static PsiClass getContainerClass(final PsiClass aClass) {
PsiElement parent = aClass.getContext();
while (parent != null && !(parent instanceof PsiClass)) {
parent = parent.getContext();
}
return (PsiClass)parent;
}
public static int getNonQualifiedClassIdx(@NotNull final PsiClass psiClass) {
final int[] result = {-1};
final PsiClass containingClass = getContainerClass(psiClass);
if (containingClass != null) {
containingClass.accept(new JavaRecursiveElementVisitor() {
private int myCurrentIdx = 0;
@Override public void visitElement(PsiElement element) {
if (result[0] == -1) {
super.visitElement(element);
}
}
@Override public void visitClass(PsiClass aClass) {
super.visitClass(aClass);
if (aClass.getQualifiedName() == null) {
myCurrentIdx++;
if (psiClass == aClass) {
result[0] = myCurrentIdx;
}
}
}
});
}
return result[0];
}
public static PsiClass findNonQualifiedClassByIndex(final String indexName, @NotNull final PsiClass containingClass,
final boolean jvmCompatible) {
String prefix = getDigitPrefix(indexName);
final int idx = prefix.length() > 0 ? Integer.parseInt(prefix) : -1;
final String name = prefix.length() < indexName.length() ? indexName.substring(prefix.length()) : null;
final PsiClass[] result = new PsiClass[1];
containingClass.accept(new JavaRecursiveElementVisitor() {
private int myCurrentIdx = 0;
@Override public void visitElement(PsiElement element) {
if (result[0] == null) {
super.visitElement(element);
}
}
@Override public void visitClass(PsiClass aClass) {
if (!jvmCompatible) {
super.visitClass(aClass);
if (aClass.getQualifiedName() == null) {
myCurrentIdx++;
if (myCurrentIdx == idx && Comparing.strEqual(name, aClass.getName())) {
result[0] = aClass;
}
}
return;
}
if (aClass == containingClass) {
super.visitClass(aClass);
return;
}
if (Comparing.strEqual(name, aClass.getName())) {
myCurrentIdx++;
if (myCurrentIdx == idx || idx == -1) {
result[0] = aClass;
}
}
}
@Override public void visitTypeParameter(final PsiTypeParameter classParameter) {
if (!jvmCompatible) {
super.visitTypeParameter(classParameter);
}
else {
visitElement(classParameter);
}
}
});
return result[0];
}
private static String getDigitPrefix(final String indexName) {
final StringBuilder builder = StringBuilderSpinAllocator.alloc();
try {
for (int i = 0; i < indexName.length(); i++) {
final char c = indexName.charAt(i);
if (Character.isDigit(c)) {
builder.append(c);
}
else {
break;
}
}
return builder.toString();
}
finally {
StringBuilderSpinAllocator.dispose(builder);
}
}
@Nullable
public static PsiClass findPsiClass(final PsiManager psiManager,
String externalName,
PsiClass psiClass,
boolean jvmCompatible) {
return findPsiClass(psiManager, externalName, psiClass, jvmCompatible, GlobalSearchScope.allScope(psiManager.getProject()));
}
@Nullable
public static PsiClass findPsiClass(final PsiManager psiManager,
String externalName,
@Nullable PsiClass psiClass,
boolean jvmCompatible,
final GlobalSearchScope scope) {
final int topIdx = externalName.indexOf('$');
if (topIdx > -1) {
if (psiClass == null) {
psiClass = JavaPsiFacade.getInstance(psiManager.getProject())
.findClass(externalName.substring(0, topIdx), scope);
}
if (psiClass == null) return null;
externalName = externalName.substring(topIdx + 1);
return findSubclass(psiManager, externalName, psiClass, jvmCompatible);
} else {
return JavaPsiFacade.getInstance(psiManager.getProject()).findClass(externalName, scope);
}
}
@Nullable
private static PsiClass findSubclass(final PsiManager psiManager,
final String externalName,
final PsiClass psiClass,
final boolean jvmCompatible) {
final int nextIdx = externalName.indexOf('$');
if (nextIdx > -1) {
final PsiClass anonymousClass = findNonQualifiedClassByIndex(externalName.substring(0, nextIdx), psiClass, jvmCompatible);
if (anonymousClass == null) return null;
return findPsiClass(psiManager, externalName.substring(nextIdx), anonymousClass, jvmCompatible);
}
else {
return findNonQualifiedClassByIndex(externalName, psiClass, jvmCompatible);
}
}
}
@@ -0,0 +1,254 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.java.extAnnotations;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.StreamUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.containers.ConcurrentWeakHashMap;
import com.intellij.util.containers.ConcurrentWeakValueHashMap;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
/**
* This class is copied from IDEA.
* This class should be eliminated when Kotlin will depend on IDEA 12.x (KT-2326)
* @author Evgeny Gerashchenko
* @since 6/26/12
*/
@Deprecated
public class CoreAnnotationsProvider extends ExternalAnnotationsProvider {
private static final Logger LOG = Logger.getInstance("#" + CoreAnnotationsProvider.class.getName());
@NotNull private static final List<PsiFile> NULL = new ArrayList<PsiFile>();
@NotNull private final ConcurrentMap<String, List<PsiFile>>
myExternalAnnotations = new ConcurrentWeakValueHashMap<String, List<PsiFile>>();
private List<VirtualFile> externalAnnotationsRoots = new ArrayList<VirtualFile>();
public CoreAnnotationsProvider() {
}
@Nullable
private static String getExternalName(PsiModifierListOwner listOwner, boolean showParamName) {
return PsiFormatUtil.getExternalName(listOwner, showParamName, Integer.MAX_VALUE);
}
@Nullable
private static String getFQN(String packageName, @Nullable VirtualFile virtualFile) {
if (virtualFile == null) return null;
return StringUtil.getQualifiedName(packageName, virtualFile.getNameWithoutExtension());
}
@Nullable
protected static String getNormalizedExternalName(@NotNull PsiModifierListOwner owner) {
String externalName = getExternalName(owner, true);
if (externalName != null) {
if (owner instanceof PsiParameter && owner.getParent() instanceof PsiParameterList) {
final PsiMethod method = PsiTreeUtil.getParentOfType(owner, PsiMethod.class);
if (method != null) {
externalName =
externalName.substring(0, externalName.lastIndexOf(' ') + 1) + method.getParameterList().getParameterIndex((PsiParameter)owner);
}
}
final int idx = externalName.indexOf('(');
if (idx == -1) return externalName;
final StringBuilder buf = StringBuilderSpinAllocator.alloc();
try {
final int rightIdx = externalName.indexOf(')');
final String[] params = externalName.substring(idx + 1, rightIdx).split(",");
buf.append(externalName.substring(0, idx + 1));
for (String param : params) {
param = param.trim();
final int spaceIdx = param.indexOf(' ');
buf.append(spaceIdx > -1 ? param.substring(0, spaceIdx) : param).append(", ");
}
return StringUtil.trimEnd(buf.toString(), ", ") + externalName.substring(rightIdx);
}
finally {
StringBuilderSpinAllocator.dispose(buf);
}
}
return externalName;
}
@Override
@Nullable
public PsiAnnotation findExternalAnnotation(@NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQN) {
return collectExternalAnnotations(listOwner).get(annotationFQN);
}
@Override
@Nullable
public PsiAnnotation[] findExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) {
final Map<String, PsiAnnotation> result = collectExternalAnnotations(listOwner);
return result.isEmpty() ? null : result.values().toArray(new PsiAnnotation[result.size()]);
}
private final Map<PsiModifierListOwner, Map<String, PsiAnnotation>> cache = new ConcurrentWeakHashMap<PsiModifierListOwner, Map<String, PsiAnnotation>>();
@NotNull
private Map<String, PsiAnnotation> collectExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) {
Map<String, PsiAnnotation> map = cache.get(listOwner);
if (map == null) {
map = doCollect(listOwner);
cache.put(listOwner, map);
}
return map;
}
public void addExternalAnnotationsRoot(VirtualFile externalAnnotationsRoot) {
externalAnnotationsRoots.add(externalAnnotationsRoot);
}
private Map<String, PsiAnnotation> doCollect(@NotNull PsiModifierListOwner listOwner) {
final List<PsiFile> files = findExternalAnnotationsFiles(listOwner);
if (files == null) {
return Collections.emptyMap();
}
final Map<String, PsiAnnotation> result = new HashMap<String, PsiAnnotation>();
for (PsiFile file : files) {
if (!file.isValid()) continue;
final Document document;
try {
// CoreLocalVirtualFile.getInputStream() fails with AssertionError
VirtualFile virtualFile = file.getVirtualFile();
InputStream stream = "CoreLocalVirtualFile".equals(virtualFile.getClass().getSimpleName())
? new BufferedInputStream(new FileInputStream(virtualFile.getPath()))
: virtualFile.getInputStream();
document = JDOMUtil.loadDocument(escapeAttributes(StreamUtil.readText(stream)));
}
catch (IOException e) {
LOG.error(e);
continue;
}
catch (JDOMException e) {
LOG.error(e);
continue;
}
if (document == null) continue;
final Element rootElement = document.getRootElement();
if (rootElement == null) continue;
final String externalName = getExternalName(listOwner, false);
final String oldExternalName = getNormalizedExternalName(listOwner);
//noinspection unchecked
for (final Element element : (List<Element>) rootElement.getChildren()) {
final String className = element.getAttributeValue("name");
if (!Comparing.strEqual(className, externalName) && !Comparing.strEqual(className, oldExternalName)) {
continue;
}
//noinspection unchecked
for (Element annotationElement : (List<Element>) element.getChildren()) {
final String annotationFQN = annotationElement.getAttributeValue("name");
final StringBuilder buf = new StringBuilder();
//noinspection unchecked
for (Element annotationParameter : (List<Element>) annotationElement.getChildren()) {
buf.append(",");
final String nameValue = annotationParameter.getAttributeValue("name");
if (nameValue != null) {
buf.append(nameValue).append("=");
}
buf.append(annotationParameter.getAttributeValue("val"));
}
final String annotationText =
"@" + annotationFQN + (buf.length() > 0 ? "(" + StringUtil.trimStart(buf.toString(), ",") + ")" : "");
try {
result.put(annotationFQN,
JavaPsiFacade.getInstance(listOwner.getProject()).getElementFactory().createAnnotationFromText(
annotationText, null));
}
catch (IncorrectOperationException e) {
LOG.error(e);
}
}
}
}
return result;
}
@Nullable
private List<PsiFile> findExternalAnnotationsFiles(@NotNull PsiModifierListOwner listOwner) {
final PsiFile containingFile = listOwner.getContainingFile();
if (!(containingFile instanceof PsiJavaFile)) {
return null;
}
final PsiJavaFile javaFile = (PsiJavaFile)containingFile;
final String packageName = javaFile.getPackageName();
final VirtualFile virtualFile = containingFile.getVirtualFile();
String fqn = getFQN(packageName, virtualFile);
if (fqn == null) return null;
final List<PsiFile> files = myExternalAnnotations.get(fqn);
if (files == NULL) return null;
if (files != null) {
for (Iterator<PsiFile> it = files.iterator(); it.hasNext();) {
if (!it.next().isValid()) it.remove();
}
return files;
}
if (virtualFile == null) {
return null;
}
List<PsiFile> possibleAnnotationsXmls = new ArrayList<PsiFile>();
for (VirtualFile root : externalAnnotationsRoots) {
final VirtualFile ext = root.findFileByRelativePath(packageName.replace(".", "/") + "/" + "annotations.xml");
if (ext == null) continue;
final PsiFile psiFile = listOwner.getManager().findFile(ext);
possibleAnnotationsXmls.add(psiFile);
}
if (!possibleAnnotationsXmls.isEmpty()) {
myExternalAnnotations.put(fqn, possibleAnnotationsXmls);
return possibleAnnotationsXmls;
}
myExternalAnnotations.put(fqn, NULL);
return null;
}
// This method is used for legacy reasons.
// Old external annotations sometimes are bad XML: they have "<" and ">" characters in attributes values. To prevent SAX parser from
// failing, we escape attributes values.
@NotNull
private static String escapeAttributes(@NotNull String invalidXml) {
// We assume that XML has single- and double-quote characters only for attribute values, therefore we don't any complex parsing,
// just split by ['"] regexp instead
String[] split = invalidXml.split("[\"\']");
assert split.length % 2 == 1;
for (int i = 1; i < split.length; i += 2) {
split[i] = split[i].replace("<", "&lt;").replace(">", "&gt;");
}
return StringUtil.join(split, "\"");
}
}
@@ -0,0 +1,42 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.java.extAnnotations;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiModifierListOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This class should be eliminated when Kotlin will depend on IDEA 12.x (KT-2326)
* @author Evgeny Gerashchenko
* @since 6/26/12
*/
@Deprecated
public abstract class ExternalAnnotationsProvider {
@Nullable
public abstract PsiAnnotation findExternalAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN);
@Nullable
public abstract PsiAnnotation[] findExternalAnnotations(@NotNull PsiModifierListOwner listOwner);
public static ExternalAnnotationsProvider getInstance(@NotNull Project project) {
return ServiceManager.getService(project, ExternalAnnotationsProvider.class);
}
}
@@ -0,0 +1,235 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* User: anna
* Date: 28-Oct-2008
*/
package org.jetbrains.jet.lang.resolve.java.extAnnotations;
import com.intellij.psi.*;
import com.intellij.util.Function;
/**
* This class is copied from IDEA.
* This class should be eliminated when Kotlin will depend on IDEA 12.x (KT-2326)
* @author Evgeny Gerashchenko
* @since 6/26/12
*/
@Deprecated
public class PsiExpressionTrimRenderer extends JavaRecursiveElementWalkingVisitor {
private final StringBuilder myBuf;
public PsiExpressionTrimRenderer(final StringBuilder buf) {
myBuf = buf;
}
@Override
public void visitExpression(final PsiExpression expression) {
myBuf.append(expression.getText());
}
@Override
public void visitInstanceOfExpression(final PsiInstanceOfExpression expression) {
expression.getOperand().accept(this);
myBuf.append(" ").append(PsiKeyword.INSTANCEOF).append(" ");
final PsiTypeElement checkType = expression.getCheckType();
if (checkType != null) {
myBuf.append(checkType.getText());
}
}
@Override
public void visitParenthesizedExpression(final PsiParenthesizedExpression expression) {
myBuf.append("(");
final PsiExpression expr = expression.getExpression();
if (expr != null) {
expr.accept(this);
}
myBuf.append(")");
}
@Override
public void visitTypeCastExpression(final PsiTypeCastExpression expression) {
final PsiTypeElement castType = expression.getCastType();
if (castType != null) {
myBuf.append("(").append(castType.getText()).append(")");
}
final PsiExpression operand = expression.getOperand();
if (operand != null) {
operand.accept(this);
}
}
@Override
public void visitArrayAccessExpression(final PsiArrayAccessExpression expression) {
expression.getArrayExpression().accept(this);
myBuf.append("[");
final PsiExpression indexExpression = expression.getIndexExpression();
if (indexExpression != null) {
indexExpression.accept(this);
}
myBuf.append("]");
}
@Override
public void visitPrefixExpression(final PsiPrefixExpression expression) {
myBuf.append(expression.getOperationSign().getText());
final PsiExpression operand = expression.getOperand();
if (operand != null) {
operand.accept(this);
}
}
@Override
public void visitPostfixExpression(final PsiPostfixExpression expression) {
expression.getOperand().accept(this);
myBuf.append(expression.getOperationSign().getText());
}
@Override
public void visitPolyadicExpression(PsiPolyadicExpression expression) {
PsiExpression[] operands = expression.getOperands();
for (int i = 0; i < operands.length; i++) {
PsiExpression operand = operands[i];
if (i != 0) {
PsiJavaToken token = expression.getTokenBeforeOperand(operand);
myBuf.append(" ").append(token.getText()).append(" ");
}
operand.accept(this);
}
}
@Override
public void visitConditionalExpression(final PsiConditionalExpression expression) {
expression.getCondition().accept(this);
myBuf.append(" ? ");
final PsiExpression thenExpression = expression.getThenExpression();
if (thenExpression != null) {
thenExpression.accept(this);
}
myBuf.append(" : ");
final PsiExpression elseExpression = expression.getElseExpression();
if (elseExpression != null) {
elseExpression.accept(this);
}
}
@Override
public void visitAssignmentExpression(final PsiAssignmentExpression expression) {
expression.getLExpression().accept(this);
myBuf.append(expression.getOperationSign().getText());
final PsiExpression rExpression = expression.getRExpression();
if (rExpression != null) {
rExpression.accept(this);
}
}
@Override
public void visitReferenceExpression(final PsiReferenceExpression expr) {
final PsiExpression qualifierExpression = expr.getQualifierExpression();
if (qualifierExpression != null) {
qualifierExpression.accept(this);
myBuf.append(".");
}
myBuf.append(expr.getReferenceName());
}
@Override
public void visitMethodCallExpression(final PsiMethodCallExpression expr) {
expr.getMethodExpression().accept(this);
expr.getArgumentList().accept(this);
}
@Override
public void visitArrayInitializerExpression(final PsiArrayInitializerExpression expression) {
myBuf.append("{");
boolean first = true;
for (PsiExpression expr : expression.getInitializers()) {
if (!first) {
myBuf.append(", ");
}
first = false;
expr.accept(this);
}
myBuf.append("}");
}
@Override
public void visitExpressionList(final PsiExpressionList list) {
final PsiExpression[] args = list.getExpressions();
if (args.length > 0) {
myBuf.append("(...)");
}
else {
myBuf.append("()");
}
}
@Override
public void visitNewExpression(final PsiNewExpression expr) {
final PsiAnonymousClass anonymousClass = expr.getAnonymousClass();
final PsiExpressionList argumentList = expr.getArgumentList();
if (anonymousClass != null) {
myBuf.append(PsiKeyword.NEW).append(" ").append(anonymousClass.getBaseClassType().getPresentableText());
if (argumentList != null) argumentList.accept(this);
myBuf.append(" {...}");
}
else {
final PsiJavaCodeReferenceElement reference = expr.getClassReference();
if (reference != null) {
myBuf.append(PsiKeyword.NEW).append(" ").append(reference.getText());
final PsiExpression[] arrayDimensions = expr.getArrayDimensions();
final PsiType type = expr.getType();
final int dimensions = type != null ? type.getArrayDimensions() : arrayDimensions.length;
if (arrayDimensions.length > 0) myBuf.append("[");
for (int i = 0, arrayDimensionsLength = arrayDimensions.length; i < dimensions; i++) {
final PsiExpression dimension = i < arrayDimensionsLength ? arrayDimensions[i] : null;
if (i > 0) myBuf.append("][");
if (dimension != null) {
dimension.accept(this);
}
}
if (arrayDimensions.length > 0) myBuf.append("]");
if (argumentList != null) {
argumentList.accept(this);
}
final PsiArrayInitializerExpression arrayInitializer = expr.getArrayInitializer();
if (arrayInitializer != null) {
arrayInitializer.accept(this);
}
}
else {
myBuf.append(expr.getText());
}
}
}
public static String render(PsiExpression expression) {
StringBuilder buf = new StringBuilder();
expression.accept(new PsiExpressionTrimRenderer(buf));
return buf.toString();
}
}
@@ -0,0 +1,360 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.java.extAnnotations;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This class is copied from IDEA.
* This class should be eliminated when Kotlin will depend on IDEA 12.x (KT-2326)
* @author Evgeny Gerashchenko
* @since 6/26/12
*/
@Deprecated
public class PsiFormatUtil extends PsiFormatUtilBase {
@MagicConstant(flags = {SHOW_MODIFIERS, SHOW_TYPE, TYPE_AFTER, SHOW_CONTAINING_CLASS, SHOW_FQ_NAME, SHOW_NAME, SHOW_MODIFIERS, SHOW_INITIALIZER, SHOW_RAW_TYPE, SHOW_RAW_NON_TOP_TYPE, SHOW_FQ_CLASS_NAMES})
public @interface FormatVariableOptions {}
public static String formatVariable(PsiVariable variable, @FormatVariableOptions int options, PsiSubstitutor substitutor){
StringBuilder buffer = new StringBuilder();
formatVariable(variable, options, substitutor,buffer);
return buffer.toString();
}
private static void formatVariable(PsiVariable variable,
@FormatVariableOptions int options,
PsiSubstitutor substitutor,
@NotNull StringBuilder buffer){
if ((options & SHOW_MODIFIERS) != 0 && (options & MODIFIERS_AFTER) == 0){
formatModifiers(variable, options,buffer);
}
if ((options & SHOW_TYPE) != 0 && (options & TYPE_AFTER) == 0){
appendSpaceIfNeeded(buffer);
buffer.append(formatType(variable.getType(), options, substitutor));
}
if (variable instanceof PsiField && (options & SHOW_CONTAINING_CLASS) != 0){
PsiClass aClass = ((PsiField)variable).getContainingClass();
if (aClass != null){
String className = aClass.getName();
if (className != null) {
appendSpaceIfNeeded(buffer);
if ((options & SHOW_FQ_NAME) != 0){
String qName = aClass.getQualifiedName();
if (qName != null){
buffer.append(qName);
}
else{
buffer.append(className);
}
}
else{
buffer.append(className);
}
buffer.append('.');
}
}
if ((options & SHOW_NAME) != 0){
buffer.append(variable.getName());
}
}
else{
if ((options & SHOW_NAME) != 0){
String name = variable.getName();
if (StringUtil.isNotEmpty(name)){
appendSpaceIfNeeded(buffer);
buffer.append(name);
}
}
}
if ((options & SHOW_TYPE) != 0 && (options & TYPE_AFTER) != 0){
if ((options & SHOW_NAME) != 0 && variable.getName() != null){
buffer.append(':');
}
buffer.append(formatType(variable.getType(), options, substitutor));
}
if ((options & SHOW_MODIFIERS) != 0 && (options & MODIFIERS_AFTER) != 0){
formatModifiers(variable, options,buffer);
}
if ((options & SHOW_INITIALIZER) != 0){
PsiExpression initializer = variable.getInitializer();
if (initializer != null){
buffer.append(" = ");
String text = PsiExpressionTrimRenderer.render(initializer);
int index1 = text.lastIndexOf('\n');
if (index1 < 0) index1 = text.length();
int index2 = text.lastIndexOf('\r');
if (index2 < 0) index2 = text.length();
int index = Math.min(index1, index2);
buffer.append(text.substring(0, index));
if (index < text.length()) {
buffer.append(" ...");
}
}
}
}
@MagicConstant(flags = {SHOW_MODIFIERS, MODIFIERS_AFTER, SHOW_TYPE, TYPE_AFTER, SHOW_CONTAINING_CLASS, SHOW_FQ_NAME, SHOW_NAME, SHOW_PARAMETERS, SHOW_THROWS, SHOW_RAW_TYPE, SHOW_RAW_NON_TOP_TYPE, SHOW_FQ_CLASS_NAMES})
public @interface FormatMethodOptions {}
private static void formatMethod(PsiMethod method, PsiSubstitutor substitutor, @FormatMethodOptions int options, @FormatVariableOptions int parameterOptions, int maxParametersToShow, StringBuilder buffer){
if ((options & SHOW_MODIFIERS) != 0 && (options & MODIFIERS_AFTER) == 0){
formatModifiers(method, options,buffer);
}
if ((options & SHOW_TYPE) != 0 && (options & TYPE_AFTER) == 0){
PsiType type = method.getReturnType();
if (type != null){
appendSpaceIfNeeded(buffer);
buffer.append(formatType(type, options, substitutor));
}
}
if ((options & SHOW_CONTAINING_CLASS) != 0){
PsiClass aClass = method.getContainingClass();
if (aClass != null){
appendSpaceIfNeeded(buffer);
String name = aClass.getName();
if (name != null) {
if ((options & SHOW_FQ_NAME) != 0){
String qName = aClass.getQualifiedName();
if (qName != null){
buffer.append(qName);
}
else{
buffer.append(name);
}
}
else{
buffer.append(name);
}
buffer.append('.');
}
}
if ((options & SHOW_NAME) != 0){
buffer.append(method.getName());
}
}
else{
if ((options & SHOW_NAME) != 0){
appendSpaceIfNeeded(buffer);
buffer.append(method.getName());
}
}
if ((options & SHOW_PARAMETERS) != 0){
buffer.append('(');
PsiParameter[] parms = method.getParameterList().getParameters();
for(int i = 0; i < Math.min(parms.length, maxParametersToShow); i++) {
PsiParameter parm = parms[i];
if (i > 0){
buffer.append(", ");
}
buffer.append(formatVariable(parm, parameterOptions, substitutor));
}
if(parms.length > maxParametersToShow) {
buffer.append (", ...");
}
buffer.append(')');
}
if ((options & SHOW_TYPE) != 0 && (options & TYPE_AFTER) != 0){
PsiType type = method.getReturnType();
if (type != null){
if (buffer.length() > 0){
buffer.append(':');
}
buffer.append(formatType(type, options, substitutor));
}
}
if ((options & SHOW_MODIFIERS) != 0 && (options & MODIFIERS_AFTER) != 0){
formatModifiers(method, options,buffer);
}
if ((options & SHOW_THROWS) != 0){
String throwsText = formatReferenceList(method.getThrowsList(), options);
if (!throwsText.isEmpty()){
appendSpaceIfNeeded(buffer);
//noinspection HardCodedStringLiteral
buffer.append("throws ");
buffer.append(throwsText);
}
}
}
private static void formatModifiers(PsiElement element, int options, StringBuilder buffer) throws IllegalArgumentException{
PsiModifierList list;
boolean isInterface = false;
if (element instanceof PsiVariable){
list = ((PsiVariable)element).getModifierList();
}
else if (element instanceof PsiMethod){
list = ((PsiMethod)element).getModifierList();
}
else if (element instanceof PsiClass){
isInterface = ((PsiClass)element).isInterface();
list = ((PsiClass)element).getModifierList();
if (list == null) return;
}
else if (element instanceof PsiClassInitializer){
list = ((PsiClassInitializer)element).getModifierList();
if (list == null) return;
}
else{
throw new IllegalArgumentException();
}
if (list == null) return;
if ((options & SHOW_REDUNDANT_MODIFIERS) == 0
? list.hasExplicitModifier(PsiModifier.PUBLIC)
: list.hasModifierProperty(PsiModifier.PUBLIC)) {
appendModifier(buffer, PsiModifier.PUBLIC);
}
if (list.hasModifierProperty(PsiModifier.PROTECTED)){
appendModifier(buffer, PsiModifier.PROTECTED);
}
if (list.hasModifierProperty(PsiModifier.PRIVATE)){
appendModifier(buffer, PsiModifier.PRIVATE);
}
if ((options & SHOW_REDUNDANT_MODIFIERS) == 0
? list.hasExplicitModifier(PsiModifier.PACKAGE_LOCAL)
: list.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) {
if (element instanceof PsiClass && element.getParent() instanceof PsiDeclarationStatement) {// local class
appendModifier(buffer, "local");
}
else {
appendModifier(buffer, PsiBundle.visibilityPresentation(PsiModifier.PACKAGE_LOCAL));
}
}
if ((options & SHOW_REDUNDANT_MODIFIERS) == 0
? list.hasExplicitModifier(PsiModifier.STATIC)
: list.hasModifierProperty(PsiModifier.STATIC)) appendModifier(buffer, PsiModifier.STATIC);
if (!isInterface && //cls modifier list
((options & SHOW_REDUNDANT_MODIFIERS) == 0
? list.hasExplicitModifier(PsiModifier.ABSTRACT)
: list.hasModifierProperty(PsiModifier.ABSTRACT))) appendModifier(buffer, PsiModifier.ABSTRACT);
if ((options & SHOW_REDUNDANT_MODIFIERS) == 0
? list.hasExplicitModifier(PsiModifier.FINAL)
: list.hasModifierProperty(PsiModifier.FINAL)) appendModifier(buffer, PsiModifier.FINAL);
if (list.hasModifierProperty(PsiModifier.NATIVE) && (options & JAVADOC_MODIFIERS_ONLY) == 0){
appendModifier(buffer, PsiModifier.NATIVE);
}
if (list.hasModifierProperty(PsiModifier.SYNCHRONIZED) && (options & JAVADOC_MODIFIERS_ONLY) == 0){
appendModifier(buffer, PsiModifier.SYNCHRONIZED);
}
if (list.hasModifierProperty(PsiModifier.STRICTFP) && (options & JAVADOC_MODIFIERS_ONLY) == 0){
appendModifier(buffer, PsiModifier.STRICTFP);
}
if (list.hasModifierProperty(PsiModifier.TRANSIENT) &&
element instanceof PsiVariable // javac 5 puts transient attr for methods
){
appendModifier(buffer, PsiModifier.TRANSIENT);
}
if (list.hasModifierProperty(PsiModifier.VOLATILE)){
appendModifier(buffer, PsiModifier.VOLATILE);
}
}
private static void appendModifier(final StringBuilder buffer, final String modifier) {
appendSpaceIfNeeded(buffer);
buffer.append(modifier);
}
public static String formatReferenceList(PsiReferenceList list, int options){
StringBuilder buffer = new StringBuilder();
PsiJavaCodeReferenceElement[] refs = list.getReferenceElements();
for(int i = 0; i < refs.length; i++) {
PsiJavaCodeReferenceElement ref = refs[i];
if (i > 0){
buffer.append(", ");
}
buffer.append(formatReference(ref, options));
}
return buffer.toString();
}
public static String formatType(PsiType type, int options, @NotNull PsiSubstitutor substitutor){
type = substitutor.substitute(type);
if ((options & SHOW_RAW_TYPE) != 0) {
type = TypeConversionUtil.erasure(type);
} else if ((options & SHOW_RAW_NON_TOP_TYPE) != 0) {
if (!(PsiUtil.resolveClassInType(type) instanceof PsiTypeParameter)) {
final boolean preserveEllipsis = type instanceof PsiEllipsisType;
type = TypeConversionUtil.erasure(type);
if (preserveEllipsis && type instanceof PsiArrayType) {
type = new PsiEllipsisType(((PsiArrayType)type).getComponentType());
}
}
}
return (options & SHOW_FQ_CLASS_NAMES) == 0 ? type.getPresentableText() : type.getInternalCanonicalText();
}
public static String formatReference(PsiJavaCodeReferenceElement ref, int options){
return (options & SHOW_FQ_CLASS_NAMES) == 0 ? ref.getText() : ref.getCanonicalText();
}
@Nullable
public static String getExternalName(PsiModifierListOwner owner, final boolean showParamName, int maxParamsToShow) {
final StringBuilder builder = new StringBuilder();
if (owner instanceof PsiClass) {
ClassUtil.formatClassName((PsiClass)owner, builder);
return builder.toString();
}
final PsiClass psiClass = PsiTreeUtil.getParentOfType(owner, PsiClass.class, false);
if (psiClass == null) return null;
ClassUtil.formatClassName(psiClass, builder);
if (owner instanceof PsiMethod) {
builder.append(" ");
formatMethod((PsiMethod)owner, PsiSubstitutor.EMPTY,
SHOW_NAME | SHOW_FQ_NAME | SHOW_TYPE | SHOW_PARAMETERS | SHOW_FQ_CLASS_NAMES,
showParamName ? SHOW_NAME | SHOW_TYPE | SHOW_FQ_CLASS_NAMES : SHOW_TYPE | SHOW_FQ_CLASS_NAMES, maxParamsToShow, builder);
}
else if (owner instanceof PsiField) {
builder.append(" ").append(((PsiField)owner).getName());
}
else if (owner instanceof PsiParameter) {
final PsiElement declarationScope = ((PsiParameter)owner).getDeclarationScope();
if (!(declarationScope instanceof PsiMethod)) {
return null;
}
final PsiMethod psiMethod = (PsiMethod)declarationScope;
builder.append(" ");
formatMethod(psiMethod, PsiSubstitutor.EMPTY,
SHOW_NAME | SHOW_FQ_NAME | SHOW_TYPE | SHOW_PARAMETERS | SHOW_FQ_CLASS_NAMES,
showParamName ? SHOW_NAME | SHOW_TYPE | SHOW_FQ_CLASS_NAMES : SHOW_TYPE | SHOW_FQ_CLASS_NAMES, maxParamsToShow, builder);
builder.append(" ");
if (showParamName) {
formatVariable((PsiVariable)owner, SHOW_NAME, PsiSubstitutor.EMPTY, builder);
}
else {
builder.append(psiMethod.getParameterList().getParameterIndex((PsiParameter)owner));
}
}
else {
return null;
}
return builder.toString();
}
}
@@ -0,0 +1,55 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.lang.resolve.java.extAnnotations;
import com.intellij.openapi.util.text.StringUtil;
/**
* This class is copied from IDEA.
* This class should be eliminated when Kotlin will depend on IDEA 12.x (KT-2326)
* @author Evgeny Gerashchenko
* @since 6/26/12
*/
@Deprecated
public abstract class PsiFormatUtilBase {
public static final int SHOW_NAME = 0x0001; // variable, method, class
public static final int SHOW_TYPE = 0x0002; // variable, method
public static final int TYPE_AFTER = 0x0004; // variable, method
public static final int SHOW_MODIFIERS = 0x0008; // variable, method, class
public static final int MODIFIERS_AFTER = 0x0010; // variable, method, class
public static final int SHOW_REDUNDANT_MODIFIERS = 0x0020; // variable, method, class, modifier list
public static final int SHOW_PACKAGE_LOCAL = 0x0040; // variable, method, class, modifier list
public static final int SHOW_INITIALIZER = 0x0080; // variable
public static final int SHOW_PARAMETERS = 0x0100; // method
public static final int SHOW_THROWS = 0x0200; // method
public static final int SHOW_EXTENDS_IMPLEMENTS = 0x0400; // class
public static final int SHOW_FQ_NAME = 0x0800; // class, field, method
public static final int SHOW_CONTAINING_CLASS = 0x1000; // field, method
public static final int SHOW_FQ_CLASS_NAMES = 0x2000; // variable, method, class
public static final int JAVADOC_MODIFIERS_ONLY = 0x4000; // field, method, class
public static final int SHOW_ANONYMOUS_CLASS_VERBOSE = 0x8000; // class
public static final int SHOW_RAW_TYPE = 0x10000; //type
public static final int SHOW_RAW_NON_TOP_TYPE = 0x20000;
public static final int MAX_PARAMS_TO_SHOW = 7;
protected static void appendSpaceIfNeeded(StringBuilder buffer) {
if (buffer.length() != 0 && !StringUtil.endsWithChar(buffer, ' ')) {
buffer.append(' ');
}
}
}
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiClass;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
import org.jetbrains.jet.utils.BitSetUtils;
@@ -54,6 +55,6 @@ public class JetClassAnnotation extends PsiAnnotationWithFlags {
@NotNull
public static JetClassAnnotation get(PsiClass psiClass) {
return new JetClassAnnotation(psiClass.getModifierList().findAnnotation(JvmStdlibNames.JET_CLASS.getFqName().getFqName()));
return new JetClassAnnotation(JavaDescriptorResolver.findAnnotation(psiClass, JvmStdlibNames.JET_CLASS.getFqName().getFqName()));
}
}
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
import org.jetbrains.jet.utils.BitSetUtils;
@@ -56,6 +57,6 @@ public class JetConstructorAnnotation extends PsiAnnotationWithFlags {
}
public static JetConstructorAnnotation get(PsiMethod constructor) {
return new JetConstructorAnnotation(constructor.getModifierList().findAnnotation(JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName()));
return new JetConstructorAnnotation(JavaDescriptorResolver.findAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName()));
}
}
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
import org.jetbrains.jet.utils.BitSetUtils;
@@ -88,6 +89,6 @@ public class JetMethodAnnotation extends PsiAnnotationWithFlags {
}
public static JetMethodAnnotation get(PsiMethod psiMethod) {
return new JetMethodAnnotation(psiMethod.getModifierList().findAnnotation(JvmStdlibNames.JET_METHOD.getFqName().getFqName()));
return new JetMethodAnnotation(JavaDescriptorResolver.findAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().getFqName()));
}
}
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiParameter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
/**
@@ -33,6 +34,7 @@ public class JetTypeParameterAnnotation extends PsiAnnotationWrapper {
@NotNull
public static JetTypeParameterAnnotation get(@NotNull PsiParameter psiParameter) {
return new JetTypeParameterAnnotation(psiParameter.getModifierList().findAnnotation(JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().getFqName()));
return new JetTypeParameterAnnotation(
JavaDescriptorResolver.findAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().getFqName()));
}
}
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiParameter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
/**
@@ -80,7 +81,8 @@ public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
}
public static JetValueParameterAnnotation get(PsiParameter psiParameter) {
return new JetValueParameterAnnotation(psiParameter.getModifierList().findAnnotation(JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName()));
return new JetValueParameterAnnotation(
JavaDescriptorResolver.findAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName()));
}
}
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
/**
@@ -42,6 +43,6 @@ public class KotlinSignatureAnnotation extends PsiAnnotationWrapper {
@NotNull
public static KotlinSignatureAnnotation get(PsiMethod psiClass) {
return new KotlinSignatureAnnotation(psiClass.getModifierList().findAnnotation(JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName()));
return new KotlinSignatureAnnotation(JavaDescriptorResolver.findAnnotation(psiClass, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName()));
}
}
@@ -758,7 +758,7 @@ public class CallResolver {
result = OTHER_ERROR;
}
}
if (safeAccess && (receiverParameter.getType().isNullable() || !receiverArgumentType.isNullable())) {
if (safeAccess && !receiverArgumentType.isNullable()) {
context.tracing.unnecessarySafeCall(context.candidateCall.getTrace(), receiverArgumentType);
}
}
+2 -1
View File
@@ -2,9 +2,10 @@ Usage: org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments
-jar [String] jar file name
-src [String] source file or directory
-classpath [String] classpath to use when compiling
-annotations [String] paths to external annotations
-includeRuntime [flag]
-stdlib [String] Path to the stdlib.jar
-jdkHeaders [String] Path to the kotlin-jdk-headers.jar
-jdkAnnotations [String] Path to the kotlin-jdk-annotations.jar
-mode [String] Special compiler modes: stubs or jdkHeaders
-output [String] output directory
-module [String] module to compile
@@ -50,7 +50,7 @@ fun test6() : Boolean {
return true
}
// ArrayList without jdk-headers cannot be used in these tests
// ArrayList without jdk-annotations cannot be used in these tests
class MyArrayList<T>() {
private var value17: T? = null
private var value39: T? = null
@@ -1,9 +1,8 @@
package kotlin1
import java.util.*
fun main(args : Array<String>) {
val al : ArrayList<Int> = ArrayList<Int>()
al.clone() : Object // A type mismatch on this line means that alt-headers were not loaded
al.clone() : Any // A type mismatch on this line means that jdk-annotations were not loaded
}
@@ -1,4 +1,3 @@
package kotlin1
import java.util.*
@@ -6,6 +5,6 @@ import java.util.*
fun main(args : Array<String>) {
val al : ArrayList<Int> = ArrayList<Int>()
// A type mismatch on this line means that alt-headers were not loaded
// A type mismatch on this line means that jdk-annotations were not loaded
al.toArray(Array<Int>(3, {1})) : Array<Int>
}
@@ -66,10 +66,10 @@ import outer.*
command.equals(null)
command?.equals(null)
command.equals1(null)
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals1(null)
command?.equals1(null)
val c = Command()
c<!UNNECESSARY_SAFE_CALL!>?.<!>equals2(null)
if (command == null) 1
}
}
@@ -0,0 +1,15 @@
//KT-2317 Wrong UNNECESSARY_SAFE_CALL
package kt2317
fun Any?.baz() = 1
fun foo(l: Long?) = l?.baz()
fun Any?.bar(): Unit { }
fun quux(x: Int?): Unit {
x?.baz()
x?.bar()
}
@@ -32,7 +32,7 @@ fun test(x : Int?, a : A?) {
a.times(1)
a * 1
a times 1
a<!UNNECESSARY_SAFE_CALL!>?.<!>times(1)
a?.times(1)
1 <!UNSAFE_INFIX_CALL!>in<!> a
a <!UNSAFE_INFIX_CALL!>contains<!> 1
@@ -12,7 +12,7 @@ fun test(a : A?) {
a?.foo()
a?.bar()
a<!UNNECESSARY_SAFE_CALL!>?.<!>buzz() // warning
a?.buzz()
}
fun A.test2() {
@@ -40,5 +40,5 @@ fun A?.test3() {
this?.foo()
this?.bar()
this<!UNNECESSARY_SAFE_CALL!>?.<!>buzz() // warning
this?.buzz()
}
@@ -5,5 +5,5 @@ fun Array<String>.length() : Int {
}
fun test(array : Array<String?>?) {
array<!UNNECESSARY_SAFE_CALL!>?.<!>sure<Array<String?>>()<!UNSAFE_CALL!>.<!>length()
array?.sure<Array<String?>>()<!UNSAFE_CALL!>.<!>length()
}
@@ -18,11 +18,10 @@ package org.jetbrains.jet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileBuiltins;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileJdkHeaders;
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
import org.jetbrains.jet.utils.PathUtil;
import org.junit.Test;
/**
@@ -36,8 +35,8 @@ public class CompileCompilerDependenciesTest {
}
@Test
public void compileJdkHeaders() {
ForTestCompileJdkHeaders.jdkHeadersForTests();
public void packJdkAnnotations() {
ForTestPackJdkAnnotations.jdkAnnotationsForTests();
}
@Test
@@ -53,7 +52,7 @@ public class CompileCompilerDependenciesTest {
return new CompilerDependencies(
compilerSpecialMode,
compilerSpecialMode.includeJdk() ? (mockJdk ? JetTestUtils.findMockJdkRtJar() : CompilerDependencies.findRtJar()) : null,
compilerSpecialMode.includeJdkHeaders() ? ForTestCompileJdkHeaders.jdkHeadersForTests() : null,
compilerSpecialMode.includeJdkAnnotations() ? ForTestPackJdkAnnotations.jdkAnnotationsForTests() : null,
compilerSpecialMode.includeKotlinRuntime() ? ForTestCompileRuntime.runtimeJarForTests() : null);
}
}
@@ -41,7 +41,7 @@ public class ForTestCompileBuiltins {
ExitCode exitCode = new K2JVMCompiler().exec(
System.err, "-output", classesDir.getPath(), "-src", "./compiler/frontend/src", "-mode", "builtins");
if (exitCode != ExitCode.OK) {
throw new IllegalStateException("jdk headers compilation failed: " + exitCode);
throw new IllegalStateException("builtins compilation failed: " + exitCode);
}
}
@@ -1,55 +0,0 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.codegen.forTestCompile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.cli.common.ExitCode;
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
import java.io.File;
/**
* @author Stepan Koltsov
*/
public class ForTestCompileJdkHeaders {
private ForTestCompileJdkHeaders() {
}
private static class JdkHeaders extends ForTestCompileSomething {
JdkHeaders() {
super("jdkHeaders");
}
@Override
protected void doCompile(@NotNull File classesDir) throws Exception {
ExitCode exitCode = new K2JVMCompiler().exec(
System.err, "-output", classesDir.getPath(), "-src", "./jdk-headers/src", "-mode", "jdkHeaders");
if (exitCode != ExitCode.OK) {
throw new IllegalStateException("jdk headers compilation failed: " + exitCode);
}
}
private static final JdkHeaders jdkHeaders = new JdkHeaders();
}
@NotNull
public static File jdkHeadersForTests() {
return ForTestCompileSomething.ACTUALLY_COMPILE ? JdkHeaders.jdkHeaders.getJarFile() : new File("dist/kotlinc/lib/alt/kotlin-jdk-headers.jar");
}
}
@@ -80,7 +80,7 @@ abstract class ForTestCompileSomething {
}
}
private static void copyToJar(File root, JarOutputStream os) throws IOException {
static void copyToJar(File root, JarOutputStream os) throws IOException {
Stack<Pair<String, File>> toCopy = new Stack<Pair<String, File>>();
toCopy.add(new Pair<String, File>("", root));
while (!toCopy.empty()) {
@@ -0,0 +1,72 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.codegen.forTestCompile;
import com.google.common.io.Files;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetTestUtils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Stack;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
/**
* @author Stepan Koltsov
*/
public class ForTestPackJdkAnnotations {
private ForTestPackJdkAnnotations() {
}
private static File jarFile = null;
private static File getJarFile() {
if (jarFile == null) {
try {
File tmpDir = JetTestUtils.tmpDir("runtimejar");
jarFile = new File(tmpDir, "runtime.jar");
FileOutputStream annotationsJar = new FileOutputStream(jarFile);
try {
JarOutputStream jarOutputStream = new JarOutputStream(new BufferedOutputStream(annotationsJar));
try {
ForTestCompileSomething.copyToJar(new File("./jdk-annotations"), jarOutputStream);
}
finally {
jarOutputStream.close();
}
}
finally {
annotationsJar.close();
}
}
catch (IOException e) {
throw new AssertionError(e);
}
}
return jarFile;
}
@NotNull
public static File jdkAnnotationsForTests() {
return ForTestCompileSomething.ACTUALLY_COMPILE ? getJarFile() : new File("dist/kotlinc/lib/alt/kotlin-jdk-annotations.jar");
}
}
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.io.FileUtil;
import junit.framework.TestCase;
import org.jetbrains.jet.cli.common.ExitCode;
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileJdkHeaders;
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
import org.jetbrains.jet.parsing.JetParsingTest;
import org.junit.Assert;
@@ -44,13 +44,13 @@ public class CompileEnvironmentTest extends TestCase {
try {
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
File jdkHeaders = ForTestCompileJdkHeaders.jdkHeadersForTests();
File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests();
File resultJar = new File(tempDir, "result.jar");
ExitCode rv = new K2JVMCompiler().exec(System.out,
"-module", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kts",
"-jar", resultJar.getAbsolutePath(),
"-stdlib", stdlib.getAbsolutePath(),
"-jdkHeaders", jdkHeaders.getAbsolutePath());
"-module", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kts",
"-jar", resultJar.getAbsolutePath(),
"-stdlib", stdlib.getAbsolutePath(),
"-jdkAnnotations", jdkAnnotations.getAbsolutePath());
Assert.assertEquals("compilation completed with non-zero code", ExitCode.OK, rv);
FileInputStream fileInputStream = new FileInputStream(resultJar);
try {
@@ -78,10 +78,10 @@ public class CompileEnvironmentTest extends TestCase {
try {
File out = new File(tempDir, "out");
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
File jdkHeaders = ForTestCompileJdkHeaders.jdkHeadersForTests();
File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests();
ExitCode exitCode = new K2JVMCompiler()
.exec(System.out, "-src", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kt", "-output",
out.getAbsolutePath(), "-stdlib", stdlib.getAbsolutePath(), "-jdkHeaders", jdkHeaders.getAbsolutePath());
out.getAbsolutePath(), "-stdlib", stdlib.getAbsolutePath(), "-jdkAnnotations", jdkAnnotations.getAbsolutePath());
Assert.assertEquals(ExitCode.OK, exitCode);
assertEquals(1, out.listFiles().length);
assertEquals(1, out.listFiles()[0].listFiles().length);
@@ -19,7 +19,7 @@ package org.jetbrains.jet.jvm.compiler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileJdkHeaders;
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
import org.jetbrains.jet.di.InjectorForJavaSemanticServices;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
@@ -36,7 +36,6 @@ import org.junit.Assert;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Set;
/**
* @author Stepan Koltsov
@@ -80,7 +79,8 @@ public class JavaDescriptorResolverTest extends TestCaseWithTmpdir {
}
public void testResolveJdkHeaderClassWithoutJdk() {
JetCoreEnvironment jetCoreEnvironment = new JetCoreEnvironment(myTestRootDisposable, new CompilerDependencies(CompilerSpecialMode.IDEA, null, ForTestCompileJdkHeaders.jdkHeadersForTests(), null));
JetCoreEnvironment jetCoreEnvironment = new JetCoreEnvironment(myTestRootDisposable, new CompilerDependencies(CompilerSpecialMode.IDEA, null, ForTestPackJdkAnnotations
.jdkAnnotationsForTests(), null));
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
jetCoreEnvironment.getCompilerDependencies(), jetCoreEnvironment.getProject());
@@ -153,7 +153,7 @@ public class ResolveDescriptorsFromExternalLibraries {
}
else {
CompilerDependencies compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.STDLIB, false);
jetCoreEnvironment = JetCoreEnvironment.getCoreEnvironmentForJVM(junk, compilerDependencies);
jetCoreEnvironment = JetCoreEnvironment.createCoreEnvironmentForJVM(junk, compilerDependencies);
if (!compilerDependencies.getJdkJar().equals(jar)) {
throw new RuntimeException("rt.jar mismatch: " + jar + ", " + compilerDependencies.getJdkJar());
}
@@ -28,7 +28,7 @@ public class Printer {
private String indent = "";
private final StringBuilder out;
Printer(@NotNull StringBuilder out) {
public Printer(@NotNull StringBuilder out) {
this.out = out;
}
@@ -25,6 +25,10 @@ public class ExceptionUtils {
/**
* Translate exception to unchecked exception.
*
* Return type is specified to make it possible to use it like this:
* throw ExceptionUtils.rethrow(e);
* In this case compiler knows that code after this rethrowing won't be executed.
*/
public static RuntimeException rethrow(Throwable e) {
if (e instanceof RuntimeException) {
@@ -94,8 +94,8 @@ public class PathUtil {
}
@Nullable
public static File getAltHeadersPath() {
return getFilePackedIntoLib("alt/kotlin-jdk-headers.jar");
public static File getJdkAnnotationsPath() {
return getFilePackedIntoLib("alt/kotlin-jdk-annotations.jar");
}
@NotNull
+3
View File
@@ -71,6 +71,9 @@
<projectService serviceInterface="org.jetbrains.jet.lang.resolve.java.JetFilesProvider"
serviceImplementation="org.jetbrains.jet.plugin.project.PluginJetFilesProvider"/>
<projectService serviceInterface="org.jetbrains.jet.lang.resolve.java.extAnnotations.ExternalAnnotationsProvider"
serviceImplementation="org.jetbrains.jet.plugin.extAnnotations.IdeaExternalAnnotationsProvider"/>
<errorHandler implementation="org.jetbrains.jet.plugin.reporter.KotlinReportSubmitter"/>
<internalFileTemplate name="Kotlin File"/>
@@ -27,6 +27,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import jet.runtime.typeinfo.JetValueParameter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.java.kt.JetValueParameterAnnotation;
@@ -165,16 +166,13 @@ class JetFromJavaDescriptorHelper {
// Should be parameter with JetValueParameter.receiver == true
for (PsiParameter parameter : psiMethod.getParameterList().getParameters()) {
PsiModifierList modifierList = parameter.getModifierList();
if (modifierList != null) {
for (PsiAnnotation psiAnnotation : modifierList.getAnnotations()) {
if (!JetValueParameter.class.getCanonicalName().equals(psiAnnotation.getQualifiedName())) {
continue;
}
for (PsiAnnotation psiAnnotation : JavaDescriptorResolver.getAllAnnotations(parameter)) {
if (!JetValueParameter.class.getCanonicalName().equals(psiAnnotation.getQualifiedName())) {
continue;
}
if (filterPredicate.apply(new JetValueParameterAnnotation(psiAnnotation))) {
selectedMethods.add(psiMethod);
}
if (filterPredicate.apply(new JetValueParameterAnnotation(psiAnnotation))) {
selectedMethods.add(psiMethod);
}
}
}
@@ -30,6 +30,8 @@ import com.intellij.openapi.projectRoots.JavaSdkType;
import com.intellij.openapi.projectRoots.JdkUtil;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SimpleJavaSdkType;
import com.intellij.openapi.roots.AnnotationOrderRootType;
import com.intellij.openapi.roots.OrderEnumerator;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Chunk;
@@ -220,6 +222,13 @@ public class JetCompiler implements TranslatingCompiler {
script.append(" classpath += \"" + path(mainOutput) + "\"\n");
}
script.append(" // External annotations\n");
for (Module module : chunk.getModules()) {
for (VirtualFile file : OrderEnumerator.orderEntries(module).roots(AnnotationOrderRootType.getInstance()).getRoots()) {
script.append(" annotationsPath += \"").append(path(file)).append("\"\n");
}
}
script.append(" }\n");
script.append("}\n");
return script;
@@ -0,0 +1,50 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.plugin.extAnnotations;
import com.intellij.codeInsight.ExternalAnnotationsManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiModifierListOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.resolve.java.extAnnotations.ExternalAnnotationsProvider;
/**
* This class is copied from IDEA.
* This class should be eliminated when Kotlin will depend on IDEA 12.x (KT-2326)
* @author Evgeny Gerashchenko
* @since 6/26/12
*/
@Deprecated
public class IdeaExternalAnnotationsProvider extends ExternalAnnotationsProvider {
private final ExternalAnnotationsManager externalAnnotationsManager;
public IdeaExternalAnnotationsProvider(ExternalAnnotationsManager externalAnnotationsManager) {
this.externalAnnotationsManager = externalAnnotationsManager;
}
@Override
public synchronized PsiAnnotation findExternalAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN) {
return externalAnnotationsManager.findExternalAnnotation(listOwner, annotationFQN);
}
@Override
public synchronized PsiAnnotation[] findExternalAnnotations(@NotNull PsiModifierListOwner listOwner) {
return externalAnnotationsManager.findExternalAnnotations(listOwner);
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ fun Int.foo() = this
command.equals(null)
command?.equals(null)
command.equals1(null)
command<warning>?.</warning>equals1(null)
command?.equals1(null)
val c = Command()
c<warning>?.</warning>equals2(null)
@@ -17,8 +17,14 @@
package org.jetbrains.jet.plugin;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkModificator;
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.openapi.roots.AnnotationOrderRootType;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.jet.JetTestCaseBuilder;
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
/**
* @author yole
@@ -32,6 +38,12 @@ public class PluginTestCaseBase {
}
public static Sdk jdkFromIdeaHome() {
return new JavaSdkImpl().createJdk("JDK", "compiler/testData/mockJDK-1.7/jre", true);
Sdk sdk = new JavaSdkImpl().createJdk("JDK", "compiler/testData/mockJDK-1.7/jre", true);
SdkModificator modificator = sdk.getSdkModificator();
VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(ForTestPackJdkAnnotations.jdkAnnotationsForTests());
assert file != null;
modificator.addRoot(JarFileSystem.getInstance().getJarRootForLocalFile(file), AnnotationOrderRootType.getInstance());
modificator.commitChanges();
return sdk;
}
}
+12
View File
@@ -0,0 +1,12 @@
<root>
<item name='java.lang.Iterable java.util.Iterator<T> iterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun iterator() : Iterator&lt;T&gt;&quot;"/>
</annotation>
</item>
<item name='java.lang.Object java.lang.Object clone()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun clone() : Any&quot;"/>
</annotation>
</item>
</root>
+744
View File
@@ -0,0 +1,744 @@
<root>
<item name='java.util.AbstractList boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractList void add(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(index : Int, element : E)&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractList boolean addAll(int, java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(index : Int, c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractList E get(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun get(index : Int) : E&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractList java.util.Iterator<E> iterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun iterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractList java.util.ListIterator<E> listIterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun listIterator() : ListIterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractList java.util.ListIterator<E> listIterator(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun listIterator(index : Int) : ListIterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractList E set(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun set(index : Int, element : E) : E&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractList java.util.List<E> subList(int, int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun subList(fromIndex : Int, toIndex : Int) : List&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.ArrayList boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.ArrayList void add(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(index : Int, element : E)&quot;"/>
</annotation>
</item>
<item name='java.util.ArrayList boolean addAll(java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.ArrayList boolean addAll(int, java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(index : Int, c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.ArrayList E get(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun get(index : Int) : E&quot;"/>
</annotation>
</item>
<item name='java.util.ArrayList E remove(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun remove(index : Int) : E&quot;"/>
</annotation>
</item>
<item name='java.util.ArrayList E set(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun set(index : Int, element : E) : E&quot;"/>
</annotation>
</item>
<item name='java.util.ArrayList java.lang.Object[] toArray()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun toArray() : Array&lt;Any?&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.ArrayList T[] toArray(T[])'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun &lt;T&gt; toArray(a : Array&lt;T&gt;) : Array&lt;T&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.List boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.List void add(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(index : Int, element : E)&quot;"/>
</annotation>
</item>
<item name='java.util.List boolean addAll(java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.List boolean addAll(int, java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(index : Int, c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.List boolean containsAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun containsAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.List E get(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun get(index : Int) : E&quot;"/>
</annotation>
</item>
<item name='java.util.List java.util.Iterator<E> iterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun iterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.List java.util.ListIterator<E> listIterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun listIterator() : ListIterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.List java.util.ListIterator<E> listIterator(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun listIterator(index : Int) : ListIterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.List E remove(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun remove(index : Int) : E&quot;"/>
</annotation>
</item>
<item name='java.util.List boolean removeAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.List boolean retainAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun retainAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.List E set(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun set(index : Int, element : E) : E&quot;"/>
</annotation>
</item>
<item name='java.util.List java.util.List<E> subList(int, int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun subList(fromIndex : Int, toIndex : Int) : List&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.List java.lang.Object[] toArray()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun toArray() : Array&lt;Any?&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.List T[] toArray(T[])'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun &lt;T&gt; toArray(a : Array&lt;T&gt;) : Array&lt;T&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.HashSet boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.HashSet java.util.Iterator<E> iterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun iterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Collection boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Collection boolean addAll(java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Collection boolean containsAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun containsAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Collection java.util.Iterator<E> iterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun iterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Collection boolean removeAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Collection boolean retainAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun retainAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Collection java.lang.Object[] toArray()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun toArray() : Array&lt;Any?&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Collection T[] toArray(T[])'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun &lt;T&gt; toArray(a : Array&lt;T&gt;) : Array&lt;T&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Map.Entry K getKey()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun getKey() : K&quot;"/>
</annotation>
</item>
<item name='java.util.Map.Entry V getValue()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun getValue() : V&quot;"/>
</annotation>
</item>
<item name='java.util.Map.Entry V setValue(V)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun setValue(value : V) : V&quot;"/>
</annotation>
</item>
<item name='java.util.Map java.util.Set<java.util.Map.Entry<K,V>> entrySet()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun entrySet() : Set&lt;Map.Entry&lt;K, V&gt;&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Map java.util.Set<K> keySet()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun keySet() : Set&lt;K&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Map V put(K, V)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun put(key : K, value : V) : V?&quot;"/>
</annotation>
</item>
<item name='java.util.Map void putAll(java.util.Map<? extends K,? extends V>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun putAll(m : Map&lt;out K, out V&gt;)&quot;"/>
</annotation>
</item>
<item name='java.util.Map java.util.Collection<V> values()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun values() : Collection&lt;V&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedHashMap boolean removeEldestEntry(java.util.Map.Entry<K,V>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeEldestEntry(eldest : Map.Entry&lt;K, V&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Set boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Set boolean addAll(java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Set boolean containsAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun containsAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Set java.util.Iterator<E> iterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun iterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Set boolean removeAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Set boolean retainAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun retainAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Set java.lang.Object[] toArray()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun toArray() : Array&lt;Any?&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Set T[] toArray(T[])'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun &lt;T&gt; toArray(a : Array&lt;T&gt;) : Array&lt;T&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractCollection boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractCollection boolean addAll(java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractCollection boolean containsAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun containsAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractCollection java.util.Iterator<E> iterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun iterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractCollection boolean removeAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractCollection boolean retainAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun retainAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractCollection java.lang.Object[] toArray()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun toArray() : Array&lt;Any?&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractCollection T[] toArray(T[])'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun &lt;T&gt; toArray(a : Array&lt;T&gt;) : Array&lt;T&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Enumeration E nextElement()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun nextElement() : E&quot;"/>
</annotation>
</item>
<item name='java.util.HashMap java.util.Set<java.util.Map.Entry<K,V>> entrySet()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun entrySet() : Set&lt;Map.Entry&lt;K, V&gt;&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.HashMap java.util.Set<K> keySet()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun keySet() : Set&lt;K&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.HashMap V put(K, V)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun put(key : K, value : V) : V?&quot;"/>
</annotation>
</item>
<item name='java.util.HashMap void putAll(java.util.Map<? extends K,? extends V>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun putAll(m : Map&lt;out K, out V&gt;)&quot;"/>
</annotation>
</item>
<item name='java.util.HashMap java.util.Collection<V> values()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun values() : Collection&lt;V&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractSet boolean removeAll(java.util.Collection<?>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeAll(c : Collection&lt;out Any?&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Queue boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Queue E()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun element() : E&quot;"/>
</annotation>
</item>
<item name='java.util.Queue boolean offer(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun offer(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Queue E peek()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun peek() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.Queue E poll()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun poll() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.Queue E remove()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun remove() : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList void add(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(index : Int, element : E)&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList boolean addAll(java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList boolean addAll(int, java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(index : Int, c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList void addFirst(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addFirst(e : E)&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList void addLast(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addLast(e : E)&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList java.util.Iterator<E> descendingIterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun descendingIterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun element() : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E get(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun get(index : Int) : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E getFirst()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun getFirst() : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E getLast()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun getLast() : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList java.util.ListIterator<E> listIterator(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun listIterator(index : Int) : ListIterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList boolean offer(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun offer(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList boolean offerFirst(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun offerFirst(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList boolean offerLast(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun offerLast(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E peek()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun peek() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E peekFirst()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun peekFirst() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E peekLast()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun peekLast() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E poll()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun poll() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E pollFirst()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun pollFirst() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E pollLast()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun pollLast() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E pop()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun pop() : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList void push(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun push(e : E)&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E remove()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun remove() : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E remove(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun remove(index : Int) : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E removeFirst()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeFirst() : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E removeLast()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeLast() : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList E set(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun set(index : Int, element : E) : E&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList java.lang.Object[] toArray()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun toArray() : Array&lt;Any?&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.LinkedList T[] toArray(T[])'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun &lt;T&gt; toArray(a : Array&lt;T&gt;) : Array&lt;T&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Iterator E next()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun next() : E&quot;"/>
</annotation>
</item>
<item name='java.util.Deque boolean add(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Deque void addFirst(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addFirst(e : E)&quot;"/>
</annotation>
</item>
<item name='java.util.Deque void addLast(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addLast(e : E)&quot;"/>
</annotation>
</item>
<item name='java.util.Deque java.util.Iterator<E> descendingIterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun descendingIterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun element() : E&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E getFirst()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun getFirst() : E&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E getLast()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun getLast() : E&quot;"/>
</annotation>
</item>
<item name='java.util.Deque java.util.Iterator<E> iterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun iterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.Deque boolean offer(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun offer(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Deque boolean offerFirst(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun offerFirst(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Deque boolean offerLast(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun offerLast(e : E) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E peek()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun peek() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E peekFirst()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun peekFirst() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E peekLast()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun peekLast() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E poll()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun poll() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E pollFirst()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun pollFirst() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E pollLast()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun pollLast() : E?&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E pop()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun pop() : E&quot;"/>
</annotation>
</item>
<item name='java.util.Deque void push(E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun push(e : E)&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E remove()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun remove() : E&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E removeFirst()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeFirst() : E&quot;"/>
</annotation>
</item>
<item name='java.util.Deque E removeLast()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun removeLast() : E&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractMap java.util.Set<java.util.Map.Entry<K,V>> entrySet()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun entrySet() : Set&lt;Map.Entry&lt;K, V&gt;&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractMap java.util.Set<K> keySet()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun keySet() : Set&lt;K&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractMap V put(K, V)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun put(key : K, value : V) : V?&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractMap void putAll(java.util.Map<? extends K,? extends V>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun putAll(m : Map&lt;out K, out V&gt;)&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractMap java.util.Collection<V> values()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun values() : Collection&lt;V&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractSequentialList void add(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun add(index : Int, element : E)&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractSequentialList boolean addAll(int, java.util.Collection<? extends E>)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun addAll(index : Int, c : Collection&lt;out E&gt;) : Boolean&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractSequentialList E get(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun get(index : Int) : E&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractSequentialList java.util.Iterator<E> iterator()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun iterator() : Iterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractSequentialList java.util.ListIterator<E> listIterator(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun listIterator(index : Int) : ListIterator&lt;E&gt;&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractSequentialList E remove(int)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun remove(index : Int) : E&quot;"/>
</annotation>
</item>
<item name='java.util.AbstractSequentialList E set(int, E)'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun set(index : Int, element : E) : E&quot;"/>
</annotation>
</item>
<!-- TODO temporary fix for alt-headers/ArrayListClone.jet test -->
<item name='java.util.ArrayList java.lang.Object clone()'>
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
<val name="value" val="&quot;fun clone() : Any&quot;"/>
</annotation>
</item>
</root>
-1
View File
@@ -1 +0,0 @@
jdk-headers
-7
View File
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AntConfiguration">
<defaultAnt bundledAnt="true" />
</component>
</project>
-13
View File
@@ -1,13 +0,0 @@
<component name="ArtifactManager">
<artifact build-on-make="true" name="jdk-headers:jar">
<output-path>$PROJECT_DIR$</output-path>
<root id="root">
<element id="archive" name="jdk-headers.jar">
<element id="directory" name="META-INF">
<element id="file-copy" path="$PROJECT_DIR$/src/META-INF/MANIFEST.MF" />
</element>
<element id="module-output" name="jdk-headers" />
</element>
</root>
</artifact>
</component>
-21
View File
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="?*.properties" />
<entry name="?*.xml" />
<entry name="?*.gif" />
<entry name="?*.png" />
<entry name="?*.jpeg" />
<entry name="?*.jpg" />
<entry name="?*.html" />
<entry name="?*.dtd" />
<entry name="?*.tld" />
<entry name="?*.ftl" />
</wildcardResourcePatterns>
<annotationProcessing enabled="false" useClasspath="true" />
</component>
</project>
-5
View File
@@ -1,5 +0,0 @@
<component name="CopyrightManager">
<settings default="">
<module2copyright />
</settings>
</component>
-5
View File
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
-13
View File
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectResources">
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
-10
View File
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/jdk-headers.iml" filepath="$PROJECT_DIR$/jdk-headers.iml" />
<module fileurl="file://$PROJECT_DIR$/test/test.iml" filepath="$PROJECT_DIR$/test/test.iml" />
</modules>
</component>
</project>
-5
View File
@@ -1,5 +0,0 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
-125
View File
@@ -1,125 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
-7
View File
@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
-2
View File
@@ -1,2 +0,0 @@
Manifest-Version: 1.0
-5
View File
@@ -1,5 +0,0 @@
package java.lang
public trait Iterable<T> {
public fun iterator() : java.util.Iterator<T>
}
@@ -1,17 +0,0 @@
package java.util
public abstract class AbstractCollection<E> protected () : java.lang.Object(), java.util.Collection<E> {
public abstract override fun iterator() : java.util.Iterator<E>
public abstract override fun size() : Int
public override fun isEmpty() : Boolean {}
public override fun contains(o : Any?) : Boolean {}
public override fun toArray() : Array<Any?> {}
public override fun toArray<T>(a : Array<out T>) : Array<T> {}
public override fun add(e : E) : Boolean {}
public override fun remove(o : Any?) : Boolean {}
public override fun containsAll(c : java.util.Collection<*>) : Boolean {}
public override fun addAll(c : java.util.Collection<out E>) : Boolean {}
public override fun removeAll(c : java.util.Collection<*>) : Boolean {}
public override fun retainAll(c : java.util.Collection<*>) : Boolean {}
public override fun clear() : Unit {}
//public override fun toString() : java.lang.String {}
}
-20
View File
@@ -1,20 +0,0 @@
package java.util
public abstract class AbstractList<E> protected () : java.util.AbstractCollection<E>(), java.util.List<E> {
public override fun add(e : E) : Boolean {}
public abstract override fun get(index : Int) : E
public override fun set(index : Int, element : E) : E {}
public override fun add(index : Int, element : E) : Unit {}
public override fun remove(index : Int) : E {}
public override fun indexOf(o : Any?) : Int {}
public override fun lastIndexOf(o : Any?) : Int {}
public override fun clear() : Unit {}
public override fun addAll(index : Int, c : java.util.Collection<out E>) : Boolean {}
public override fun iterator() : java.util.Iterator<E> {}
public override fun listIterator() : java.util.ListIterator<E> {}
public override fun listIterator(index : Int) : java.util.ListIterator<E> {}
public override fun subList(fromIndex : Int, toIndex : Int) : java.util.List<E> {}
// public override fun equals(o : Any?) : Boolean
// public override fun hashCode() : Int
open protected fun removeRange(fromIndex : Int, toIndex : Int) : Unit {}
protected var modCount : Int = 0
}
-21
View File
@@ -1,21 +0,0 @@
package java.util
import java.util.Map.Entry
public abstract class AbstractMap<K, V> protected () : java.lang.Object(), java.util.Map<K, V> {
public override fun size() : Int {}
public override fun isEmpty() : Boolean {}
public override fun containsValue(value : Any?) : Boolean {}
public override fun containsKey(key : Any?) : Boolean {}
public override fun get(key : Any?) : V? {}
public override fun put(key : K, value : V) : V? {}
public override fun remove(key : Any?) : V? {}
public override fun putAll(m : java.util.Map<out K, out V>) : Unit {}
public override fun clear() : Unit {}
public override fun keySet() : java.util.Set<K> {}
public override fun values() : java.util.Collection<V> {}
public abstract override fun entrySet() : java.util.Set<Entry<K, V>>
//public override fun equals(o : Any?) : Boolean
//public override fun hashCode() : Int
//public override fun toString() : java.lang.String?
}
@@ -1,10 +0,0 @@
package java.util
public abstract class AbstractSequentialList<E> protected () : java.util.AbstractList<E>() {
public override fun get(index : Int) : E {}
public override fun set(index : Int, element : E) : E {}
public override fun add(index : Int, element : E) : Unit {}
public override fun remove(index : Int) : E {}
public override fun addAll(index : Int, c : java.util.Collection<out E>) : Boolean {}
public override fun iterator() : java.util.Iterator<E> {}
public abstract override fun listIterator(index : Int) : java.util.ListIterator<E> {}
}
-6
View File
@@ -1,6 +0,0 @@
package java.util
public abstract class AbstractSet<E> protected () : java.util.AbstractCollection<E>(), java.util.Set<E> {
// public override fun equals(o : Any?) : Boolean
// public override fun hashCode() : Int
public override fun removeAll(c : java.util.Collection<*>) : Boolean {}
}
-37
View File
@@ -1,37 +0,0 @@
package java.util
public open class ArrayList<E>(c : java.util.Collection<out E>) : java.util.AbstractList<E>(),
java.util.List<E>,
java.util.RandomAccess,
java.lang.Cloneable,
java.io.Serializable {
public this() {}
public this(initialCapacity : Int) {}
open public fun trimToSize() : Unit {}
open public fun ensureCapacity(minCapacity : Int) : Unit {}
public override fun size() : Int {}
public override fun isEmpty() : Boolean {}
public override fun contains(o : Any?) : Boolean {}
public override fun indexOf(o : Any?) : Int {}
public override fun lastIndexOf(o : Any?) : Int {}
public override fun clone() : java.lang.Object {}
public override fun toArray() : Array<Any?> {}
public override fun toArray<T>(a : Array<out T>) : Array<T> {}
public override fun get(index : Int) : E {}
public override fun set(index : Int, element : E) : E {}
public override fun add(e : E) : Boolean {}
public override fun add(index : Int, element : E) : Unit {}
public override fun remove(index : Int) : E {}
public override fun remove(o : Any?) : Boolean {}
public override fun clear() : Unit {}
public override fun addAll(c : java.util.Collection<out E>) : Boolean {}
public override fun addAll(index : Int, c : java.util.Collection<out E>) : Boolean {}
override protected fun removeRange(fromIndex : Int, toIndex : Int) : Unit {}
// class object {
// open public fun init<E>() : ArrayList<E> {
// return __
// }
// open public fun init<E>(c : java.util.Collection<out E?>?) : ArrayList<E> {
// return __
// }
// }
}
-20
View File
@@ -1,20 +0,0 @@
package java.util
public trait Collection<E> : java.lang.Iterable<E> {
open fun size() : Int
open fun isEmpty() : Boolean
open fun contains(o : Any?) : Boolean
override fun iterator() : java.util.Iterator<E>
open fun toArray() : Array<Any?>
// a : Array<out T> to emulate Java's array covariance
open fun toArray<T>(a : Array<out T>) : Array<T>
open fun add(e : E) : Boolean
open fun remove(o : Any?) : Boolean
open fun containsAll(c : java.util.Collection<*>) : Boolean
open fun addAll(c : java.util.Collection<out E>) : Boolean
open fun removeAll(c : java.util.Collection<*>) : Boolean
open fun retainAll(c : java.util.Collection<*>) : Boolean
open fun clear() : Unit
// override fun equals(o : Any?) : Boolean
// override fun hashCode() : Int
}
-30
View File
@@ -1,30 +0,0 @@
package java.util
public trait Deque<E> : java.util.Queue<E> {
open fun addFirst(e : E) : Unit
open fun addLast(e : E) : Unit
open fun offerFirst(e : E) : Boolean
open fun offerLast(e : E) : Boolean
open fun removeFirst() : E
open fun removeLast() : E
open fun pollFirst() : E?
open fun pollLast() : E?
open fun getFirst() : E
open fun getLast() : E
open fun peekFirst() : E?
open fun peekLast() : E?
open fun removeFirstOccurrence(o : Any?) : Boolean
open fun removeLastOccurrence(o : Any?) : Boolean
override fun add(e : E) : Boolean
override fun offer(e : E) : Boolean
override fun remove() : E
override fun poll() : E?
override fun element() : E
override fun peek() : E?
open fun push(e : E) : Unit
open fun pop() : E
override fun remove(o : Any?) : Boolean
override fun contains(o : Any?) : Boolean
public override fun size() : Int
override fun iterator() : java.util.Iterator<E>
open fun descendingIterator() : java.util.Iterator<E>
}
-5
View File
@@ -1,5 +0,0 @@
package java.util
public trait Enumeration<E> {
open fun hasMoreElements() : Boolean
open fun nextElement() : E
}
-24
View File
@@ -1,24 +0,0 @@
package java.util
import java.io.*
import java.util.Map.Entry
public open class HashMap<K, V>(m : java.util.Map<out K, out V>) : java.util.AbstractMap<K, V>(),
java.util.Map<K, V>,
java.lang.Cloneable,
java.io.Serializable {
public this() {}
public this(initialCapacity : Int) {}
public this(initialCapacity : Int, loadFactor : Float) {}
public override fun size() : Int {}
public override fun isEmpty() : Boolean {}
public override fun get(key : Any?) : V? {}
public override fun containsKey(key : Any?) : Boolean {}
public override fun put(key : K, value : V) : V? {}
public override fun putAll(m : java.util.Map<out K, out V>) : Unit {}
public override fun remove(key : Any?) : V? {}
public override fun clear() : Unit {}
public override fun containsValue(value : Any?) : Boolean {}
public override fun clone() : Any? {}
public override fun keySet() : java.util.Set<K> {}
public override fun values() : java.util.Collection<V> {}
public override fun entrySet() : java.util.Set<Entry<K, V>> {}
}

Some files were not shown because too many files have changed in this diff Show More