Developing IDEA plugin

This commit is contained in:
Alexey Andreev 2016-02-13 20:41:33 +03:00
parent c744cd3644
commit 4b255e0897
21 changed files with 543 additions and 276 deletions

198
.idea/compiler.xml Normal file
View File

@ -0,0 +1,198 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<excludeFromCompile>
<directory url="file://$PROJECT_DIR$/tools/maven/webapp/src/main/resources/archetype-resources" includeSubdirectories="true" />
</excludeFromCompile>
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
<profile default="false" name="Annotation profile for teavm-cli" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-cli" />
</profile>
<profile default="false" name="Annotation profile for teavm-tooling" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-tooling" />
</profile>
<profile default="false" name="Annotation profile for teavm-platform" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-platform" />
</profile>
<profile default="false" name="Annotation profile for teavm-html4j" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-html4j" />
</profile>
<profile default="false" name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-maven-webapp" />
</profile>
<profile default="false" name="Annotation profile for teavm-jso-impl" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-jso-impl" />
</profile>
<profile default="false" name="Annotation profile for teavm-maven-plugin" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-maven-plugin" />
</profile>
<profile default="false" name="Annotation profile for teavm-jso-apis" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-jso-apis" />
</profile>
<profile default="false" name="Annotation profile for teavm-samples-scala" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-samples-scala" />
</profile>
<profile default="false" name="Annotation profile for teavm-jso" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-jso" />
</profile>
<profile default="false" name="Annotation profile for teavm-core" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-core" />
</profile>
<profile default="false" name="Annotation profile for teavm-samples-kotlin" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-samples-kotlin" />
</profile>
<profile default="false" name="Annotation profile for teavm-classlib" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-classlib" />
</profile>
<profile default="false" name="Annotation profile for teavm-samples-async" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-samples-async" />
</profile>
<profile default="false" name="Annotation profile for teavm-samples-video" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-samples-video" />
</profile>
<profile default="false" name="Annotation profile for teavm-samples-storage" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-samples-storage" />
</profile>
<profile default="false" name="Annotation profile for teavm-samples-benchmark" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-samples-benchmark" />
</profile>
<profile default="false" name="Annotation profile for teavm-samples-hello" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-samples-hello" />
</profile>
<profile default="false" name="Annotation profile for teavm-extras-slf4j" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-extras-slf4j" />
</profile>
<profile default="false" name="Annotation profile for teavm-chrome-rdp" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-chrome-rdp" />
</profile>
<profile default="false" name="Annotation profile for teavm-tests" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="teavm-tests" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="teavm" target="1.5" />
<module name="teavm-chrome-rdp" target="1.8" />
<module name="teavm-classlib" target="1.8" />
<module name="teavm-cli" target="1.8" />
<module name="teavm-core" target="1.8" />
<module name="teavm-extras-slf4j" target="1.8" />
<module name="teavm-html4j" target="1.8" />
<module name="teavm-jso" target="1.8" />
<module name="teavm-jso-apis" target="1.8" />
<module name="teavm-jso-impl" target="1.8" />
<module name="teavm-maven" target="1.5" />
<module name="teavm-maven-plugin" target="1.8" />
<module name="teavm-maven-webapp" target="1.5" />
<module name="teavm-platform" target="1.8" />
<module name="teavm-samples" target="1.5" />
<module name="teavm-samples-async" target="1.8" />
<module name="teavm-samples-benchmark" target="1.8" />
<module name="teavm-samples-hello" target="1.8" />
<module name="teavm-samples-kotlin" target="1.8" />
<module name="teavm-samples-scala" target="1.8" />
<module name="teavm-samples-storage" target="1.8" />
<module name="teavm-samples-video" target="1.8" />
<module name="teavm-tests" target="1.8" />
<module name="teavm-tooling" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>

View File

@ -0,0 +1,8 @@
<component name="CopyrightManager">
<settings default="Apache 2.0">
<LanguageOptions name="JAVA">
<option name="fileTypeOverride" value="3" />
<option name="addBlankAfter" value="false" />
</LanguageOptions>
</settings>
</component>

View File

@ -1,3 +0,0 @@
<component name="ProjectDictionaryState">
<dictionary name="Alexey Andreev" />
</component>

View File

@ -115,7 +115,7 @@
<option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" /> <option name="SUGGEST_PRIVATE_FOR_INNERS" value="false" />
</inspection_tool> </inspection_tool>
<inspection_tool class="WrongImportPackage" enabled="false" level="ERROR" enabled_by_default="false" /> <inspection_tool class="WrongImportPackage" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="XmlUnboundNsPrefix" enabled="true" level="WARNING" enabled_by_default="true"> <inspection_tool class="XmlUnboundNsPrefix" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<scope name="ecipse" level="WARNING" enabled="false" /> <scope name="ecipse" level="WARNING" enabled="false" />
</inspection_tool> </inspection_tool>
<inspection_tool class="unused" enabled="true" level="WARNING" enabled_by_default="true"> <inspection_tool class="unused" enabled="true" level="WARNING" enabled_by_default="true">

79
.idea/misc.xml Normal file
View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ClientPropertiesManager">
<properties class="javax.swing.AbstractButton">
<property name="hideActionText" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JComponent">
<property name="html.disable" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JEditorPane">
<property name="JEditorPane.w3cLengthUnits" class="java.lang.Boolean" />
<property name="JEditorPane.honorDisplayProperties" class="java.lang.Boolean" />
<property name="charset" class="java.lang.String" />
</properties>
<properties class="javax.swing.JList">
<property name="List.isFileList" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JPasswordField">
<property name="JPasswordField.cutCopyAllowed" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JSlider">
<property name="Slider.paintThumbArrowShape" class="java.lang.Boolean" />
<property name="JSlider.isFilled" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JTable">
<property name="Table.isFileList" class="java.lang.Boolean" />
<property name="JTable.autoStartsEdit" class="java.lang.Boolean" />
<property name="terminateEditOnFocusLost" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JToolBar">
<property name="JToolBar.isRollover" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JTree">
<property name="JTree.lineStyle" class="java.lang.String" />
</properties>
<properties class="javax.swing.text.JTextComponent">
<property name="caretAspectRatio" class="java.lang.Double" />
<property name="caretWidth" class="java.lang.Integer" />
</properties>
</component>
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="FrameworkDetectionExcludesConfiguration">
<file type="gwt" url="file://$PROJECT_DIR$/samples/benchmark" />
<file type="Osmorc" url="file://$PROJECT_DIR$/classlib" />
<file type="Osmorc" url="file://$PROJECT_DIR$/core" />
<file type="Osmorc" url="file://$PROJECT_DIR$/platform" />
<file type="Osmorc" url="file://$PROJECT_DIR$/tools/chrome-rdp" />
<file type="Osmorc" url="file://$PROJECT_DIR$/tools/core" />
<file type="web" url="file://$PROJECT_DIR$/samples/async" />
<file type="web" url="file://$PROJECT_DIR$/samples/benchmark" />
<file type="web" url="file://$PROJECT_DIR$/samples/hello" />
<file type="web" url="file://$PROJECT_DIR$/samples/kotlin" />
<file type="web" url="file://$PROJECT_DIR$/samples/scala" />
<file type="web" url="file://$PROJECT_DIR$/samples/storage" />
<file type="web" url="file://$PROJECT_DIR$/samples/video" />
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -10,6 +10,7 @@
<module fileurl="file://$PROJECT_DIR$/extras-slf4j/teavm-extras-slf4j.iml" filepath="$PROJECT_DIR$/extras-slf4j/teavm-extras-slf4j.iml" /> <module fileurl="file://$PROJECT_DIR$/extras-slf4j/teavm-extras-slf4j.iml" filepath="$PROJECT_DIR$/extras-slf4j/teavm-extras-slf4j.iml" />
<module fileurl="file://$PROJECT_DIR$/html4j/teavm-html4j.iml" filepath="$PROJECT_DIR$/html4j/teavm-html4j.iml" /> <module fileurl="file://$PROJECT_DIR$/html4j/teavm-html4j.iml" filepath="$PROJECT_DIR$/html4j/teavm-html4j.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/idea/teavm-idea-plugin.iml" filepath="$PROJECT_DIR$/tools/idea/teavm-idea-plugin.iml" /> <module fileurl="file://$PROJECT_DIR$/tools/idea/teavm-idea-plugin.iml" filepath="$PROJECT_DIR$/tools/idea/teavm-idea-plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/idea/jps-plugin/teavm-jps-plugin.iml" filepath="$PROJECT_DIR$/tools/idea/jps-plugin/teavm-jps-plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/jso/core/teavm-jso.iml" filepath="$PROJECT_DIR$/jso/core/teavm-jso.iml" /> <module fileurl="file://$PROJECT_DIR$/jso/core/teavm-jso.iml" filepath="$PROJECT_DIR$/jso/core/teavm-jso.iml" />
<module fileurl="file://$PROJECT_DIR$/jso/apis/teavm-jso-apis.iml" filepath="$PROJECT_DIR$/jso/apis/teavm-jso-apis.iml" /> <module fileurl="file://$PROJECT_DIR$/jso/apis/teavm-jso-apis.iml" filepath="$PROJECT_DIR$/jso/apis/teavm-jso-apis.iml" />
<module fileurl="file://$PROJECT_DIR$/jso/impl/teavm-jso-impl.iml" filepath="$PROJECT_DIR$/jso/impl/teavm-jso-impl.iml" /> <module fileurl="file://$PROJECT_DIR$/jso/impl/teavm-jso-impl.iml" filepath="$PROJECT_DIR$/jso/impl/teavm-jso-impl.iml" />

View File

@ -0,0 +1,93 @@
/*
* 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.jps;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
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;
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.library.JpsOrderRootType;
import org.jetbrains.jps.model.module.JpsDependencyElement;
import org.jetbrains.jps.model.module.JpsLibraryDependency;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.module.JpsModuleDependency;
import org.teavm.idea.jps.model.TeaVMJpsConfiguration;
public class TeaVMBuilder extends ModuleLevelBuilder {
public TeaVMBuilder() {
super(BuilderCategory.CLASS_POST_PROCESSOR);
}
@Override
public ExitCode build(CompileContext context, ModuleChunk chunk,
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder,
OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
for (JpsModule module : chunk.getModules()) {
buildModule(module);
}
return ExitCode.OK;
}
private void buildModule(JpsModule module) {
TeaVMJpsConfiguration config = TeaVMJpsConfiguration.get(module);
if (config == null || !config.isEnabled()) {
return;
}
Set<String> classPathEntries = new HashSet<>();
buildClassPath(module, new HashSet<>(), classPathEntries);
System.out.println(classPathEntries.stream().collect(Collectors.joining(":")));
}
private void buildClassPath(JpsModule module, Set<JpsModule> visited, Set<String> classPathEntries) {
if (!visited.add(module)) {
return;
}
File output = JpsJavaExtensionService.getInstance().getOutputDirectory(module, false);
if (output != null) {
classPathEntries.add(output.getPath());
}
for (JpsDependencyElement dependency : module.getDependenciesList().getDependencies()) {
if (dependency instanceof JpsModuleDependency) {
buildClassPath(((JpsModuleDependency) dependency).getModule(), visited, classPathEntries);
} else if (dependency instanceof JpsLibraryDependency) {
JpsLibrary library = ((JpsLibraryDependency) dependency).getLibrary();
if (library == null) {
continue;
}
classPathEntries.addAll(library.getFiles(JpsOrderRootType.COMPILED).stream().map(File::getPath)
.collect(Collectors.toList()));
}
}
}
@NotNull
@Override
public String getPresentableName() {
return "TeaVM builder";
}
}

View File

@ -13,30 +13,30 @@
* 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.
*/ */
package org.teavm.idea; package org.teavm.idea.jps;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull; 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.BuilderService;
import org.jetbrains.jps.incremental.ModuleLevelBuilder; import org.jetbrains.jps.incremental.ModuleLevelBuilder;
import org.jetbrains.jps.incremental.TargetBuilder;
public class TeaVMBuilderService extends BuilderService { public class TeaVMBuilderService extends BuilderService {
TeaVMBuilderService() { public TeaVMBuilderService() {
System.out.println("Hello"); System.out.println("Hello");
} }
@NotNull @NotNull
@Override @Override
public List<? extends BuildTargetType<?>> getTargetTypes() { public List<? extends ModuleLevelBuilder> createModuleLevelBuilders() {
return Arrays.asList(TeaVMBuildTargetType.INSTANCE); return Arrays.asList(new TeaVMBuilder());
} }
@NotNull @NotNull
@Override @Override
public List<? extends ModuleLevelBuilder> createModuleLevelBuilders() { public List<? extends TargetBuilder<?, ?>> createBuilders() {
return Arrays.asList(new TeaVMBuilder(BuilderCategory.CLASS_POST_PROCESSOR)); return Collections.emptyList();
} }
} }

View File

@ -0,0 +1,77 @@
/*
* 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.jps.model;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsElementChildRole;
import org.jetbrains.jps.model.ex.JpsElementBase;
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
import org.jetbrains.jps.model.module.JpsModule;
public class TeaVMJpsConfiguration extends JpsElementBase<TeaVMJpsConfiguration> {
public static final JpsElementChildRole<TeaVMJpsConfiguration> ROLE = JpsElementChildRoleBase.create(
"TeaVM configuration");
private boolean enabled;
private String mainClass;
private String targetDirectory;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getMainClass() {
return mainClass;
}
public void setMainClass(String mainClass) {
this.mainClass = mainClass;
}
public String getTargetDirectory() {
return targetDirectory;
}
public void setTargetDirectory(String targetDirectory) {
this.targetDirectory = targetDirectory;
}
public static TeaVMJpsConfiguration get(JpsModule module) {
return module.getContainer().getChild(ROLE);
}
public void setTo(JpsModule module) {
module.getContainer().setChild(ROLE, this);
}
@NotNull
@Override
public TeaVMJpsConfiguration createCopy() {
TeaVMJpsConfiguration copy = new TeaVMJpsConfiguration();
copy.applyChanges(this);
return copy;
}
@Override
public void applyChanges(@NotNull TeaVMJpsConfiguration modified) {
enabled = modified.enabled;
mainClass = modified.mainClass;
targetDirectory = modified.targetDirectory;
}
}

View File

@ -0,0 +1,38 @@
/*
* 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.jps.model;
import com.intellij.util.xmlb.XmlSerializer;
import java.util.Objects;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.module.JpsModule;
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension;
public class TeaVMModelSerializerService extends JpsModelSerializerExtension {
@Override
public void loadModuleOptions(@NotNull JpsModule module, @NotNull Element rootElement) {
rootElement.getChildren("component").stream()
.filter(child -> Objects.equals(child.getAttributeValue("name"), "teavm"))
.forEach(child -> readConfig(module, child));
}
private void readConfig(@NotNull JpsModule module, @NotNull Element element) {
TeaVMJpsConfiguration config = XmlSerializer.deserialize(element, TeaVMJpsConfiguration.class);
assert config != null;
config.setTo(module);
}
}

View File

@ -0,0 +1 @@
org.teavm.idea.jps.TeaVMBuilderService

View File

@ -0,0 +1 @@
org.teavm.idea.jps.model.TeaVMModelSerializerService

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="jdk" jdkName="IntelliJ IDEA IU-144.3600.7" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,87 +0,0 @@
/*
* 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<ArtifactRootDescriptor> {
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<BuildTarget<?>> computeDependencies(BuildTargetRegistry targetRegistry,
TargetOutputIndex outputIndex) {
return Collections.emptyList();
}
@NotNull
@Override
public List<ArtifactRootDescriptor> 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<File> getOutputRoots(CompileContext context) {
TeaVMModuleExtension extension = getModule().getContainer().getChild(TeaVMModuleExtension.ROLE);
if (extension == null) {
return Collections.emptyList();
}
return Arrays.asList(new File(extension.getTargetDirectory()));
}
}

View File

@ -1,52 +0,0 @@
/*
* 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<TeaVMBuildTarget> {
public static final TeaVMBuildTargetType INSTANCE = new TeaVMBuildTargetType("teavm");
public TeaVMBuildTargetType(String typeId) {
super(typeId);
}
@NotNull
@Override
public List<TeaVMBuildTarget> computeAllTargets(@NotNull JpsModel model) {
List<JpsModule> modules = model.getProject().getModules();
List<TeaVMBuildTarget> 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<TeaVMBuildTarget> createLoader(@NotNull JpsModel model) {
return null;
}
}

View File

@ -1,46 +0,0 @@
/*
* 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<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder,
OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
return ExitCode.OK;
}
@NotNull
@Override
public String getPresentableName() {
return "TeaVM builder";
}
}

View File

@ -1,63 +0,0 @@
/*
* 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<TeaVMModuleExtension> {
public static final JpsElementChildRole<TeaVMModuleExtension> 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);
}
}

View File

@ -58,15 +58,21 @@ class TeaVMConfigurationPanel extends JPanel {
constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.gridwidth = GridBagConstraints.REMAINDER;
add(enabledCheckBox, constraints); add(enabledCheckBox, constraints);
constraints.gridwidth = GridBagConstraints.RELATIVE; GridBagConstraints labelConstrains = new GridBagConstraints();
add(new JLabel("Main class:"), constraints); labelConstrains.gridwidth = GridBagConstraints.RELATIVE;
constraints.gridwidth = GridBagConstraints.REMAINDER; labelConstrains.anchor = GridBagConstraints.BASELINE_TRAILING;
add(mainClassField, constraints);
constraints.gridwidth = GridBagConstraints.RELATIVE; GridBagConstraints fieldConstrains = new GridBagConstraints();
add(new JLabel("Target directory:"), constraints); fieldConstrains.gridwidth = GridBagConstraints.REMAINDER;
constraints.gridwidth = GridBagConstraints.REMAINDER; fieldConstrains.fill = GridBagConstraints.HORIZONTAL;
add(targetDirectoryField, constraints); labelConstrains.anchor = GridBagConstraints.BASELINE_LEADING;
labelConstrains.insets.right = 5;
add(new JLabel("Main class:"), labelConstrains);
add(mainClassField, fieldConstrains);
add(new JLabel("Target directory:"), labelConstrains);
add(targetDirectoryField, fieldConstrains);
} }
public void load(TeaVMConfiguration config) { public void load(TeaVMConfiguration config) {

View File

@ -1,8 +1,8 @@
<idea-plugin version="2"> <idea-plugin version="2">
<id>com.your.company.unique.plugin.id</id> <id>org.teavm.idea</id>
<name>Plugin display name here</name> <name>TeaVM IDEA plugin</name>
<version>1.0</version> <version>1.0</version>
<vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor> <vendor email="info@teavm.org" url="http://teavm.org">TeaVM community</vendor>
<description><![CDATA[ <description><![CDATA[
Enter short description for your plugin here.<br> Enter short description for your plugin here.<br>
@ -21,11 +21,9 @@
<moduleConfigurable instance="org.teavm.idea.ui.TeaVMConfigurable"/> <moduleConfigurable instance="org.teavm.idea.ui.TeaVMConfigurable"/>
<moduleService serviceInterface="org.teavm.idea.TeaVMConfigurationStorage" <moduleService serviceInterface="org.teavm.idea.TeaVMConfigurationStorage"
serviceImplementation="org.teavm.idea.TeaVMConfigurationStorage"/> serviceImplementation="org.teavm.idea.TeaVMConfigurationStorage"/>
<compileServer.plugin classpath="jps-plugin/teavm-jps-plugin.jar"/>
</extensions> </extensions>
<actions>
</actions>
<module-components> <module-components>
<component> <component>
<implementation-class>org.teavm.idea.TeaVMConfigurationStorage</implementation-class> <implementation-class>org.teavm.idea.TeaVMConfigurationStorage</implementation-class>

View File

@ -1 +0,0 @@
org.teavm.idea.TeaVMBuilderService

View File

@ -1,13 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4"> <module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/src/main/resources/META-INF/plugin.xml" /> <component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/src/main/resources/META-INF/plugin.xml" />
<component name="NewModuleRootManager" inherit-compiler-output="true"> <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="jdk" jdkName="IntelliJ IDEA IU-144.3600.7" jdkType="IDEA JDK" /> <orderEntry type="jdk" jdkName="IntelliJ IDEA IU-144.3600.7" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="teavm-jps-plugin" exported="" scope="RUNTIME" />
</component> </component>
</module> </module>