J2K KotlinScriptDefinition and simplify

This commit is contained in:
Pavel V. Talanov
2015-11-20 20:15:17 +03:00
parent 15b7eca665
commit 89081d487f
3 changed files with 27 additions and 57 deletions
@@ -1,55 +0,0 @@
/*
* Copyright 2010-2015 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.kotlin.parsing;
import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter;
import org.jetbrains.kotlin.resolve.ImportPath;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class KotlinScriptDefinition {
private final String extension;
private final List<AnalyzerScriptParameter> parameters;
public KotlinScriptDefinition(String extension, List<AnalyzerScriptParameter> scriptParameters) {
this.extension = extension;
parameters = scriptParameters == null ? Collections.<AnalyzerScriptParameter>emptyList() : scriptParameters;
}
private static List<ImportPath> importPaths(List<String> imports) {
List<ImportPath> paths = new ArrayList<ImportPath>(imports.size());
for (String anImport : imports) {
paths.add(new ImportPath(anImport));
}
return paths;
}
public KotlinScriptDefinition(String extension, AnalyzerScriptParameter... scriptParameters) {
this(extension, Arrays.asList(scriptParameters));
}
public List<AnalyzerScriptParameter> getScriptParameters() {
return parameters;
}
public String getExtension() {
return extension;
}
}
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2015 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.kotlin.parsing
import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter
class KotlinScriptDefinition(val extension: String, val scriptParameters: List<AnalyzerScriptParameter>)
@@ -28,10 +28,14 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import static java.util.Collections.singletonList;
public class ScriptGenTest extends CodegenTestCase {
private static final KotlinScriptDefinition FIB_SCRIPT_DEFINITION =
new KotlinScriptDefinition(".lang.kt",
new AnalyzerScriptParameter(Name.identifier("num"), JvmPlatform.INSTANCE$.getBuiltIns().getIntType()));
new KotlinScriptDefinition(
".lang.kt",
singletonList(new AnalyzerScriptParameter(Name.identifier("num"), JvmPlatform.INSTANCE$.getBuiltIns().getIntType()))
);
@Override
protected void setUp() throws Exception {