checkers, annotators and dependencies moved to idea-analysis module

This commit is contained in:
Alexey Kudravtsev
2014-08-13 13:27:04 +04:00
parent a83d9a7dce
commit eb5f1a9953
133 changed files with 929 additions and 631 deletions
+1
View File
@@ -23,6 +23,7 @@
<module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" group="compiler" /> <module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/ide-compiler-runner/ide-compiler-runner.iml" filepath="$PROJECT_DIR$/ide-compiler-runner/ide-compiler-runner.iml" group="ide" /> <module fileurl="file://$PROJECT_DIR$/ide-compiler-runner/ide-compiler-runner.iml" filepath="$PROJECT_DIR$/ide-compiler-runner/ide-compiler-runner.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/idea/idea.iml" filepath="$PROJECT_DIR$/idea/idea.iml" group="ide" /> <module fileurl="file://$PROJECT_DIR$/idea/idea.iml" filepath="$PROJECT_DIR$/idea/idea.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/idea/idea-analysis/idea-analysis.iml" filepath="$PROJECT_DIR$/idea/idea-analysis/idea-analysis.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/idea_runner/idea_runner.iml" filepath="$PROJECT_DIR$/idea_runner/idea_runner.iml" group="ide" /> <module fileurl="file://$PROJECT_DIR$/idea_runner/idea_runner.iml" filepath="$PROJECT_DIR$/idea_runner/idea_runner.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/injector-generator/injector-generator.iml" filepath="$PROJECT_DIR$/injector-generator/injector-generator.iml" group="infrastructure" /> <module fileurl="file://$PROJECT_DIR$/injector-generator/injector-generator.iml" filepath="$PROJECT_DIR$/injector-generator/injector-generator.iml" group="infrastructure" />
<module fileurl="file://$PROJECT_DIR$/compiler/preloader/instrumentation/instrumentation.iml" filepath="$PROJECT_DIR$/compiler/preloader/instrumentation/instrumentation.iml" group="compiler/cli" /> <module fileurl="file://$PROJECT_DIR$/compiler/preloader/instrumentation/instrumentation.iml" filepath="$PROJECT_DIR$/compiler/preloader/instrumentation/instrumentation.iml" group="compiler/cli" />
+49 -23
View File
@@ -656,31 +656,57 @@
</target> </target>
<target name="kotlin-for-upsource" depends="dist"> <target name="kotlin-for-upsource" depends="dist">
<jar jarfile="${output}/kotlin-for-upsource0.jar"> <cleandir dir="${output}/classes/idea-analysis"/>
<fileset dir="${output}/classes/compiler"/>
<fileset dir="${output}/classes/runtime"/>
<fileset dir="${output}/builtins">
<include name="kotlin/**"/>
<exclude name="kotlin/internal/**"/>
</fileset>
<fileset dir="${basedir}/compiler/frontend.java/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/compiler/backend/src" includes="META-INF/services/**"/>
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/> <javac2 destdir="${output}/classes/idea-analysis" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false" source="${java.target}" target="${java.target}">
<fileset dir="${output}/classes/stdlib"/> <withKotlin externalannotations="${external.annotations.path}"/>
<src >
<dirset dir="${basedir}/idea/idea-analysis">
<include name="src"/>
</dirset>
</src>
<classpath>
<fileset dir="${idea.sdk}" includes="core/*.jar"/>
<fileset dir="${idea.sdk}" includes="core-analysis/*.jar"/>
<fileset dir="${idea.sdk}" includes="lib/protobuf-2.5.0.jar"/>
<!-- icons, etc. --> <fileset dir="${basedir}/lib" includes="**/*.jar"/>
<fileset dir="idea/resources"/> <fileset dir="${dependencies.dir}" includes="jline.jar"/>
<!-- plugin.xml and friends --> <fileset dir="${dependencies.dir}" includes="jansi.jar"/>
<fileset dir="idea/src" includes="META-INF/**"/> <fileset dir="${dependencies.dir}" includes="cli-parser-1.1.1.jar"/>
</jar> <fileset dir="${basedir}/ideaSDK/jps" includes="jps-model.jar"/>
<sleep seconds="1"/> <pathelement location="${output}/classes/runtime"/>
<jar jarfile="${output}/kotlin-for-upsource.jar"> <pathelement location="${output}/classes/compiler"/>
<zipfileset src="${output}/kotlin-for-upsource0.jar"> <pathelement location="${output}/classes/stdlib"/>
<exclude name="javax/**/*.java"/> </classpath>
</zipfileset> </javac2>
</jar>
<delete file="${output}/kotlin-for-upsource0.jar"/> <jar jarfile="${output}/kotlin-for-upsource0.jar">
<fileset dir="${output}/classes/idea-analysis"/>
<fileset dir="${output}/classes/compiler"/>
<fileset dir="${output}/classes/runtime"/>
<fileset dir="${output}/builtins">
<include name="kotlin/**"/>
<exclude name="kotlin/internal/**"/>
</fileset>
<fileset dir="${basedir}/compiler/frontend.java/src" includes="META-INF/services/**"/>
<fileset dir="${basedir}/compiler/backend/src" includes="META-INF/services/**"/>
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
<fileset dir="${output}/classes/stdlib"/>
<!-- icons, etc. -->
<fileset dir="idea/resources"/>
<!-- plugin.xml and friends -->
<fileset dir="idea/src" includes="META-INF/**"/>
</jar>
<sleep seconds="1"/>
<jar jarfile="${output}/kotlin-for-upsource.jar">
<zipfileset src="${output}/kotlin-for-upsource0.jar">
<exclude name="javax/**/*.java"/>
</zipfileset>
</jar>
<delete file="${output}/kotlin-for-upsource0.jar"/>
</target> </target>
<target name="build-artifacts" depends="zip,kotlin-for-upsource"/> <target name="build-artifacts" depends="zip,kotlin-for-upsource"/>
@@ -0,0 +1,42 @@
/*
* Copyright 2010-2014 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;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class ProjectRootsUtil {
public static boolean isInSource(@NotNull PsiElement element) {
return isInSource(element, true);
}
public static boolean isInSource(@NotNull PsiElement element, boolean includeLibrarySources) {
PsiFile containingFile = element.getContainingFile();
if (containingFile == null) {
return false;
}
VirtualFile virtualFile = containingFile.getVirtualFile();
if (virtualFile == null) {
return false;
}
ProjectFileIndex index = ProjectFileIndex.SERVICE.getInstance(element.getProject());
return includeLibrarySources ? index.isInSource(virtualFile) : index.isInSourceContent(virtualFile);
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2010-2014 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.actions.internal
import com.intellij.ide.util.PropertiesComponent
public class KotlinInternalMode {
public class object {
val INTERNAL_MODE_PROPERTY = "kotlin.internal.mode.enabled"
public var enabled: Boolean
get() = PropertiesComponent.getInstance()!!.getBoolean(
INTERNAL_MODE_PROPERTY,
System.getProperty(INTERNAL_MODE_PROPERTY) == "true"
)
set(value) {
PropertiesComponent.getInstance()!!.setValue(INTERNAL_MODE_PROPERTY, value.toString())
}
}
}
@@ -142,4 +142,4 @@ class KotlinCacheService(val project: Project) {
public fun <T> get(extension: CacheExtension<T>): T { public fun <T> get(extension: CacheExtension<T>): T {
return globalCachesPerPlatform[extension.platform]!![extension] return globalCachesPerPlatform[extension.platform]!![extension]
} }
} }
@@ -17,11 +17,7 @@
package org.jetbrains.jet.plugin.caches.resolve package org.jetbrains.jet.plugin.caches.resolve
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.psi.util.PsiModificationTracker
import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.ReentrantLock
import com.intellij.psi.util.CachedValuesManager import com.intellij.psi.util.CachedValuesManager
import com.intellij.util.containers.SLRUCache
import com.intellij.psi.util.CachedValueProvider import com.intellij.psi.util.CachedValueProvider
class SynchronizedCachedValue<V>(project: Project, provider: () -> CachedValueProvider.Result<V>, trackValue: Boolean = true) { class SynchronizedCachedValue<V>(project: Project, provider: () -> CachedValueProvider.Result<V>, trackValue: Boolean = true) {
@@ -0,0 +1,37 @@
/*
* Copyright 2010-2014 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.configuration;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
public abstract class JetModuleTypeManager {
public static JetModuleTypeManager getInstance() {
return ServiceManager.getService(JetModuleTypeManager.class);
}
public abstract boolean isKtFileInGradleProjectInWrongFolder(@NotNull PsiElement element);
public abstract boolean isKtFileInGradleProjectInWrongFolder(@NotNull VirtualFile virtualFile, @NotNull Project project);
public abstract boolean isAndroidGradleModule(@NotNull Module module);
public boolean isGradleModule(@NotNull Module module) {
return ModuleTypeCacheManager.OBJECT$.geInstance(module.getProject()).isGradleModule(module);
}
}
@@ -22,13 +22,13 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.util.CachedValueProvider import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager import com.intellij.psi.util.CachedValuesManager
import com.intellij.openapi.util.DefaultModificationTracker
import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter
import com.intellij.openapi.vfs.VirtualFileAdapter import com.intellij.openapi.vfs.VirtualFileAdapter
import com.intellij.openapi.vfs.VirtualFileEvent import com.intellij.openapi.vfs.VirtualFileEvent
import com.intellij.openapi.vfs.VirtualFileMoveEvent import com.intellij.openapi.vfs.VirtualFileMoveEvent
import com.intellij.openapi.vfs.VirtualFileCopyEvent import com.intellij.openapi.vfs.VirtualFileCopyEvent
import com.intellij.openapi.vfs.VirtualFilePropertyEvent import com.intellij.openapi.vfs.VirtualFilePropertyEvent
import com.intellij.openapi.util.SimpleModificationTracker
class ModuleTypeCacheManager private (project: Project) { class ModuleTypeCacheManager private (project: Project) {
class object { class object {
@@ -50,7 +50,7 @@ class ModuleTypeCacheManager private (project: Project) {
return cachedValue?.getValue(module) return cachedValue?.getValue(module)
} }
private class VfsModificationTracker(project: Project): DefaultModificationTracker() { private class VfsModificationTracker(project: Project): SimpleModificationTracker() {
{ {
val connection = project.getMessageBus().connect(); val connection = project.getMessageBus().connect();
connection.subscribe(VirtualFileManager.VFS_CHANGES, BulkVirtualFileListenerAdapter( connection.subscribe(VirtualFileManager.VFS_CHANGES, BulkVirtualFileListenerAdapter(
@@ -0,0 +1,53 @@
/*
* Copyright 2010-2014 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.openapi.util.io.JarUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.utils.PathUtil;
import java.util.List;
import java.util.jar.Attributes;
public class JavaRuntimeDetectionUtil {
public static String getJavaRuntimeVersion(@NotNull List<VirtualFile> classesRoots) {
VirtualFile stdJar = getRuntimeJar(classesRoots);
if (stdJar != null) {
return JarUtil.getJarAttribute(VfsUtilCore.virtualToIoFile(stdJar), Attributes.Name.IMPLEMENTATION_VERSION);
}
return null;
}
@Nullable
public static VirtualFile getRuntimeJar(@NotNull List<VirtualFile> classesRoots) {
return getJarFile(classesRoots, PathUtil.KOTLIN_JAVA_RUNTIME_JAR);
}
static VirtualFile getJarFile(@NotNull List<VirtualFile> classesRoots, @NotNull String jarName) {
for (VirtualFile root : classesRoots) {
if (root.getName().equals(jarName)) {
return root;
}
}
return null;
}
}
@@ -0,0 +1,53 @@
/*
* Copyright 2010-2014 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.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.CommonProcessors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.plugin.JetFileType;
import java.util.List;
public class JsHeaderLibraryDetectionUtil {
public static boolean isJsHeaderLibraryDetected(@NotNull List<VirtualFile> classesRoots) {
if (JavaRuntimeDetectionUtil.getJavaRuntimeVersion(classesRoots) != null) {
// Prevent clashing with java runtime
return false;
}
for (VirtualFile file : classesRoots) {
CommonProcessors.FindFirstProcessor<VirtualFile> findKTProcessor = new CommonProcessors.FindFirstProcessor<VirtualFile>() {
@Override
protected boolean accept(VirtualFile file) {
String extension = file.getExtension();
return extension != null && extension.equals(JetFileType.INSTANCE.getDefaultExtension());
}
};
VfsUtilCore.processFilesRecursively(file, findKTProcessor);
if (findKTProcessor.isFound()) {
return true;
}
}
return false;
}
}
@@ -0,0 +1,46 @@
/*
* Copyright 2010-2014 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.openapi.util.io.JarUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.utils.PathUtil;
import java.util.List;
import java.util.jar.Attributes;
public class JsLibraryStdDetectionUtil {
public static String getJsLibraryStdVersion(@NotNull List<VirtualFile> classesRoots) {
if (JavaRuntimeDetectionUtil.getJavaRuntimeVersion(classesRoots) != null) {
// Prevent clashing with java runtime, in case when library collects all roots.
return null;
}
for (VirtualFile root : classesRoots) {
if (root.getName().equals(PathUtil.JS_LIB_JAR_NAME)) {
assert JsHeaderLibraryDetectionUtil.isJsHeaderLibraryDetected(classesRoots) : "StdLib should also be detected as headers library";
return JarUtil.getJarAttribute(VfsUtilCore.virtualToIoFile(root), Attributes.Name.IMPLEMENTATION_VERSION);
}
}
return null;
}
}
@@ -18,7 +18,6 @@ package org.jetbrains.jet.plugin.highlighter;
import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.lang.annotation.Annotator; import com.intellij.lang.annotation.Annotator;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -27,9 +26,10 @@ import org.jetbrains.jet.lang.psi.JetCodeFragment;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.psi.JetReferenceExpression;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.plugin.JetPluginUtil; import org.jetbrains.jet.plugin.ProjectRootsUtil;
import org.jetbrains.jet.plugin.actions.internal.KotlinInternalModeToggleAction; import org.jetbrains.jet.plugin.actions.internal.KotlinInternalMode;
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage; import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
import org.jetbrains.jet.plugin.configuration.JetModuleTypeManager;
/** /**
* Quick showing possible problems with Kotlin internals in IDEA with tooltips * Quick showing possible problems with Kotlin internals in IDEA with tooltips
@@ -37,14 +37,14 @@ import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
public class DebugInfoAnnotator implements Annotator { public class DebugInfoAnnotator implements Annotator {
public static boolean isDebugInfoEnabled() { public static boolean isDebugInfoEnabled() {
return KotlinInternalModeToggleAction.OBJECT$.getEnabled(); return KotlinInternalMode.OBJECT$.getEnabled();
} }
@Override @Override
public void annotate(@NotNull PsiElement element, @NotNull final AnnotationHolder holder) { public void annotate(@NotNull PsiElement element, @NotNull final AnnotationHolder holder) {
if (!isDebugInfoEnabled() || if (!isDebugInfoEnabled() ||
!JetPluginUtil.isInSource(element) || !ProjectRootsUtil.isInSource(element) ||
JetPluginUtil.isKtFileInGradleProjectInWrongFolder(element)) { JetModuleTypeManager.getInstance().isKtFileInGradleProjectInWrongFolder(element)) {
return; return;
} }
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.psi.JetDeclaration;
import org.jetbrains.jet.lang.psi.JetElement; import org.jetbrains.jet.lang.psi.JetElement;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.Diagnostics; import org.jetbrains.jet.lang.resolve.Diagnostics;
import org.jetbrains.jet.plugin.JetPluginUtil; import org.jetbrains.jet.plugin.ProjectRootsUtil;
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage; import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
import org.jetbrains.jet.plugin.project.TargetPlatform; import org.jetbrains.jet.plugin.project.TargetPlatform;
import org.jetbrains.jet.plugin.project.TargetPlatformDetector; import org.jetbrains.jet.plugin.project.TargetPlatformDetector;
@@ -36,7 +36,7 @@ public class DuplicateJvmSignatureAnnotator implements Annotator {
@Override @Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (!(element instanceof JetFile) && !(element instanceof JetDeclaration)) return; if (!(element instanceof JetFile) && !(element instanceof JetDeclaration)) return;
if (!JetPluginUtil.isInSource(element, false)) return; if (!ProjectRootsUtil.isInSource(element, false)) return;
PsiFile file = element.getContainingFile(); PsiFile file = element.getContainingFile();
if (!(file instanceof JetFile) || TargetPlatformDetector.getPlatform((JetFile) file) != TargetPlatform.JVM) return; if (!(file instanceof JetFile) || TargetPlatformDetector.getPlatform((JetFile) file) != TargetPlatform.JVM) return;
@@ -45,9 +45,10 @@ import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.psi.JetReferenceExpression;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.Diagnostics; import org.jetbrains.jet.lang.resolve.Diagnostics;
import org.jetbrains.jet.plugin.JetPluginUtil; import org.jetbrains.jet.plugin.ProjectRootsUtil;
import org.jetbrains.jet.plugin.actions.internal.KotlinInternalModeToggleAction; import org.jetbrains.jet.plugin.actions.internal.KotlinInternalMode;
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage; import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
import org.jetbrains.jet.plugin.configuration.JetModuleTypeManager;
import org.jetbrains.jet.plugin.quickfix.JetIntentionActionsFactory; import org.jetbrains.jet.plugin.quickfix.JetIntentionActionsFactory;
import org.jetbrains.jet.plugin.quickfix.QuickFixes; import org.jetbrains.jet.plugin.quickfix.QuickFixes;
@@ -93,8 +94,8 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
@Override @Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (!(JetPluginUtil.isInSource(element) || element.getContainingFile() instanceof JetCodeFragment) if (!(ProjectRootsUtil.isInSource(element) || element.getContainingFile() instanceof JetCodeFragment)
|| JetPluginUtil.isKtFileInGradleProjectInWrongFolder(element)) { || JetModuleTypeManager.getInstance().isKtFileInGradleProjectInWrongFolder(element)) {
return; return;
} }
@@ -106,8 +107,6 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
AnalyzeExhaust analyzeExhaust = ResolvePackage.getAnalysisResults(file); AnalyzeExhaust analyzeExhaust = ResolvePackage.getAnalysisResults(file);
if (analyzeExhaust.isError()) { if (analyzeExhaust.isError()) {
HighlighterPackage.updateHighlightingResult(file, true);
throw new ProcessCanceledException(analyzeExhaust.getError()); throw new ProcessCanceledException(analyzeExhaust.getError());
} }
@@ -118,15 +117,10 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
} }
annotateElement(element, holder, bindingContext.getDiagnostics()); annotateElement(element, holder, bindingContext.getDiagnostics());
if (element instanceof JetFile) {
//noinspection StaticMethodReferencedViaSubclass
HighlighterPackage.updateHighlightingResult(file, false);
}
} }
public static void annotateElement(PsiElement element, AnnotationHolder holder, Diagnostics diagnostics) { public static void annotateElement(PsiElement element, AnnotationHolder holder, Diagnostics diagnostics) {
if (JetPluginUtil.isInSource(element, /* includeLibrarySources = */ false) || element.getContainingFile() instanceof JetCodeFragment) { if (ProjectRootsUtil.isInSource(element, /* includeLibrarySources = */ false) || element.getContainingFile() instanceof JetCodeFragment) {
ElementAnnotator elementAnnotator = new ElementAnnotator(element, holder); ElementAnnotator elementAnnotator = new ElementAnnotator(element, holder);
for (Diagnostic diagnostic : diagnostics.forElement(element)) { for (Diagnostic diagnostic : diagnostics.forElement(element)) {
elementAnnotator.registerDiagnosticAnnotations(diagnostic); elementAnnotator.registerDiagnosticAnnotations(diagnostic);
@@ -264,7 +258,7 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
@NotNull @NotNull
private static String getMessage(@NotNull Diagnostic diagnostic) { private static String getMessage(@NotNull Diagnostic diagnostic) {
String message = IdeErrorMessages.RENDERER.render(diagnostic); String message = IdeErrorMessages.RENDERER.render(diagnostic);
if (KotlinInternalModeToggleAction.OBJECT$.getEnabled() || ApplicationManager.getApplication().isUnitTestMode()) { if (KotlinInternalMode.OBJECT$.getEnabled() || ApplicationManager.getApplication().isUnitTestMode()) {
String factoryName = diagnostic.getFactory().getName(); String factoryName = diagnostic.getFactory().getName();
if (message.startsWith("<html>")) { if (message.startsWith("<html>")) {
message = String.format("<html>[%s] %s", factoryName, message.substring("<html>".length())); message = String.format("<html>[%s] %s", factoryName, message.substring("<html>".length()));
@@ -281,7 +275,7 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
@NotNull @NotNull
private static String getDefaultMessage(@NotNull Diagnostic diagnostic) { private static String getDefaultMessage(@NotNull Diagnostic diagnostic) {
String message = DefaultErrorMessages.RENDERER.render(diagnostic); String message = DefaultErrorMessages.RENDERER.render(diagnostic);
if (KotlinInternalModeToggleAction.OBJECT$.getEnabled() || ApplicationManager.getApplication().isUnitTestMode()) { if (KotlinInternalMode.OBJECT$.getEnabled() || ApplicationManager.getApplication().isUnitTestMode()) {
return String.format("[%s] %s", diagnostic.getFactory().getName(), message); return String.format("[%s] %s", diagnostic.getFactory().getName(), message);
} }
return message; return message;
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2014 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@ package org.jetbrains.jet.plugin.highlighter
import com.intellij.codeInsight.daemon.ProblemHighlightFilter import com.intellij.codeInsight.daemon.ProblemHighlightFilter
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
import com.intellij.ide.projectView.impl.ProjectRootsUtil
import org.jetbrains.jet.plugin.JetFileType import org.jetbrains.jet.plugin.JetFileType
import com.intellij.ide.projectView.impl.ProjectRootsUtil
class KotlinProblemHighlightFilter : ProblemHighlightFilter() { class KotlinProblemHighlightFilter : ProblemHighlightFilter() {
@@ -19,7 +19,9 @@ package org.jetbrains.jet.plugin.highlighter;
import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
import org.jetbrains.jet.lang.psi.JetParameter; import org.jetbrains.jet.lang.psi.JetParameter;
import org.jetbrains.jet.lang.psi.JetProperty; import org.jetbrains.jet.lang.psi.JetProperty;
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
@@ -24,7 +24,8 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.source.tree.LeafPsiElement; import com.intellij.psi.impl.source.tree.LeafPsiElement;
import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.JetFunctionLiteral;
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression;
import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.lexer.JetTokens;
class SoftKeywordsHighlightingVisitor extends HighlightingVisitor { class SoftKeywordsHighlightingVisitor extends HighlightingVisitor {
@@ -19,7 +19,9 @@ package org.jetbrains.jet.plugin.highlighter;
import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.LocalVariableDescriptor; import org.jetbrains.jet.lang.descriptors.impl.LocalVariableDescriptor;
import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -19,9 +19,9 @@ package org.jetbrains.jet.plugin.inspections
import com.intellij.codeInspection.LocalInspectionTool import com.intellij.codeInspection.LocalInspectionTool
import com.intellij.codeInspection.CustomSuppressableInspectionTool import com.intellij.codeInspection.CustomSuppressableInspectionTool
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.codeInsight.daemon.HighlightDisplayKey
import com.intellij.codeInspection.SuppressIntentionAction import com.intellij.codeInspection.SuppressIntentionAction
import com.intellij.codeInspection.SuppressManager import com.intellij.codeInspection.SuppressManager
import com.intellij.codeInsight.daemon.HighlightDisplayKey
public abstract class AbstractKotlinInspection: LocalInspectionTool(), CustomSuppressableInspectionTool { public abstract class AbstractKotlinInspection: LocalInspectionTool(), CustomSuppressableInspectionTool {
public override fun getSuppressActions(element: PsiElement?): Array<SuppressIntentionAction>? { public override fun getSuppressActions(element: PsiElement?): Array<SuppressIntentionAction>? {
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2014 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -16,18 +16,20 @@
package org.jetbrains.jet.plugin.intentions package org.jetbrains.jet.plugin.intentions
import com.intellij.codeInsight.intention.impl.BaseIntentionAction
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
import org.jetbrains.jet.lang.psi.JetElement import org.jetbrains.jet.lang.psi.JetElement
import org.jetbrains.jet.plugin.JetBundle import org.jetbrains.jet.plugin.JetBundle
import org.jetbrains.jet.lang.psi.psiUtil.getParentByTypesAndPredicate import org.jetbrains.jet.lang.psi.psiUtil.getParentByTypesAndPredicate
import com.intellij.codeInsight.intention.IntentionAction
public abstract class JetSelfTargetingIntention<T: JetElement>(val key: String, val elementType: Class<T>) : BaseIntentionAction() { public abstract class JetSelfTargetingIntention<T: JetElement>(val key: String, val elementType: Class<T>) : IntentionAction {
{ private var myText:String = JetBundle.message(key);
setText(JetBundle.message(key)) protected fun setText(text: String) {
myText = text
} }
override fun getText(): String = myText
abstract fun isApplicableTo(element: T): Boolean abstract fun isApplicableTo(element: T): Boolean
open fun isApplicableTo(element: T, editor: Editor): Boolean = isApplicableTo(element) open fun isApplicableTo(element: T, editor: Editor): Boolean = isApplicableTo(element)
@@ -52,4 +54,8 @@ public abstract class JetSelfTargetingIntention<T: JetElement>(val key: String,
applyTo(target!!, editor) applyTo(target!!, editor)
} }
}
override fun startInWriteAction(): Boolean = true
override fun toString(): String = getText()
}
@@ -1,18 +1,18 @@
/* /*
* Copyright 2010-2014 JetBrains s.r.o. * Copyright 2010-2014 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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.jetbrains.jet.plugin.intentions package org.jetbrains.jet.plugin.intentions
@@ -31,7 +31,6 @@ import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
import org.jetbrains.jet.lang.resolve.BindingContext import org.jetbrains.jet.lang.resolve.BindingContext
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpression>("operator.to.function", javaClass()) { public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpression>("operator.to.function", javaClass()) {
class object { class object {
@@ -29,7 +29,6 @@ import java.util.*
import org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumEntry import org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumEntry
import org.jetbrains.jet.lang.resolve.DescriptorUtils.isSyntheticClassObject import org.jetbrains.jet.lang.resolve.DescriptorUtils.isSyntheticClassObject
import org.jetbrains.jet.lang.types.error.MissingDependencyErrorClass import org.jetbrains.jet.lang.types.error.MissingDependencyErrorClass
import org.jetbrains.jet.lang.resolve.DescriptorResolver
import org.jetbrains.jet.lang.resolve.name.isComponentFunctionName import org.jetbrains.jet.lang.resolve.name.isComponentFunctionName
public fun buildDecompiledText( public fun buildDecompiledText(
@@ -16,17 +16,14 @@
package org.jetbrains.jet.plugin.libraries package org.jetbrains.jet.plugin.libraries
import com.intellij.openapi.fileTypes.StdFileTypes
import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.jet.lang.resolve.kotlin.KotlinBinaryClassCache import org.jetbrains.jet.lang.resolve.kotlin.KotlinBinaryClassCache
import org.jetbrains.jet.lang.resolve.kotlin.header.KotlinClassHeader import org.jetbrains.jet.lang.resolve.kotlin.header.KotlinClassHeader
import com.intellij.psi.ClassFileViewProvider import com.intellij.psi.ClassFileViewProvider
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass
import com.intellij.ide.highlighter.JavaClassFileType
public fun isKotlinCompiledFile(file: VirtualFile): Boolean { public fun isKotlinCompiledFile(file: VirtualFile): Boolean {
if (file.getExtension() != StdFileTypes.CLASS.getDefaultExtension()) {
return false
}
if (isKotlinCompiledFileWithIncompatibleAbiVersion(file)) { if (isKotlinCompiledFileWithIncompatibleAbiVersion(file)) {
return false return false
} }
@@ -35,7 +32,7 @@ public fun isKotlinCompiledFile(file: VirtualFile): Boolean {
} }
public fun isKotlinCompiledFileWithIncompatibleAbiVersion(file: VirtualFile): Boolean { public fun isKotlinCompiledFileWithIncompatibleAbiVersion(file: VirtualFile): Boolean {
if (file.getExtension() != StdFileTypes.CLASS.getDefaultExtension()) { if (file.getExtension() != JavaClassFileType.INSTANCE!!.getDefaultExtension()) {
return false return false
} }
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.getClassHeader() val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.getClassHeader()
@@ -49,4 +49,4 @@ public class JetClassFileViewProvider(
override fun createCopy(copy: VirtualFile): SingleRootFileViewProvider { override fun createCopy(copy: VirtualFile): SingleRootFileViewProvider {
return JetClassFileViewProvider(getManager(), copy, false, isInternal) return JetClassFileViewProvider(getManager(), copy, false, isInternal)
} }
} }
@@ -19,13 +19,10 @@ package org.jetbrains.jet.plugin.libraries
import com.intellij.openapi.util.TextRange import com.intellij.openapi.util.TextRange
import com.intellij.psi.impl.compiled.ClsFileImpl import com.intellij.psi.impl.compiled.ClsFileImpl
import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.annotations.Nullable
import org.jetbrains.annotations.TestOnly import org.jetbrains.annotations.TestOnly
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
import org.jetbrains.jet.lang.psi.JetDeclaration import org.jetbrains.jet.lang.psi.JetDeclaration
import org.jetbrains.jet.lang.psi.JetFile
import kotlin.properties.Delegates import kotlin.properties.Delegates
import com.intellij.psi.PsiFile
public class JetClsFile(val provider: JetClassFileViewProvider) : ClsFileImpl(provider) { public class JetClsFile(val provider: JetClassFileViewProvider) : ClsFileImpl(provider) {
@@ -26,4 +26,4 @@ public class JetDecompilerForWrongAbiVersion : ClassFileDecompilers.Light() {
override fun getText(file: VirtualFile) = "$INCOMPATIBLE_ABI_VERSION_COMMENT\n${ClsFileImpl.decompile(file)}" override fun getText(file: VirtualFile) = "$INCOMPATIBLE_ABI_VERSION_COMMENT\n${ClsFileImpl.decompile(file)}"
} }
val INCOMPATIBLE_ABI_VERSION_COMMENT = " // This Kotlin file has an incompatible ABI version and is displayed as Java class" val INCOMPATIBLE_ABI_VERSION_COMMENT = " // This Kotlin file has an incompatible ABI version and is displayed as Java class"
@@ -16,9 +16,9 @@
package org.jetbrains.jet.plugin.libraries package org.jetbrains.jet.plugin.libraries
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
import org.jetbrains.jet.lang.resolve.name.FqName import org.jetbrains.jet.lang.resolve.name.FqName
import org.jetbrains.jet.lang.descriptors.ClassDescriptor import org.jetbrains.jet.lang.descriptors.ClassDescriptor
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
trait ResolverForDecompiler { trait ResolverForDecompiler {
fun resolveTopLevelClass(classFqName: FqName): ClassDescriptor? fun resolveTopLevelClass(classFqName: FqName): ClassDescriptor?
@@ -25,4 +25,4 @@ public final class IDEAConfig extends LibrarySourcesConfig {
public IDEAConfig(@NotNull Project project) { public IDEAConfig(@NotNull Project project) {
super(project, "default", ProjectStructureUtil.getLibLocationForProject(project), EcmaVersion.defaultVersion(), false); super(project, "default", ProjectStructureUtil.getLibLocationForProject(project), EcmaVersion.defaultVersion(), false);
} }
} }
@@ -31,6 +31,7 @@ import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.search.FileTypeIndex;
import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.CachedValue; import com.intellij.psi.util.CachedValue;
import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValueProvider;
@@ -40,16 +41,12 @@ import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.plugin.configuration.ConfigureKotlinInProjectUtils; import org.jetbrains.jet.plugin.JetFileType;
import org.jetbrains.jet.plugin.framework.JSLibraryStdPresentationProvider; import org.jetbrains.jet.plugin.framework.JsHeaderLibraryDetectionUtil;
import org.jetbrains.jet.plugin.framework.JsHeaderLibraryPresentationProvider; import org.jetbrains.jet.plugin.framework.JsLibraryStdDetectionUtil;
import org.jetbrains.jet.plugin.framework.LibraryPresentationProviderUtil; import org.jetbrains.jet.plugin.versions.KotlinRuntimeLibraryCoreUtil;
import org.jetbrains.jet.plugin.versions.KotlinRuntimeLibraryUtil;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ProjectStructureUtil { public class ProjectStructureUtil {
private static final Key<CachedValue<Boolean>> IS_KOTLIN_JS_MODULE = Key.create("IS_KOTLIN_JS_MODULE"); private static final Key<CachedValue<Boolean>> IS_KOTLIN_JS_MODULE = Key.create("IS_KOTLIN_JS_MODULE");
@@ -66,8 +63,8 @@ public class ProjectStructureUtil {
public static boolean isJavaKotlinModule(@NotNull Module module) { public static boolean isJavaKotlinModule(@NotNull Module module) {
GlobalSearchScope scope = module.getModuleWithDependenciesAndLibrariesScope( GlobalSearchScope scope = module.getModuleWithDependenciesAndLibrariesScope(
ConfigureKotlinInProjectUtils.hasKotlinFilesOnlyInTests(module)); hasKotlinFilesOnlyInTests(module));
return KotlinRuntimeLibraryUtil.getKotlinRuntimeMarkerClass(scope) != null; return KotlinRuntimeLibraryCoreUtil.getKotlinRuntimeMarkerClass(scope) != null;
} }
public static boolean isJsKotlinModule(@NotNull final Module module) { public static boolean isJsKotlinModule(@NotNull final Module module) {
@@ -162,7 +159,10 @@ public class ProjectStructureUtil {
ModuleRootManager.getInstance(module).orderEntries().librariesOnly().forEachLibrary(new Processor<Library>() { ModuleRootManager.getInstance(module).orderEntries().librariesOnly().forEachLibrary(new Processor<Library>() {
@Override @Override
public boolean process(Library library) { public boolean process(Library library) {
if (LibraryPresentationProviderUtil.isDetected(JsHeaderLibraryPresentationProvider.getInstance(), library)) { boolean detected = JsHeaderLibraryDetectionUtil.isJsHeaderLibraryDetected(Arrays.asList(
library.getFiles(OrderRootType.CLASSES)));
if (detected) {
for (VirtualFile file : library.getRootProvider().getFiles(OrderRootType.SOURCES)) { for (VirtualFile file : library.getRootProvider().getFiles(OrderRootType.SOURCES)) {
String path = PathUtil.getLocalPath(PathUtil.getLocalFile(file)); String path = PathUtil.getLocalPath(PathUtil.getLocalFile(file));
if (path != null) { if (path != null) {
@@ -193,7 +193,11 @@ public class ProjectStructureUtil {
ModuleRootManager.getInstance(module).orderEntries().librariesOnly().forEachLibrary(new Processor<Library>() { ModuleRootManager.getInstance(module).orderEntries().librariesOnly().forEachLibrary(new Processor<Library>() {
@Override @Override
public boolean process(Library library) { public boolean process(Library library) {
if (LibraryPresentationProviderUtil.isDetected(JSLibraryStdPresentationProvider.getInstance(), library)) { List<VirtualFile> classes = Arrays.asList(library.getFiles(OrderRootType.CLASSES));
boolean detected = JsLibraryStdDetectionUtil.getJsLibraryStdVersion(classes) != null;
if (detected) {
jsLibrary.set(library); jsLibrary.set(library);
return false; return false;
} }
@@ -206,4 +210,12 @@ public class ProjectStructureUtil {
} }
}); });
} }
public static boolean hasKotlinFilesInSources(@NotNull Module module) {
return FileTypeIndex.containsFileOfType(JetFileType.INSTANCE, module.getModuleScope(false));
}
public static boolean hasKotlinFilesOnlyInTests(@NotNull Module module) {
return !hasKotlinFilesInSources(module) && FileTypeIndex.containsFileOfType(JetFileType.INSTANCE, module.getModuleScope(true));
}
} }
@@ -549,4 +549,4 @@ public class ResolveElementCache {
return true; return true;
} }
} }
} }
@@ -159,4 +159,4 @@ private class CaretBox<out E: JetExpression>(
if (editor == null) return if (editor == null) return
editor.getCaretModel().moveToOffset(copy.getTextOffset() + offsetInExpression) editor.getCaretModel().moveToOffset(copy.getTextOffset() + offsetInExpression)
} }
} }
@@ -0,0 +1,40 @@
/*
* Copyright 2010-2014 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.quickfix;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.intellij.codeInsight.intention.IntentionAction;
import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
import java.util.Collection;
public class QuickFixes {
static final Multimap<DiagnosticFactory<?>, JetIntentionActionsFactory> factories = HashMultimap.create();
static final Multimap<DiagnosticFactory<?>, IntentionAction> actions = HashMultimap.create();
public static Collection<JetIntentionActionsFactory> getActionsFactories(DiagnosticFactory<?> diagnosticFactory) {
return factories.get(diagnosticFactory);
}
public static Collection<IntentionAction> getActions(DiagnosticFactory<?> diagnosticFactory) {
return actions.get(diagnosticFactory);
}
private QuickFixes() {}
}
@@ -22,14 +22,15 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.AbstractProjectComponent; import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.newvfs.NewVirtualFile; import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager; import com.intellij.psi.PsiManager;
import com.intellij.util.Function; import com.intellij.util.Function;
import com.intellij.util.PathUtil;
import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -153,16 +154,14 @@ public class BuiltInsReferenceResolver extends AbstractProjectComponent {
@NotNull @NotNull
private Set<JetFile> getBuiltInSourceFiles(@NotNull URL url) { private Set<JetFile> getBuiltInSourceFiles(@NotNull URL url) {
VirtualFile vf = VfsUtil.findFileByURL(url); String fromUrl = VfsUtilCore.convertFromUrl(url);
VirtualFile vf = VirtualFileManager.getInstance().findFileByUrl(fromUrl);
assert vf != null : "Virtual file not found by URL: " + url; assert vf != null : "Virtual file not found by URL: " + url;
// Refreshing VFS: in case the plugin jar was updated, the caches may hold the old value // Refreshing VFS: in case the plugin jar was updated, the caches may hold the old value
if (vf instanceof NewVirtualFile) {
NewVirtualFile newVirtualFile = (NewVirtualFile) vf;
newVirtualFile.markDirtyRecursively(); // This doesn't happen in a JARFS entry, unless we do it manually here
}
vf.getChildren(); vf.getChildren();
vf.refresh(false, true); vf.refresh(false, true);
PathUtil.getLocalFile(vf).refresh(false, true);
PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(vf); PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(vf);
assert psiDirectory != null : "No PsiDirectory for " + vf; assert psiDirectory != null : "No PsiDirectory for " + vf;
@@ -19,18 +19,13 @@ package org.jetbrains.jet.plugin.references
import com.intellij.psi.PsiReference import com.intellij.psi.PsiReference
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.jet.asJava.unwrapped import org.jetbrains.jet.asJava.unwrapped
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
import org.jetbrains.jet.lang.resolve.BindingContext
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
import com.intellij.psi.PsiMethod import com.intellij.psi.PsiMethod
import org.jetbrains.jet.lang.psi.JetPropertyAccessor import org.jetbrains.jet.lang.psi.JetPropertyAccessor
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
import org.jetbrains.jet.lang.psi.JetProperty import org.jetbrains.jet.lang.psi.JetProperty
import java.util.HashSet import java.util.HashSet
import com.intellij.util.containers.ContainerUtil import com.intellij.util.containers.ContainerUtil
import org.jetbrains.jet.lang.psi.JetNamedDeclaration
import org.jetbrains.jet.lang.psi.JetExpression import org.jetbrains.jet.lang.psi.JetExpression
import org.jetbrains.jet.lang.psi.JetElement
import org.jetbrains.jet.plugin.intentions.OperatorToFunctionIntention import org.jetbrains.jet.plugin.intentions.OperatorToFunctionIntention
import org.jetbrains.jet.lang.psi.JetQualifiedExpression import org.jetbrains.jet.lang.psi.JetQualifiedExpression
import org.jetbrains.jet.lang.psi.JetCallExpression import org.jetbrains.jet.lang.psi.JetCallExpression
@@ -30,4 +30,4 @@ fun Project.allScope(): GlobalSearchScope = GlobalSearchScope.allScope(this)
fun Project.projectScope(): GlobalSearchScope = GlobalSearchScope.projectScope(this) fun Project.projectScope(): GlobalSearchScope = GlobalSearchScope.projectScope(this)
fun PsiFile.fileScope(): GlobalSearchScope = GlobalSearchScope.fileScope(this) fun PsiFile.fileScope(): GlobalSearchScope = GlobalSearchScope.fileScope(this)
@@ -46,4 +46,4 @@ public class JetPropertyShortNameIndex extends StringStubIndexExtension<JetPrope
public Collection<JetProperty> get(String s, Project project, @NotNull GlobalSearchScope scope) { public Collection<JetProperty> get(String s, Project project, @NotNull GlobalSearchScope scope) {
return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project)); return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project));
} }
} }
@@ -16,7 +16,7 @@
package org.jetbrains.jet.plugin.stubindex; package org.jetbrains.jet.plugin.stubindex;
import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.ide.highlighter.JavaClassFileType;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.roots.ProjectRootManager;
@@ -25,7 +25,7 @@ import com.intellij.psi.search.DelegatingGlobalSearchScope;
import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.plugin.JetFileType; import org.jetbrains.jet.plugin.JetFileType;
import org.jetbrains.jet.plugin.JetPluginUtil; import org.jetbrains.jet.plugin.configuration.JetModuleTypeManager;
public class JetSourceFilterScope extends DelegatingGlobalSearchScope { public class JetSourceFilterScope extends DelegatingGlobalSearchScope {
@NotNull @NotNull
@@ -55,11 +55,11 @@ public class JetSourceFilterScope extends DelegatingGlobalSearchScope {
return false; return false;
} }
if (includeLibraries && StdFileTypes.CLASS == file.getFileType()) { if (includeLibraries && JavaClassFileType.INSTANCE == file.getFileType()) {
return index.isInLibraryClasses(file); return index.isInLibraryClasses(file);
} }
if (JetPluginUtil.isKtFileInGradleProjectInWrongFolder(file, project)) { if (JetModuleTypeManager.getInstance().isKtFileInGradleProjectInWrongFolder(file, getProject())) {
return false; return false;
} }
@@ -18,14 +18,12 @@ package org.jetbrains.jet.plugin.stubindex.resolve
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.annotations.Nullable
import org.jetbrains.jet.lang.psi.JetFile import org.jetbrains.jet.lang.psi.JetFile
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassLikeInfo import org.jetbrains.jet.lang.resolve.lazy.data.JetClassLikeInfo
import org.jetbrains.jet.lang.resolve.lazy.declarations.* import org.jetbrains.jet.lang.resolve.lazy.declarations.*
import org.jetbrains.jet.lang.resolve.name.FqName import org.jetbrains.jet.lang.resolve.name.FqName
import org.jetbrains.jet.plugin.stubindex.JetAllPackagesIndex import org.jetbrains.jet.plugin.stubindex.JetAllPackagesIndex
import org.jetbrains.jet.storage.StorageManager import org.jetbrains.jet.storage.StorageManager
import java.util.Arrays
public class PluginDeclarationProviderFactory( public class PluginDeclarationProviderFactory(
private val project: Project, private val project: Project,
@@ -35,4 +35,4 @@ public class PluginDeclarationProviderFactoryService : DeclarationProviderFactor
return PluginDeclarationProviderFactory(project, JetSourceFilterScope.kotlinSources(filesScope, project), return PluginDeclarationProviderFactory(project, JetSourceFilterScope.kotlinSources(filesScope, project),
storageManager, syntheticFiles) storageManager, syntheticFiles)
} }
} }
@@ -75,4 +75,4 @@ private val TOP_LEVEL_DECLARATION_INDICES: List<StringStubIndexExtension<out Jet
JetFullClassNameIndex.getInstance(), JetFullClassNameIndex.getInstance(),
JetTopLevelFunctionsFqnNameIndex.getInstance(), JetTopLevelFunctionsFqnNameIndex.getInstance(),
JetTopLevelPropertiesFqnNameIndex.getInstance() JetTopLevelPropertiesFqnNameIndex.getInstance()
) )
@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2013 JetBrains s.r.o. * Copyright 2010-2014 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ import org.jetbrains.jet.lang.parsing.JetExpressionParsing
import java.util.HashMap import java.util.HashMap
import org.jetbrains.jet.lang.parsing.JetExpressionParsing.Precedence.* import org.jetbrains.jet.lang.parsing.JetExpressionParsing.Precedence.*
import org.jetbrains.jet.lang.psi.* import org.jetbrains.jet.lang.psi.*
import org.jetbrains.jet.utils.*
public object JetPsiPrecedences { public object JetPsiPrecedences {

Some files were not shown because too many files have changed in this diff Show More