Rename package jet -> kotlin in injector-generator

org.jetbrains.jet.di -> org.jetbrains.kotlin.generators.di
This commit is contained in:
Alexander Udalov
2015-01-02 19:38:14 +03:00
parent 77be31c149
commit 159a2dc585
25 changed files with 67 additions and 62 deletions
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -69,6 +69,7 @@ public class ConstructorCall implements Expression {
} }
@NotNull @NotNull
@Override
public DiType getType() { public DiType getType() {
return new DiType(constructor.getDeclaringClass()); return new DiType(constructor.getDeclaringClass());
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -22,13 +22,14 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.inject.Inject;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.*; import java.util.*;
import static org.jetbrains.jet.di.InjectorGeneratorUtil.var; import static org.jetbrains.kotlin.generators.di.InjectorGeneratorUtil.var;
public class Dependencies { public class Dependencies {
@@ -69,14 +70,16 @@ public class Dependencies {
List<Method> declaredMethods = Lists.newArrayList(typeToInitialize.getClazz().getDeclaredMethods()); List<Method> declaredMethods = Lists.newArrayList(typeToInitialize.getClazz().getDeclaredMethods());
Collections.sort(declaredMethods, new Comparator<Method>() { Collections.sort(declaredMethods, new Comparator<Method>() {
@Override @Override
public int compare(Method o1, Method o2) { public int compare(@NotNull Method o1, @NotNull Method o2) {
return o1.getName().compareTo(o2.getName()); return o1.getName().compareTo(o2.getName());
} }
}); });
for (Method method : declaredMethods) { for (Method method : declaredMethods) {
if (method.getAnnotation(javax.inject.Inject.class) == null if (method.getAnnotation(Inject.class) == null
|| !method.getName().startsWith("set") || !method.getName().startsWith("set")
|| method.getParameterTypes().length != 1) continue; || method.getParameterTypes().length != 1) {
continue;
}
Type parameterType = method.getGenericParameterTypes()[0]; Type parameterType = method.getGenericParameterTypes()[0];
@@ -245,6 +248,7 @@ public class Dependencies {
}; };
@NotNull @NotNull
@SuppressWarnings("unchecked")
public static <T> ImmutableStack<T> empty() { public static <T> ImmutableStack<T> empty() {
return EMPTY; return EMPTY;
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2014 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@@ -32,7 +32,7 @@ import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import static org.jetbrains.jet.di.InjectorGeneratorUtil.var; import static org.jetbrains.kotlin.generators.di.InjectorGeneratorUtil.var;
public class DependencyInjectorGenerator { public class DependencyInjectorGenerator {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtil;
@@ -27,7 +27,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import static org.jetbrains.jet.di.InjectorGeneratorUtil.var; import static org.jetbrains.kotlin.generators.di.InjectorGeneratorUtil.var;
class Field { class Field {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.FileUtil;
@@ -48,17 +48,17 @@ public class GeneratorsFileUtil {
return; return;
} }
boolean useTmpfile = !SystemInfo.isWindows; boolean useTempFile = !SystemInfo.isWindows;
File tmpfile = useTmpfile ? new File(file.getName() + ".tmp") : file; File tempFile = useTempFile ? new File(file.getName() + ".tmp") : file;
FileUtil.writeToFile(tmpfile, newText); FileUtil.writeToFile(tempFile, newText);
System.out.println("File written: " + tmpfile.getAbsolutePath()); System.out.println("File written: " + tempFile.getAbsolutePath());
if (useTmpfile) { if (useTempFile) {
if (!tmpfile.renameTo(file)) { if (!tempFile.renameTo(file)) {
throw new RuntimeException("failed to rename " + tmpfile + " to " + file); throw new RuntimeException("failed to rename " + tempFile + " to " + file);
} }
System.out.println("Renamed " + tmpfile + " to " + file); System.out.println("Renamed " + tempFile + " to " + file);
} }
System.out.println(); System.out.println();
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2014 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -62,6 +62,7 @@ public class GivenExpression implements Expression {
return "given<" + expression + ">"; return "given<" + expression + ">";
} }
@Override
public DiType getType() { public DiType getType() {
return null; return null;
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.utils.DFS; import org.jetbrains.jet.utils.DFS;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2014 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di package org.jetbrains.kotlin.generators.di
public fun generator( public fun generator(
targetSourceRoot: String, targetSourceRoot: String,
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtil;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -32,6 +32,7 @@ public class InstantiateType implements Expression {
this(new DiType(theClass)); this(new DiType(theClass));
} }
@Override
@NotNull @NotNull
public DiType getType() { public DiType getType() {
return type; return type;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2014 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,10 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di package org.jetbrains.kotlin.generators.di
import java.lang.reflect.Method import java.lang.reflect.Method
import org.jetbrains.jet.lang.types.JetType
public class MethodCall( public class MethodCall(
val receiver: Field, val receiver: Field,
@@ -30,5 +29,4 @@ public class MethodCall(
override fun getTypesToImport() = listOf<DiType>() override fun getTypesToImport() = listOf<DiType>()
override fun getType(): DiType = DiType.fromReflectionType(method.getGenericReturnType()) override fun getType(): DiType = DiType.fromReflectionType(method.getGenericReturnType())
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
class Parameter { class Parameter {
private final DiType type; private final DiType type;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.jet.di; package org.jetbrains.kotlin.generators.di;
class SetterDependency { class SetterDependency {
private final Field dependent; private final Field dependent;
@@ -16,9 +16,9 @@
package org.jetbrains.jet.generators.evaluate package org.jetbrains.jet.generators.evaluate
import org.jetbrains.jet.di.GeneratorsFileUtil
import java.io.File import java.io.File
import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.generators.di.GeneratorsFileUtil
import org.jetbrains.jet.utils.Printer import org.jetbrains.jet.utils.Printer
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
import org.jetbrains.jet.lang.descriptors.ClassDescriptor import org.jetbrains.jet.lang.descriptors.ClassDescriptor
@@ -19,10 +19,10 @@ package org.jetbrains.jet.generators.frontend;
import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.FileUtil;
import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.di.GeneratorsFileUtil;
import org.jetbrains.jet.lexer.JetKeywordToken; import org.jetbrains.jet.lexer.JetKeywordToken;
import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.utils.Printer; import org.jetbrains.jet.utils.Printer;
import org.jetbrains.kotlin.generators.di.GeneratorsFileUtil;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinder
import org.jetbrains.jet.lang.resolve.lazy.ResolveSession import org.jetbrains.jet.lang.resolve.lazy.ResolveSession
import org.jetbrains.jet.lang.resolve.lazy.declarations.DeclarationProviderFactory import org.jetbrains.jet.lang.resolve.lazy.declarations.DeclarationProviderFactory
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices
import org.jetbrains.jet.di.* import org.jetbrains.kotlin.generators.di.*
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingComponents import org.jetbrains.jet.lang.types.expressions.ExpressionTypingComponents
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils
import org.jetbrains.jet.lang.resolve.calls.CallResolver import org.jetbrains.jet.lang.resolve.calls.CallResolver
@@ -19,7 +19,7 @@ package org.jetbrains.jet.generators.tests.reservedWords
import java.io.File import java.io.File
import org.jetbrains.jet.renderer.KeywordStringsGenerated import org.jetbrains.jet.renderer.KeywordStringsGenerated
import com.google.dart.compiler.backend.js.ast.JsFunctionScope import com.google.dart.compiler.backend.js.ast.JsFunctionScope
import org.jetbrains.jet.di.GeneratorsFileUtil.writeFileIfContentChanged import org.jetbrains.kotlin.generators.di.GeneratorsFileUtil.writeFileIfContentChanged
val commonCases: CaseBuilder.(String, String) -> Unit = { (testByName, testByRef) -> val commonCases: CaseBuilder.(String, String) -> Unit = { (testByName, testByRef) ->
case("val", "val $KEYWORD_MARKER: Int", " = 0", testByName) case("val", "val $KEYWORD_MARKER: Int", " = 0", testByName)
@@ -24,8 +24,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JUnit3RunnerWithInners; import org.jetbrains.jet.JUnit3RunnerWithInners;
import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.di.GeneratorsFileUtil;
import org.jetbrains.jet.utils.Printer; import org.jetbrains.jet.utils.Printer;
import org.jetbrains.kotlin.generators.di.GeneratorsFileUtil;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.util.text.StringUtil;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.jetbrains.jet.di.DependencyInjectorGenerator; import org.jetbrains.kotlin.generators.di.DependencyInjectorGenerator;
import org.junit.Assert; import org.junit.Assert;
import java.io.IOException; import java.io.IOException;