CLI: move *CompilerArguments classes to cli-common module.

This commit is contained in:
Zalim Bashorov
2013-10-08 22:39:39 +04:00
parent db5faf8300
commit 0901c98ff8
20 changed files with 44 additions and 31 deletions
@@ -0,0 +1,65 @@
/*
* Copyright 2010-2013 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.cli.common.arguments;
import com.sampullara.cli.Argument;
public abstract class CommonCompilerArguments extends CompilerArguments {
@Argument(value = "tags", description = "Demarcate each compilation message (error, warning, etc) with an open and close tag")
public boolean tags;
@Argument(value = "verbose", description = "Enable verbose logging output")
public boolean verbose;
@Argument(value = "version", description = "Display compiler version")
public boolean version;
@Argument(value = "help", alias = "h", description = "Show help")
public boolean help;
@Argument(value = "suppress", description = "Suppress compiler messages by severity (warnings)")
public String suppress;
@Override
public boolean isHelp() {
return help;
}
public void setHelp(boolean help) {
this.help = help;
}
@Override
public boolean isTags() {
return tags;
}
@Override
public boolean isVersion() {
return version;
}
@Override
public boolean isVerbose() {
return verbose;
}
public void setTags(boolean tags) {
this.tags = tags;
}
@Override
public boolean suppressAllWarnings() {
return "warnings".equalsIgnoreCase(suppress);
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2010-2013 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.cli.common.arguments;
import com.intellij.util.SmartList;
import java.util.List;
public abstract class CompilerArguments {
public List<String> freeArgs = new SmartList<String>();
public abstract boolean isHelp();
public abstract boolean isTags();
public abstract boolean isVersion();
public abstract boolean isVerbose();
public abstract String getSrc();
public abstract boolean suppressAllWarnings();
}
@@ -0,0 +1,49 @@
/*
* Copyright 2010-2013 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.cli.common.arguments;
import com.sampullara.cli.Argument;
import org.jetbrains.annotations.Nullable;
/**
* NOTE: for now K2JSCompiler supports only minimal amount of parameters required to launch it from the plugin.
*/
public class K2JSCompilerArguments extends CommonCompilerArguments {
@Argument(value = "output", description = "Output file path")
public String outputFile;
@Argument(value = "libraryFiles", description = "Path to zipped lib sources or kotlin files")
public String[] libraryFiles;
@Argument(value = "sourceFiles", description = "Source files (dir or file)")
public String[] sourceFiles;
@Argument(value = "sourcemap", description = "Generate SourceMap")
public boolean sourcemap;
@Argument(value = "target", description = "Generate js files for specific ECMA version (now support only ECMA 5)")
public String target;
@Nullable
@Argument(value = "main", description = "Whether a main function should be called; either 'call' or 'noCall', default 'call' (main function will be auto detected)")
public String main;
@Override
public String getSrc() {
throw new IllegalStateException();
}
}
@@ -0,0 +1,142 @@
/**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.cli.common.arguments;
import com.sampullara.cli.Argument;
import java.util.List;
/**
* Command line arguments for the {@link K2JVMCompiler}
*/
@SuppressWarnings("UnusedDeclaration")
public class K2JVMCompilerArguments extends CommonCompilerArguments {
// TODO ideally we'd unify this with 'src' to just having a single field that supports multiple files/dirs
private List<String> sourceDirs;
public List<String> getSourceDirs() {
return sourceDirs;
}
public void setSourceDirs(List<String> sourceDirs) {
this.sourceDirs = sourceDirs;
}
@Argument(value = "jar", description = "jar file name")
public String jar;
@Argument(value = "src", description = "source file or directory (allows many paths separated by the system path separator)")
public String src;
@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 = "noJdk", description = "don't include Java runtime into classpath")
public boolean noJdk;
@Argument(value = "noStdlib", description = "don't include Kotlin runtime into classpath")
public boolean noStdlib;
@Argument(value = "noJdkAnnotations", description = "don't include JDK external annotations into classpath")
public boolean noJdkAnnotations;
@Argument(value = "notNullAssertions", description = "generate not-null assertion after each invokation of method returning not-null")
public boolean notNullAssertions;
@Argument(value = "notNullParamAssertions", description = "generate not-null assertions on parameters of methods accessible from Java")
public boolean notNullParamAssertions;
@Argument(value = "output", description = "output directory")
public String outputDir;
@Argument(value = "module", description = "module to compile")
public String module;
@Argument(value = "script", description = "evaluate script")
public boolean script;
@Argument(value = "kotlinHome", description = "Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery")
public String kotlinHome;
public String getKotlinHome() {
return kotlinHome;
}
public void setKotlinHome(String kotlinHome) {
this.kotlinHome = kotlinHome;
}
public String getClasspath() {
return classpath;
}
public void setClasspath(String classpath) {
this.classpath = classpath;
}
public boolean isIncludeRuntime() {
return includeRuntime;
}
public void setIncludeRuntime(boolean includeRuntime) {
this.includeRuntime = includeRuntime;
}
public String getJar() {
return jar;
}
public void setJar(String jar) {
this.jar = jar;
}
public String getModule() {
return module;
}
public void setModule(String module) {
this.module = module;
}
public String getOutputDir() {
return outputDir;
}
public void setOutputDir(String outputDir) {
this.outputDir = outputDir;
}
@Override
public String getSrc() {
return src;
}
public void setSrc(String src) {
this.src = src;
}
public void setNoStdlib(boolean noStdlib) {
this.noStdlib = noStdlib;
}
}