Merge branch 'idea13'

This commit is contained in:
Andrey Breslav
2013-07-24 18:24:42 +04:00
17 changed files with 246 additions and 43 deletions
@@ -191,7 +191,7 @@ public class ClassPreloadingUtils {
public URL getURL() {
try {
String path = "file:" + jarFile + "!" + resourceName;
String path = "file:" + jarFile + "!/" + resourceName;
return new URL("jar", null, 0, path, new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL u) throws IOException {
+1 -1
View File
@@ -6,7 +6,7 @@
<version>@snapshot@</version>
<vendor url="http://www.jetbrains.com">JetBrains Inc.</vendor>
<idea-version since-build="129.1" until-build="129.9999"/>
<idea-version since-build="130.555" until-build="131.0"/>
<depends optional="true" config-file="junit.xml">JUnit</depends>
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
@@ -21,17 +21,14 @@ import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleComponent;
import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import com.intellij.openapi.roots.impl.storage.ClassPathStorageUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.k2js.config.EcmaVersion;
@Deprecated
@State(
name = "K2JSModule",
storages = @Storage(
id = ClasspathStorage.DEFAULT_STORAGE,
id = ClassPathStorageUtil.DEFAULT_STORAGE,
file = "$MODULE_FILE$"
)
)
@@ -16,7 +16,7 @@
package org.jetbrains.jet.plugin.quickfix;
import com.intellij.codeInsight.CodeInsightUtilBase;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -79,7 +79,7 @@ public class ExclExclCallFix implements IntentionAction {
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
if (!CodeInsightUtilBase.prepareFileForWrite(file)) {
if (!FileModificationService.getInstance().prepareFileForWrite(file)) {
return;
}
@@ -16,7 +16,7 @@
package org.jetbrains.jet.plugin.quickfix;
import com.intellij.codeInsight.CodeInsightUtilBase;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
@@ -43,7 +43,7 @@ public abstract class JetIntentionAction<T extends PsiElement> implements Intent
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
if (file instanceof JetFile) {
if (CodeInsightUtilBase.prepareFileForWrite(element.getContainingFile())) {
if (FileModificationService.getInstance().prepareFileForWrite(element.getContainingFile())) {
invoke(project, editor, (JetFile) file);
}
}
@@ -150,7 +150,7 @@ public class MapPlatformClassToKotlinFix extends JetIntentionAction<JetReference
caretModel.moveToOffset(file.getNode().getStartOffset());
TemplateBuilderImpl builder = new TemplateBuilderImpl(file);
Expression expression = new MyLookupExpression(primaryReplacedExpression.getText(), options, null, false,
Expression expression = new MyLookupExpression(primaryReplacedExpression.getText(), options, null, null, false,
JetBundle.message("map.platform.class.to.kotlin.advertisement"));
builder.replaceElement(primaryReplacedExpression, PRIMARY_USAGE, expression, true);
@@ -46,6 +46,9 @@ public class Converter {
"javax.annotation.Nonnull"
);
@NotNull
private final Project project;
@NotNull
private Set<String> classIdentifiers = Sets.newHashSet();
@@ -59,9 +62,15 @@ public class Converter {
private final Set<J2KConverterFlags> flags = Sets.newHashSet();
public Converter(@NotNull Project project) {
this.project = project;
KotlinBuiltIns.initialize(project, KotlinBuiltIns.InitializationMode.MULTI_THREADED);
}
@NotNull
public Project getProject() {
return project;
}
public boolean addFlag(@NotNull J2KConverterFlags flag) {
return flags.add(flag);
}
+1
View File
@@ -13,6 +13,7 @@
<orderEntry type="module" module-name="cli" scope="TEST" />
<orderEntry type="module" module-name="frontend" scope="TEST" />
<orderEntry type="module" module-name="util" />
<orderEntry type="module" module-name="compiler-tests" scope="TEST" />
</component>
</module>
@@ -16,44 +16,24 @@
package org.jetbrains.jet.j2k;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiJavaFile;
import com.intellij.testFramework.UsefulTestCase;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
import org.jetbrains.jet.ConfigurationKind;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.config.CompilerConfiguration;
import org.jetbrains.jet.utils.PathUtil;
import java.io.File;
import java.io.IOException;
public class StandaloneJavaToKotlinConverterTest extends TestCase {
private static final JetCoreEnvironment jetCoreEnvironment;
static {
CompilerConfiguration config = new CompilerConfiguration();
config.add(JVMConfigurationKeys.CLASSPATH_KEY, PathUtil.findRtJar());
File annotations = JavaToKotlinTranslator.findAnnotations();
if (annotations != null && annotations.exists()) {
config.add(JVMConfigurationKeys.CLASSPATH_KEY, annotations);
}
Disposable disposable = new Disposable() {
@Override
public void dispose() {
}
};
jetCoreEnvironment = new JetCoreEnvironment(disposable, config);
}
import static org.jetbrains.jet.JetTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations;
public class StandaloneJavaToKotlinConverterTest extends UsefulTestCase {
private final String myDataPath;
private final String myName;
@@ -64,7 +44,9 @@ public class StandaloneJavaToKotlinConverterTest extends TestCase {
@Override
protected void runTest() throws Throwable {
JetCoreEnvironment jetCoreEnvironment = createEnvironmentWithMockJdkAndIdeaAnnotations(getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
Converter converter = new Converter(jetCoreEnvironment.getProject());
String javaPath = "j2k/tests/testData/" + getTestFilePath();
String kotlinPath = javaPath.replace(".jav", ".kt");
@@ -140,7 +122,7 @@ public class StandaloneJavaToKotlinConverterTest extends TestCase {
@NotNull
private String fileToKotlin(Converter converter, @NotNull String text) {
return generateKotlinCode(converter, JavaToKotlinTranslator.createFile(jetCoreEnvironment.getProject(), text));
return generateKotlinCode(converter, JavaToKotlinTranslator.createFile(converter.getProject(), text));
}
@NotNull
+3
View File
@@ -906,6 +906,9 @@
<item name="java.io.StringWriter void write(char[], int, int) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.io.StringWriter void write(java.lang.String) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.io.StringWriter void write(java.lang.String, int, int) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
@@ -1187,6 +1187,9 @@
<item name="java.lang.String java.lang.String[] split(java.lang.String, int) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.lang.String void getBytes(int, int, byte[], int) 2">
<annotation name="org.jetbrains.annotations.NotNull" />
</item>
<item name="java.lang.String void getChars(int, int, char[], int) 2">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
+6
View File
@@ -318,6 +318,9 @@
<item name="java.net.URI java.net.URI create(java.lang.String)">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.net.URI java.net.URI create(java.lang.String) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.net.URI java.net.URI normalize()">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
@@ -333,6 +336,9 @@
<item name="java.net.URI java.net.URI resolve(java.lang.String)">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.net.URI java.net.URI resolve(java.lang.String) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.net.URI java.net.URI resolve(java.net.URI)">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
+6
View File
@@ -21,6 +21,9 @@
<item name="java.nio.Buffer java.nio.Buffer rewind()">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.nio.ByteBuffer byte[] array()">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.nio.ByteBuffer int compareTo(java.lang.Object) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
@@ -60,6 +63,9 @@
<item name="java.nio.ByteBuffer java.nio.ByteBuffer order(java.nio.ByteOrder)">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.nio.ByteBuffer java.nio.ByteBuffer order(java.nio.ByteOrder) 0">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.nio.ByteBuffer java.nio.ByteBuffer put(byte)">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
@@ -2104,6 +2104,9 @@
<item name="java.util.Formatter java.util.Formatter format(java.lang.String, java.lang.Object...)">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
<item name="java.util.Formatter java.util.Formatter format(java.lang.String, java.lang.Object...) 0">
<annotation name="org.jetbrains.annotations.NotNull" />
</item>
<item name="java.util.Formatter java.util.Formatter format(java.util.Locale, java.lang.String, java.lang.Object...)">
<annotation name="org.jetbrains.annotations.NotNull"/>
</item>
@@ -0,0 +1,118 @@
package kotlin.properties.delegation
import kotlin.properties.ChangeSupport
public class NotNullVar<T: Any> {
private var value: T? = null
public fun get(thisRef: Any?, desc: PropertyMetadata): T {
return value ?: throw IllegalStateException("Property ${desc.name} should be initialized before get")
}
public fun set(thisRef: Any?, desc: PropertyMetadata, value: T) {
this.value = value
}
}
public class SynchronizedVar<T>(private val initValue: T, private val lock: Any) {
private var value: T = initValue
public fun get(thisRef: Any?, desc: PropertyMetadata): T {
return synchronized(lock) { value }
}
public fun set(thisRef: Any?, desc: PropertyMetadata, newValue: T) {
synchronized(lock) {
value = newValue
}
}
}
class ObservableProperty<T>(initialValue: T, val changeSupport: (name: String, oldValue: T, newValue: T) -> Unit) {
private var value = initialValue
public fun get(thisRef: Any?, desc: PropertyMetadata): T {
return value
}
public fun set(thisRef: Any?, desc: PropertyMetadata, newValue: T) {
changeSupport(desc.name, value, newValue)
value = newValue
}
}
public class KeyMissingException(message: String): RuntimeException(message)
public abstract class MapVal<T, V> {
public abstract fun getMap(thisRef: T): Map<*, *>
public abstract fun getKey(desc: PropertyMetadata): Any?
public open fun getDefaultValue(desc: PropertyMetadata, key: Any?): V {
throw KeyMissingException("Key $key is missing")
}
public fun get(thisRef: T, desc: PropertyMetadata): V {
val key = getKey(desc)
val map = getMap(thisRef)
if (!map.containsKey(key)) {
return getDefaultValue(desc, key)
}
return map[key] as V
}
}
public abstract class MapVar<T, V>: MapVal<T, V>() {
public fun set(thisRef: T, desc: PropertyMetadata, newValue: V) {
val map = getMap(thisRef) as MutableMap<Any?, Any?>
map[getKey(desc)] = newValue
}
}
public fun <V> Map<String, *>.readOnlyProperty(default: (() -> V)? = null): MapVal<Any?, V> {
return object: MapVal<Any?, V>() {
override fun getMap(thisRef: Any?) = this@readOnlyProperty
override fun getKey(desc: PropertyMetadata) = desc.name
override fun getDefaultValue(desc: PropertyMetadata, key: Any?) = if (default == null) super.getDefaultValue(desc, key) else default()
}
}
public fun <V> Map<*, *>.readOnlyProperty(default: (() -> V)? = null, key: Any?): MapVal<Any?, V> {
return object: MapVal<Any?, V>() {
override fun getMap(thisRef: Any?) = this@readOnlyProperty
override fun getKey(desc: PropertyMetadata) = key
override fun getDefaultValue(desc: PropertyMetadata, key: Any?) = if (default == null) super.getDefaultValue(desc, key) else default()
}
}
public fun <V> Map<*, *>.readOnlyProperty(default: (() -> V)? = null, key: (desc: PropertyMetadata) -> Any?): MapVal<Any?, V> {
return object: MapVal<Any?, V>() {
override fun getMap(thisRef: Any?) = this@readOnlyProperty
override fun getKey(desc: PropertyMetadata) = key(desc)
override fun getDefaultValue(desc: PropertyMetadata, key: Any?) = if (default == null) super.getDefaultValue(desc, key) else default()
}
}
public fun <V> MutableMap<String, *>.property(default: (() -> V)? = null): MapVar<Any?, V> {
return object: MapVar<Any?, V>() {
override fun getMap(thisRef: Any?) = this@property
override fun getKey(desc: PropertyMetadata) = desc.name
override fun getDefaultValue(desc: PropertyMetadata, key: Any?) = if (default == null) super.getDefaultValue(desc, key) else default()
}
}
public fun <V> MutableMap<*, *>.property(default: (() -> V)? = null, key: Any?): MapVar<Any?, V> {
return object: MapVar<Any?, V>() {
override fun getMap(thisRef: Any?) = this@property
override fun getKey(desc: PropertyMetadata) = key
override fun getDefaultValue(desc: PropertyMetadata, key: Any?) = if (default == null) super.getDefaultValue(desc, key) else default()
}
}
public fun <V> MutableMap<*, *>.property(default: (() -> V)? = null, key: (desc: PropertyMetadata) -> Any?): MapVar<Any?, V> {
return object: MapVar<Any?, V>() {
override fun getMap(thisRef: Any?) = this@property
override fun getKey(desc: PropertyMetadata) = key(desc)
override fun getDefaultValue(desc: PropertyMetadata, key: Any?) = if (default == null) super.getDefaultValue(desc, key) else default()
}
}
@@ -0,0 +1,75 @@
package kotlin.properties.delegation.lazy
private val NULL_VALUE: Any = Any()
private fun <T> escape(value: T): Any {
return if (value == null) NULL_VALUE else value
}
private fun <T: Any> unescape(value: Any): T? {
return if (value == NULL_VALUE) null else value as T
}
public open class LazyVal<T: Any>(initializer: () -> T): NullableLazyVal<T>(initializer) {
override fun get(thisRef: Any?, desc: PropertyMetadata): T {
return super.get(thisRef, desc)!!
}
}
public open class NullableLazyVal<T: Any>(private val initializer: () -> T?) {
private var value: Any? = null
public open fun get(thisRef: Any?, desc: PropertyMetadata): T? {
if (value == null) {
value = escape(initializer())
}
return unescape(value!!)
}
}
public open class VolatileLazyVal<T: Any>(initializer: () -> T): VolatileNullableLazyVal<T>(initializer) {
override fun get(thisRef: Any?, desc: PropertyMetadata): T {
return super.get(thisRef, desc)!!
}
}
public open class VolatileNullableLazyVal<T: Any>(private val initializer: () -> T?) {
private volatile var value: Any? = null
public open fun get(thisRef: Any?, desc: PropertyMetadata): T? {
if (value == null) {
value = escape(initializer())
}
return unescape(value!!)
}
}
public open class AtomicLazyVal<T: Any>(lock: Any? = null, initializer: () -> T): AtomicNullableLazyVal<T>(lock, initializer) {
override fun get(thisRef: Any?, desc: PropertyMetadata): T {
return super.get(thisRef, desc)!!
}
}
public open class AtomicNullableLazyVal<T: Any>(lock: Any? = null, private val initializer: () -> T?) {
private val lock = lock ?: this
private volatile var value: Any? = null
public open fun get(thisRef: Any?, desc: PropertyMetadata): T? {
val _v1 = value
if (_v1 != null) {
return unescape(_v1)
}
return synchronized(lock) {
val _v2 = value
if (_v2 != null) {
unescape<T>(_v2)
}
else {
val typedValue = initializer()
value = escape(typedValue)
typedValue
}
}
}
}
+6 -6
View File
@@ -1,7 +1,7 @@
<project name="Update Dependencies" default="update">
<property name="jb.buildserver.build.id" value="1964536"/>
<property name="public.buildserver.build.id" value="85865"/>
<property name="idea.archive.name" value="ideaIC-129.SNAPSHOT.win.zip"/>
<property name="jb.buildserver.build.id" value="1973992"/>
<property name="public.buildserver.build.id" value="86185"/>
<property name="idea.archive.name" value="ideaIC-130.SNAPSHOT.win.zip"/>
<property name="idea.sdk.fetch.needed" value="true"/>
@@ -118,7 +118,7 @@
-->
<!-- Guava 12 sources-->
<get-maven-library prefix="com/google/guava" lib="guava" version="12.0" bin="false"/>
<get-maven-library prefix="com/google/guava" lib="guava" version="14.0" bin="false"/>
<!-- ASM 4 -->
<get-asm4-and-rename-packages/>
@@ -178,7 +178,7 @@
<get src="@{base.url.for.core}/core/intellij-core.jar" dest="${core}/intellij-core.jar" usetimestamp="true"/>
<get src="@{base.url}/core/annotations.jar" dest="${core}/annotations.jar" usetimestamp="true"/>
<get src="@{base.url}/core/cli-parser-1.1.jar" dest="${core}/cli-parser-1.1.jar" usetimestamp="true"/>
<get src="@{base.url}/core/guava-12.0.jar" dest="${core}/guava-12.0.jar" usetimestamp="true"/>
<get src="@{base.url}/core/guava-14.0.1.jar" dest="${core}/guava-14.0.1.jar" usetimestamp="true"/>
<get src="@{base.url}/core/picocontainer.jar" dest="${core}/picocontainer.jar" usetimestamp="true"/>
<get src="@{base.url}/core/trove4j.jar" dest="${core}/trove4j.jar" usetimestamp="true"/>
@@ -192,7 +192,7 @@
<get src="@{base.url}/jps/jps-model.jar" dest="${jps}/jps-model.jar" usetimestamp="true"/>
<get src="@{base.url}/jps/log4j.jar" dest="${jps}/log4j.jar" usetimestamp="true"/>
<get src="@{base.url}/jps/nanoxml-2.2.3.jar" dest="${jps}/nanoxml-2.2.3.jar" usetimestamp="true"/>
<get src="@{base.url}/jps/protobuf-2.4.1.jar" dest="${jps}/protobuf-2.4.1.jar" usetimestamp="true"/>
<get src="@{base.url}/jps/protobuf-2.5.0.jar" dest="${jps}/protobuf-2.5.0.jar" usetimestamp="true"/>
<get src="@{base.url}/jps/trove4j.jar" dest="${jps}/trove4j.jar" usetimestamp="true"/>
<get src="@{base.url}/jps/ui-designer-jps-plugin.jar" dest="${jps}/ui-designer-jps-plugin.jar" usetimestamp="true"/>
<get src="@{base.url}/jps/util.jar" dest="${jps}/util.jar" usetimestamp="true"/>