diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml index 1172874a3..149b8453c 100644 --- a/.idea/codeStyleSettings.xml +++ b/.idea/codeStyleSettings.xml @@ -5,6 +5,14 @@ diff --git a/.idea/modules.xml b/.idea/modules.xml index 380ea5aba..954f431a8 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -9,6 +9,7 @@ + diff --git a/classlib/teavm-classlib.iml b/classlib/teavm-classlib.iml index 9fe7c13b0..4cbb552a6 100644 --- a/classlib/teavm-classlib.iml +++ b/classlib/teavm-classlib.iml @@ -1,5 +1,12 @@ + + + diff --git a/html4j/teavm-html4j.iml b/html4j/teavm-html4j.iml index a900dfb6d..ed9502aa5 100644 --- a/html4j/teavm-html4j.iml +++ b/html4j/teavm-html4j.iml @@ -8,7 +8,14 @@ - + + + + + + + + diff --git a/samples/async/teavm-samples-async.iml b/samples/async/teavm-samples-async.iml index a0b0341f7..c2b1426b5 100644 --- a/samples/async/teavm-samples-async.iml +++ b/samples/async/teavm-samples-async.iml @@ -35,5 +35,6 @@ + \ No newline at end of file diff --git a/samples/benchmark/teavm-samples-benchmark.iml b/samples/benchmark/teavm-samples-benchmark.iml index e636ebb73..330f1bcee 100644 --- a/samples/benchmark/teavm-samples-benchmark.iml +++ b/samples/benchmark/teavm-samples-benchmark.iml @@ -14,6 +14,8 @@ + + diff --git a/teavm.iml b/teavm.iml index bebe45005..35f71533f 100644 --- a/teavm.iml +++ b/teavm.iml @@ -1,18 +1,19 @@ - - - - - - - + + + + diff --git a/tools/cli/teavm-cli.iml b/tools/cli/teavm-cli.iml index f1df25985..a90d1720a 100644 --- a/tools/cli/teavm-cli.iml +++ b/tools/cli/teavm-cli.iml @@ -9,11 +9,11 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/tools/idea/src/main/java/org/teavm/idea/TeaVMBuildTarget.java b/tools/idea/src/main/java/org/teavm/idea/TeaVMBuildTarget.java new file mode 100644 index 000000000..21a307be4 --- /dev/null +++ b/tools/idea/src/main/java/org/teavm/idea/TeaVMBuildTarget.java @@ -0,0 +1,87 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * 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.teavm.idea; + +import java.io.File; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.builders.BuildRootIndex; +import org.jetbrains.jps.builders.BuildTarget; +import org.jetbrains.jps.builders.BuildTargetRegistry; +import org.jetbrains.jps.builders.ModuleBasedTarget; +import org.jetbrains.jps.builders.TargetOutputIndex; +import org.jetbrains.jps.builders.storage.BuildDataPaths; +import org.jetbrains.jps.incremental.CompileContext; +import org.jetbrains.jps.incremental.artifacts.instructions.ArtifactRootDescriptor; +import org.jetbrains.jps.indices.IgnoredFileIndex; +import org.jetbrains.jps.indices.ModuleExcludeIndex; +import org.jetbrains.jps.model.JpsModel; +import org.jetbrains.jps.model.module.JpsModule; + +public class TeaVMBuildTarget extends ModuleBasedTarget { + TeaVMBuildTarget(TeaVMBuildTargetType targetType, @NotNull JpsModule module) { + super(targetType, module); + } + + @Override + public boolean isTests() { + return false; + } + + @Override + public String getId() { + return getModule().getName() + "_teavm"; + } + + @Override + public Collection> computeDependencies(BuildTargetRegistry targetRegistry, + TargetOutputIndex outputIndex) { + return Collections.emptyList(); + } + + @NotNull + @Override + public List computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, + IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) { + return Collections.emptyList(); + } + + @Nullable + @Override + public ArtifactRootDescriptor findRootDescriptor(String rootId, BuildRootIndex rootIndex) { + return null; + } + + @NotNull + @Override + public String getPresentableName() { + return getModule().getName() + " (TeaVM)"; + } + + @NotNull + @Override + public Collection getOutputRoots(CompileContext context) { + TeaVMModuleExtension extension = getModule().getContainer().getChild(TeaVMModuleExtension.ROLE); + if (extension == null) { + return Collections.emptyList(); + } + return Arrays.asList(new File(extension.getTargetDirectory())); + } +} diff --git a/tools/idea/src/main/java/org/teavm/idea/TeaVMBuildTargetType.java b/tools/idea/src/main/java/org/teavm/idea/TeaVMBuildTargetType.java new file mode 100644 index 000000000..f3b1c7510 --- /dev/null +++ b/tools/idea/src/main/java/org/teavm/idea/TeaVMBuildTargetType.java @@ -0,0 +1,52 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * 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.teavm.idea; + +import java.util.ArrayList; +import java.util.List; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.builders.BuildTargetLoader; +import org.jetbrains.jps.builders.ModuleBasedBuildTargetType; +import org.jetbrains.jps.incremental.ModuleBuildTarget; +import org.jetbrains.jps.model.JpsModel; +import org.jetbrains.jps.model.module.JpsModule; + +public class TeaVMBuildTargetType extends ModuleBasedBuildTargetType { + public static final TeaVMBuildTargetType INSTANCE = new TeaVMBuildTargetType("teavm"); + + public TeaVMBuildTargetType(String typeId) { + super(typeId); + } + + @NotNull + @Override + public List computeAllTargets(@NotNull JpsModel model) { + List modules = model.getProject().getModules(); + List targets = new ArrayList<>(modules.size()); + for (JpsModule module : modules) { + if (module.getContainer().getChild(TeaVMModuleExtension.ROLE) != null) { + targets.add(new TeaVMBuildTarget(this, module)); + } + } + return targets; + } + + @NotNull + @Override + public BuildTargetLoader createLoader(@NotNull JpsModel model) { + return null; + } +} diff --git a/tools/idea/src/main/java/org/teavm/idea/TeaVMBuilder.java b/tools/idea/src/main/java/org/teavm/idea/TeaVMBuilder.java new file mode 100644 index 000000000..6c75b17f5 --- /dev/null +++ b/tools/idea/src/main/java/org/teavm/idea/TeaVMBuilder.java @@ -0,0 +1,46 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * 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.teavm.idea; + +import java.io.IOException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.ModuleChunk; +import org.jetbrains.jps.builders.DirtyFilesHolder; +import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor; +import org.jetbrains.jps.incremental.BuilderCategory; +import org.jetbrains.jps.incremental.CompileContext; +import org.jetbrains.jps.incremental.ModuleBuildTarget; +import org.jetbrains.jps.incremental.ModuleLevelBuilder; +import org.jetbrains.jps.incremental.ProjectBuildException; + +public class TeaVMBuilder extends ModuleLevelBuilder { + public TeaVMBuilder(BuilderCategory category) { + super(category); + } + + @Override + public ExitCode build(CompileContext context, ModuleChunk chunk, + DirtyFilesHolder dirtyFilesHolder, + OutputConsumer outputConsumer) throws ProjectBuildException, IOException { + return ExitCode.OK; + } + + @NotNull + @Override + public String getPresentableName() { + return "TeaVM builder"; + } +} diff --git a/tools/idea/src/main/java/org/teavm/idea/TeaVMBuilderService.java b/tools/idea/src/main/java/org/teavm/idea/TeaVMBuilderService.java new file mode 100644 index 000000000..d4e2f6e13 --- /dev/null +++ b/tools/idea/src/main/java/org/teavm/idea/TeaVMBuilderService.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * 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.teavm.idea; + +import java.util.Arrays; +import java.util.List; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.builders.BuildTargetType; +import org.jetbrains.jps.incremental.BuilderCategory; +import org.jetbrains.jps.incremental.BuilderService; +import org.jetbrains.jps.incremental.ModuleLevelBuilder; +import org.jetbrains.jps.incremental.TargetBuilder; + +public class TeaVMBuilderService extends BuilderService { + @NotNull + @Override + public List> getTargetTypes() { + return Arrays.asList(TeaVMBuildTargetType.INSTANCE); + } + + @NotNull + @Override + public List createModuleLevelBuilders() { + return Arrays.asList(new TeaVMBuilder(BuilderCategory.CLASS_POST_PROCESSOR)); + } +} diff --git a/tools/idea/src/main/java/org/teavm/idea/TeaVMModuleExtension.java b/tools/idea/src/main/java/org/teavm/idea/TeaVMModuleExtension.java new file mode 100644 index 000000000..b60b0db48 --- /dev/null +++ b/tools/idea/src/main/java/org/teavm/idea/TeaVMModuleExtension.java @@ -0,0 +1,63 @@ +/* + * Copyright 2016 Alexey Andreev. + * + * 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.teavm.idea; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.model.JpsElementChildRole; +import org.jetbrains.jps.model.ex.JpsCompositeElementBase; +import org.jetbrains.jps.model.ex.JpsElementChildRoleBase; + +public class TeaVMModuleExtension extends JpsCompositeElementBase { + public static final JpsElementChildRole ROLE = JpsElementChildRoleBase + .create("TeaVM configuration"); + private String mainClass; + private String targetDirectory; + + public TeaVMModuleExtension(@NotNull String mainClass, @NotNull String targetDirectory) { + this.mainClass = mainClass; + this.targetDirectory = targetDirectory; + } + + public TeaVMModuleExtension(TeaVMModuleExtension original) { + super(original); + mainClass = original.mainClass; + targetDirectory = original.targetDirectory; + } + + @NotNull + public String getMainClass() { + return mainClass; + } + + public void setMainClass(@NotNull String mainClass) { + this.mainClass = mainClass; + } + + @NotNull + public String getTargetDirectory() { + return targetDirectory; + } + + public void setTargetDirectory(@NotNull String targetDirectory) { + this.targetDirectory = targetDirectory; + } + + @NotNull + @Override + public TeaVMModuleExtension createCopy() { + return new TeaVMModuleExtension(this); + } +} diff --git a/tools/idea/src/main/resources/META-INF/plugin.xml b/tools/idea/src/main/resources/META-INF/plugin.xml new file mode 100644 index 000000000..68ae2627b --- /dev/null +++ b/tools/idea/src/main/resources/META-INF/plugin.xml @@ -0,0 +1,35 @@ + + com.your.company.unique.plugin.id + Plugin display name here + 1.0 + YourCompany + + + most HTML tags may be used + ]]> + + + most HTML tags may be used + ]]> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/idea/src/main/resources/META-INF/services/org.jetbrains.jps.incremental.BuilderService b/tools/idea/src/main/resources/META-INF/services/org.jetbrains.jps.incremental.BuilderService new file mode 100644 index 000000000..f1072fdb7 --- /dev/null +++ b/tools/idea/src/main/resources/META-INF/services/org.jetbrains.jps.incremental.BuilderService @@ -0,0 +1 @@ +org.teavm.idea.TeaVMBuilderService \ No newline at end of file diff --git a/tools/idea/teavm-idea-plugin.iml b/tools/idea/teavm-idea-plugin.iml new file mode 100644 index 000000000..eacb55867 --- /dev/null +++ b/tools/idea/teavm-idea-plugin.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file