Library kinds detectors for Java and JavaScript

This commit is contained in:
Nikolay Krasko
2013-02-19 19:15:40 +04:00
parent 688359de45
commit 057bdb7731
4 changed files with 113 additions and 2 deletions
+2
View File
@@ -216,6 +216,8 @@
<framework.type implementation="org.jetbrains.jet.plugin.framework.JetJavaFrameworkType"/>
<framework.type implementation="org.jetbrains.jet.plugin.framework.JavaScriptFrameworkType"/>
<library.presentationProvider implementation="org.jetbrains.jet.plugin.framework.KotlinJavaRuntimePresentationProvider"/>
<library.presentationProvider implementation="org.jetbrains.jet.plugin.framework.KotlinJavaScriptHeadersPresentationProvider"/>
<java.elementFinder implementation="org.jetbrains.jet.asJava.JavaElementFinder"/>
<java.shortNamesCache implementation="org.jetbrains.jet.plugin.caches.JetShortNamesCache"/>
@@ -36,7 +36,7 @@ import javax.swing.*;
import java.util.Set;
public class JetJavaRuntimeLibraryDescription extends CustomLibraryDescription {
public static final LibraryKind KOTLIN_KIND = LibraryKind.create("kotlin-java-runtime");
public static final LibraryKind KOTLIN_JAVA_RUNTIME_KIND = LibraryKind.create("kotlin-java-runtime");
private final FrameworkSourcePanel frameworkSourcePanel;
public JetJavaRuntimeLibraryDescription(FrameworkSourcePanel frameworkSourcePanel) {
@@ -47,7 +47,7 @@ public class JetJavaRuntimeLibraryDescription extends CustomLibraryDescription {
@NotNull
@Override
public Set<? extends LibraryKind> getSuitableLibraryKinds() {
return Sets.newHashSet(KOTLIN_KIND);
return Sets.newHashSet(KOTLIN_JAVA_RUNTIME_KIND);
}
@Nullable
@@ -0,0 +1,55 @@
/*
* 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.plugin.framework;
import com.intellij.framework.library.LibraryVersionProperties;
import com.intellij.openapi.roots.libraries.LibraryKind;
import com.intellij.openapi.roots.libraries.LibraryPresentationProvider;
import com.intellij.openapi.roots.libraries.LibraryProperties;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.plugin.JetIcons;
import org.jetbrains.jet.plugin.versions.KotlinRuntimeLibraryUtil;
import javax.swing.*;
import java.util.List;
public class KotlinJavaRuntimePresentationProvider extends LibraryPresentationProvider<LibraryVersionProperties> {
protected KotlinJavaRuntimePresentationProvider() {
super(JetJavaRuntimeLibraryDescription.KOTLIN_JAVA_RUNTIME_KIND);
}
@Nullable
@Override
public Icon getIcon() {
return JetIcons.SMALL_LOGO_13;
}
@Nullable
@Override
public LibraryVersionProperties detect(@NotNull List<VirtualFile> classesRoots) {
for (VirtualFile root : classesRoots) {
if (root.getName().equals(KotlinRuntimeLibraryUtil.KOTLIN_RUNTIME_JAR)) {
// TODO: Detect library version
return new LibraryVersionProperties("Unknown");
}
}
return null;
}
}
@@ -0,0 +1,54 @@
/*
* 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.plugin.framework;
import com.intellij.framework.library.LibraryVersionProperties;
import com.intellij.openapi.roots.libraries.LibraryPresentationProvider;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.plugin.JetIcons;
import org.jetbrains.jet.utils.PathUtil;
import javax.swing.*;
import java.util.List;
public class KotlinJavaScriptHeadersPresentationProvider extends LibraryPresentationProvider<LibraryVersionProperties> {
protected KotlinJavaScriptHeadersPresentationProvider() {
super(JetJavaScriptLibraryDescription.KOTLIN_JAVASCRIPT_HEADERS_KIND);
}
@Nullable
@Override
public Icon getIcon() {
return JetIcons.SMALL_LOGO_13;
}
@Nullable
@Override
public LibraryVersionProperties detect(@NotNull List<VirtualFile> classesRoots) {
for (VirtualFile root : classesRoots) {
// TODO: Better detection for headers library
if (root.getName().equals(PathUtil.JS_LIB_JS_NAME)) {
// TODO: Detect library version
return new LibraryVersionProperties("Unknown");
}
}
return null;
}
}