When generating light class for package, do not generate other classes
This commit is contained in:
@@ -124,8 +124,10 @@ public class NamespaceCodegen extends MemberCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (declaration instanceof JetClassOrObject) {
|
else if (declaration instanceof JetClassOrObject) {
|
||||||
final CodegenContext context = CodegenContext.STATIC.intoNamespace(descriptor);
|
if (state.isGenerateDeclaredClasses()) {
|
||||||
genClassOrObject(context, (JetClassOrObject) declaration);
|
final CodegenContext context = CodegenContext.STATIC.intoNamespace(descriptor);
|
||||||
|
genClassOrObject(context, (JetClassOrObject) declaration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (declaration instanceof JetScript) {
|
else if (declaration instanceof JetScript) {
|
||||||
state.getScriptCodegen().generate((JetScript) declaration);
|
state.getScriptCodegen().generate((JetScript) declaration);
|
||||||
|
|||||||
@@ -66,8 +66,10 @@ public class GenerationState {
|
|||||||
|
|
||||||
private final boolean generateNotNullParamAssertions;
|
private final boolean generateNotNullParamAssertions;
|
||||||
|
|
||||||
|
private final boolean generateDeclaredClasses;
|
||||||
|
|
||||||
public GenerationState(Project project, ClassBuilderFactory builderFactory, BindingContext bindingContext, List<JetFile> files) {
|
public GenerationState(Project project, ClassBuilderFactory builderFactory, BindingContext bindingContext, List<JetFile> files) {
|
||||||
this(project, builderFactory, Progress.DEAF, bindingContext, files, BuiltinToJavaTypesMapping.ENABLED, true, false);
|
this(project, builderFactory, Progress.DEAF, bindingContext, files, BuiltinToJavaTypesMapping.ENABLED, true, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenerationState(
|
public GenerationState(
|
||||||
@@ -78,7 +80,8 @@ public class GenerationState {
|
|||||||
@NotNull List<JetFile> files,
|
@NotNull List<JetFile> files,
|
||||||
@NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping,
|
@NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping,
|
||||||
boolean generateNotNullAssertions,
|
boolean generateNotNullAssertions,
|
||||||
boolean generateNotNullParamAssertions
|
boolean generateNotNullParamAssertions,
|
||||||
|
boolean generateDeclaredClasses
|
||||||
) {
|
) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
@@ -100,6 +103,7 @@ public class GenerationState {
|
|||||||
|
|
||||||
this.generateNotNullAssertions = generateNotNullAssertions;
|
this.generateNotNullAssertions = generateNotNullAssertions;
|
||||||
this.generateNotNullParamAssertions = generateNotNullParamAssertions;
|
this.generateNotNullParamAssertions = generateNotNullParamAssertions;
|
||||||
|
this.generateDeclaredClasses = generateDeclaredClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -160,6 +164,10 @@ public class GenerationState {
|
|||||||
return generateNotNullParamAssertions;
|
return generateNotNullParamAssertions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGenerateDeclaredClasses() {
|
||||||
|
return generateDeclaredClasses;
|
||||||
|
}
|
||||||
|
|
||||||
public void beforeCompile() {
|
public void beforeCompile() {
|
||||||
markUsed();
|
markUsed();
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -353,7 +353,8 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
project, ClassBuilderFactories.binaries(stubs), backendProgress, exhaust.getBindingContext(), environment.getSourceFiles(),
|
project, ClassBuilderFactories.binaries(stubs), backendProgress, exhaust.getBindingContext(), environment.getSourceFiles(),
|
||||||
configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED),
|
configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED),
|
||||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, false),
|
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, false),
|
||||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, false)
|
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, false),
|
||||||
|
/*generateDeclaredClasses = */true
|
||||||
);
|
);
|
||||||
KotlinCodegenFacade.compileCorrectFiles(generationState, StandardGenerationStrategy.INSTANCE, CompilationErrorHandler.THROW_EXCEPTION);
|
KotlinCodegenFacade.compileCorrectFiles(generationState, StandardGenerationStrategy.INSTANCE, CompilationErrorHandler.THROW_EXCEPTION);
|
||||||
|
|
||||||
|
|||||||
+18
-7
@@ -5,7 +5,11 @@
|
|||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apacheither express or implied.
|
* 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
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
@@ -26,12 +30,10 @@ import com.intellij.testFramework.LightVirtualFile;
|
|||||||
import com.intellij.util.containers.Stack;
|
import com.intellij.util.containers.Stack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.codegen.ClassBuilder;
|
import org.jetbrains.jet.codegen.*;
|
||||||
import org.jetbrains.jet.codegen.ClassBuilderFactory;
|
|
||||||
import org.jetbrains.jet.codegen.ClassBuilderMode;
|
|
||||||
import org.jetbrains.jet.codegen.CompilationErrorHandler;
|
|
||||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||||
import org.jetbrains.jet.codegen.state.GenerationStrategy;
|
import org.jetbrains.jet.codegen.state.GenerationStrategy;
|
||||||
|
import org.jetbrains.jet.codegen.state.Progress;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
@@ -75,10 +77,19 @@ public class KotlinLightClassForPackageProvider implements CachedValueProvider<P
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GenerationState state = new GenerationState(project, builderFactory, context.getBindingContext(), Lists.newArrayList(files));
|
GenerationState state = new GenerationState(
|
||||||
|
project,
|
||||||
|
builderFactory,
|
||||||
|
Progress.DEAF,
|
||||||
|
context.getBindingContext(),
|
||||||
|
Lists.newArrayList(files),
|
||||||
|
BuiltinToJavaTypesMapping.ENABLED,
|
||||||
|
/*not-null assertions*/false, false,
|
||||||
|
/*generateDeclaredClasses=*/false);
|
||||||
|
|
||||||
GenerationStrategy strategy = new LightClassGenerationStrategy(new LightVirtualFile(), stubStack, javaFileStub);
|
GenerationStrategy strategy = new LightClassGenerationStrategy(new LightVirtualFile(), stubStack, javaFileStub);
|
||||||
|
|
||||||
strategy.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
|
KotlinCodegenFacade.compileCorrectFiles(state, strategy, CompilationErrorHandler.THROW_EXCEPTION);
|
||||||
state.getFactory().files();
|
state.getFactory().files();
|
||||||
}
|
}
|
||||||
catch (ProcessCanceledException e) {
|
catch (ProcessCanceledException e) {
|
||||||
|
|||||||
@@ -361,7 +361,8 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
|||||||
environment.getProject(), classBuilderFactory, Progress.DEAF, analyzeExhaust.getBindingContext(), files.getPsiFiles(),
|
environment.getProject(), classBuilderFactory, Progress.DEAF, analyzeExhaust.getBindingContext(), files.getPsiFiles(),
|
||||||
configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED),
|
configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED),
|
||||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, true),
|
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, true),
|
||||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, true)
|
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, true),
|
||||||
|
/*generateDeclaredClasses = */true
|
||||||
);
|
);
|
||||||
KotlinCodegenFacade.compileCorrectFiles(state, StandardGenerationStrategy.INSTANCE, CompilationErrorHandler.THROW_EXCEPTION);
|
KotlinCodegenFacade.compileCorrectFiles(state, StandardGenerationStrategy.INSTANCE, CompilationErrorHandler.THROW_EXCEPTION);
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
Reference in New Issue
Block a user