checkers, annotators and dependencies moved to idea-analysis module
This commit is contained in:
Generated
+1
@@ -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$/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-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$/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" />
|
||||
|
||||
@@ -656,31 +656,57 @@
|
||||
</target>
|
||||
|
||||
<target name="kotlin-for-upsource" depends="dist">
|
||||
<jar jarfile="${output}/kotlin-for-upsource0.jar">
|
||||
<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/**"/>
|
||||
<cleandir dir="${output}/classes/idea-analysis"/>
|
||||
|
||||
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
|
||||
<fileset dir="${output}/classes/stdlib"/>
|
||||
<javac2 destdir="${output}/classes/idea-analysis" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false" source="${java.target}" target="${java.target}">
|
||||
<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="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"/>
|
||||
<fileset dir="${basedir}/lib" includes="**/*.jar"/>
|
||||
<fileset dir="${dependencies.dir}" includes="jline.jar"/>
|
||||
<fileset dir="${dependencies.dir}" includes="jansi.jar"/>
|
||||
<fileset dir="${dependencies.dir}" includes="cli-parser-1.1.1.jar"/>
|
||||
<fileset dir="${basedir}/ideaSDK/jps" includes="jps-model.jar"/>
|
||||
<pathelement location="${output}/classes/runtime"/>
|
||||
<pathelement location="${output}/classes/compiler"/>
|
||||
<pathelement location="${output}/classes/stdlib"/>
|
||||
</classpath>
|
||||
</javac2>
|
||||
|
||||
<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 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);
|
||||
}
|
||||
}
|
||||
+34
@@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -142,4 +142,4 @@ class KotlinCacheService(val project: Project) {
|
||||
public fun <T> get(extension: CacheExtension<T>): T {
|
||||
return globalCachesPerPlatform[extension.platform]!![extension]
|
||||
}
|
||||
}
|
||||
}
|
||||
-4
@@ -17,11 +17,7 @@
|
||||
package org.jetbrains.jet.plugin.caches.resolve
|
||||
|
||||
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.util.containers.SLRUCache
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
|
||||
class SynchronizedCachedValue<V>(project: Project, provider: () -> CachedValueProvider.Result<V>, trackValue: Boolean = true) {
|
||||
+37
@@ -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);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -22,13 +22,13 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
import com.intellij.psi.util.CachedValuesManager
|
||||
import com.intellij.openapi.util.DefaultModificationTracker
|
||||
import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter
|
||||
import com.intellij.openapi.vfs.VirtualFileAdapter
|
||||
import com.intellij.openapi.vfs.VirtualFileEvent
|
||||
import com.intellij.openapi.vfs.VirtualFileMoveEvent
|
||||
import com.intellij.openapi.vfs.VirtualFileCopyEvent
|
||||
import com.intellij.openapi.vfs.VirtualFilePropertyEvent
|
||||
import com.intellij.openapi.util.SimpleModificationTracker
|
||||
|
||||
class ModuleTypeCacheManager private (project: Project) {
|
||||
class object {
|
||||
@@ -50,7 +50,7 @@ class ModuleTypeCacheManager private (project: Project) {
|
||||
return cachedValue?.getValue(module)
|
||||
}
|
||||
|
||||
private class VfsModificationTracker(project: Project): DefaultModificationTracker() {
|
||||
private class VfsModificationTracker(project: Project): SimpleModificationTracker() {
|
||||
{
|
||||
val connection = project.getMessageBus().connect();
|
||||
connection.subscribe(VirtualFileManager.VFS_CHANGES, BulkVirtualFileListenerAdapter(
|
||||
+53
@@ -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;
|
||||
}
|
||||
}
|
||||
+53
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
+46
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -18,7 +18,6 @@ package org.jetbrains.jet.plugin.highlighter;
|
||||
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.psi.PsiElement;
|
||||
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.JetReferenceExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.plugin.JetPluginUtil;
|
||||
import org.jetbrains.jet.plugin.actions.internal.KotlinInternalModeToggleAction;
|
||||
import org.jetbrains.jet.plugin.ProjectRootsUtil;
|
||||
import org.jetbrains.jet.plugin.actions.internal.KotlinInternalMode;
|
||||
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
|
||||
@@ -37,14 +37,14 @@ import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||
public class DebugInfoAnnotator implements Annotator {
|
||||
|
||||
public static boolean isDebugInfoEnabled() {
|
||||
return KotlinInternalModeToggleAction.OBJECT$.getEnabled();
|
||||
return KotlinInternalMode.OBJECT$.getEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void annotate(@NotNull PsiElement element, @NotNull final AnnotationHolder holder) {
|
||||
if (!isDebugInfoEnabled() ||
|
||||
!JetPluginUtil.isInSource(element) ||
|
||||
JetPluginUtil.isKtFileInGradleProjectInWrongFolder(element)) {
|
||||
!ProjectRootsUtil.isInSource(element) ||
|
||||
JetModuleTypeManager.getInstance().isKtFileInGradleProjectInWrongFolder(element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
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.project.TargetPlatform;
|
||||
import org.jetbrains.jet.plugin.project.TargetPlatformDetector;
|
||||
@@ -36,7 +36,7 @@ public class DuplicateJvmSignatureAnnotator implements Annotator {
|
||||
@Override
|
||||
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
|
||||
if (!(element instanceof JetFile) && !(element instanceof JetDeclaration)) return;
|
||||
if (!JetPluginUtil.isInSource(element, false)) return;
|
||||
if (!ProjectRootsUtil.isInSource(element, false)) return;
|
||||
|
||||
PsiFile file = element.getContainingFile();
|
||||
if (!(file instanceof JetFile) || TargetPlatformDetector.getPlatform((JetFile) file) != TargetPlatform.JVM) return;
|
||||
+8
-14
@@ -45,9 +45,10 @@ import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.Diagnostics;
|
||||
import org.jetbrains.jet.plugin.JetPluginUtil;
|
||||
import org.jetbrains.jet.plugin.actions.internal.KotlinInternalModeToggleAction;
|
||||
import org.jetbrains.jet.plugin.ProjectRootsUtil;
|
||||
import org.jetbrains.jet.plugin.actions.internal.KotlinInternalMode;
|
||||
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.QuickFixes;
|
||||
|
||||
@@ -93,8 +94,8 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
|
||||
|
||||
@Override
|
||||
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
|
||||
if (!(JetPluginUtil.isInSource(element) || element.getContainingFile() instanceof JetCodeFragment)
|
||||
|| JetPluginUtil.isKtFileInGradleProjectInWrongFolder(element)) {
|
||||
if (!(ProjectRootsUtil.isInSource(element) || element.getContainingFile() instanceof JetCodeFragment)
|
||||
|| JetModuleTypeManager.getInstance().isKtFileInGradleProjectInWrongFolder(element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,8 +107,6 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = ResolvePackage.getAnalysisResults(file);
|
||||
if (analyzeExhaust.isError()) {
|
||||
HighlighterPackage.updateHighlightingResult(file, true);
|
||||
|
||||
throw new ProcessCanceledException(analyzeExhaust.getError());
|
||||
}
|
||||
|
||||
@@ -118,15 +117,10 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
for (Diagnostic diagnostic : diagnostics.forElement(element)) {
|
||||
elementAnnotator.registerDiagnosticAnnotations(diagnostic);
|
||||
@@ -264,7 +258,7 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
|
||||
@NotNull
|
||||
private static String getMessage(@NotNull Diagnostic 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();
|
||||
if (message.startsWith("<html>")) {
|
||||
message = String.format("<html>[%s] %s", factoryName, message.substring("<html>".length()));
|
||||
@@ -281,7 +275,7 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
|
||||
@NotNull
|
||||
private static String getDefaultMessage(@NotNull Diagnostic 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 message;
|
||||
+2
-2
@@ -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");
|
||||
* 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.psi.PsiFile
|
||||
import com.intellij.ide.projectView.impl.ProjectRootsUtil
|
||||
import org.jetbrains.jet.plugin.JetFileType
|
||||
import com.intellij.ide.projectView.impl.ProjectRootsUtil
|
||||
|
||||
class KotlinProblemHighlightFilter : ProblemHighlightFilter() {
|
||||
|
||||
+3
-1
@@ -19,7 +19,9 @@ package org.jetbrains.jet.plugin.highlighter;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.psi.PsiElement;
|
||||
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.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
+2
-1
@@ -24,7 +24,8 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
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;
|
||||
|
||||
class SoftKeywordsHighlightingVisitor extends HighlightingVisitor {
|
||||
+3
-1
@@ -19,7 +19,9 @@ package org.jetbrains.jet.plugin.highlighter;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.psi.PsiElement;
|
||||
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.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
+1
-1
@@ -19,9 +19,9 @@ package org.jetbrains.jet.plugin.inspections
|
||||
import com.intellij.codeInspection.LocalInspectionTool
|
||||
import com.intellij.codeInspection.CustomSuppressableInspectionTool
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey
|
||||
import com.intellij.codeInspection.SuppressIntentionAction
|
||||
import com.intellij.codeInspection.SuppressManager
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey
|
||||
|
||||
public abstract class AbstractKotlinInspection: LocalInspectionTool(), CustomSuppressableInspectionTool {
|
||||
public override fun getSuppressActions(element: PsiElement?): Array<SuppressIntentionAction>? {
|
||||
+12
-6
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,18 +16,20 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.intentions
|
||||
|
||||
import com.intellij.codeInsight.intention.impl.BaseIntentionAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.plugin.JetBundle
|
||||
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() {
|
||||
{
|
||||
setText(JetBundle.message(key))
|
||||
public abstract class JetSelfTargetingIntention<T: JetElement>(val key: String, val elementType: Class<T>) : IntentionAction {
|
||||
private var myText:String = JetBundle.message(key);
|
||||
protected fun setText(text: String) {
|
||||
myText = text
|
||||
}
|
||||
override fun getText(): String = myText
|
||||
|
||||
abstract fun isApplicableTo(element: T): Boolean
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
override fun startInWriteAction(): Boolean = true
|
||||
|
||||
override fun toString(): String = getText()
|
||||
}
|
||||
+14
-15
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
* 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.intentions
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
||||
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()) {
|
||||
class object {
|
||||
-1
@@ -29,7 +29,6 @@ import java.util.*
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumEntry
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils.isSyntheticClassObject
|
||||
import org.jetbrains.jet.lang.types.error.MissingDependencyErrorClass
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver
|
||||
import org.jetbrains.jet.lang.resolve.name.isComponentFunctionName
|
||||
|
||||
public fun buildDecompiledText(
|
||||
+2
-5
@@ -16,17 +16,14 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.libraries
|
||||
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.KotlinBinaryClassCache
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.header.KotlinClassHeader
|
||||
import com.intellij.psi.ClassFileViewProvider
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass
|
||||
import com.intellij.ide.highlighter.JavaClassFileType
|
||||
|
||||
public fun isKotlinCompiledFile(file: VirtualFile): Boolean {
|
||||
if (file.getExtension() != StdFileTypes.CLASS.getDefaultExtension()) {
|
||||
return false
|
||||
}
|
||||
if (isKotlinCompiledFileWithIncompatibleAbiVersion(file)) {
|
||||
return false
|
||||
}
|
||||
@@ -35,7 +32,7 @@ public fun isKotlinCompiledFile(file: VirtualFile): Boolean {
|
||||
}
|
||||
|
||||
public fun isKotlinCompiledFileWithIncompatibleAbiVersion(file: VirtualFile): Boolean {
|
||||
if (file.getExtension() != StdFileTypes.CLASS.getDefaultExtension()) {
|
||||
if (file.getExtension() != JavaClassFileType.INSTANCE!!.getDefaultExtension()) {
|
||||
return false
|
||||
}
|
||||
val header = KotlinBinaryClassCache.getKotlinBinaryClass(file)?.getClassHeader()
|
||||
+1
-1
@@ -49,4 +49,4 @@ public class JetClassFileViewProvider(
|
||||
override fun createCopy(copy: VirtualFile): SingleRootFileViewProvider {
|
||||
return JetClassFileViewProvider(getManager(), copy, false, isInternal)
|
||||
}
|
||||
}
|
||||
}
|
||||
-3
@@ -19,13 +19,10 @@ package org.jetbrains.jet.plugin.libraries
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.impl.compiled.ClsFileImpl
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.annotations.Nullable
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.psi.JetDeclaration
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import kotlin.properties.Delegates
|
||||
import com.intellij.psi.PsiFile
|
||||
|
||||
public class JetClsFile(val provider: JetClassFileViewProvider) : ClsFileImpl(provider) {
|
||||
|
||||
+1
-1
@@ -26,4 +26,4 @@ public class JetDecompilerForWrongAbiVersion : ClassFileDecompilers.Light() {
|
||||
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"
|
||||
+1
-1
@@ -16,9 +16,9 @@
|
||||
|
||||
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.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
|
||||
trait ResolverForDecompiler {
|
||||
fun resolveTopLevelClass(classFqName: FqName): ClassDescriptor?
|
||||
+1
-1
@@ -25,4 +25,4 @@ public final class IDEAConfig extends LibrarySourcesConfig {
|
||||
public IDEAConfig(@NotNull Project project) {
|
||||
super(project, "default", ProjectStructureUtil.getLibLocationForProject(project), EcmaVersion.defaultVersion(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
-13
@@ -31,6 +31,7 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.search.FileTypeIndex;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
@@ -40,16 +41,12 @@ import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.plugin.configuration.ConfigureKotlinInProjectUtils;
|
||||
import org.jetbrains.jet.plugin.framework.JSLibraryStdPresentationProvider;
|
||||
import org.jetbrains.jet.plugin.framework.JsHeaderLibraryPresentationProvider;
|
||||
import org.jetbrains.jet.plugin.framework.LibraryPresentationProviderUtil;
|
||||
import org.jetbrains.jet.plugin.versions.KotlinRuntimeLibraryUtil;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
import org.jetbrains.jet.plugin.framework.JsHeaderLibraryDetectionUtil;
|
||||
import org.jetbrains.jet.plugin.framework.JsLibraryStdDetectionUtil;
|
||||
import org.jetbrains.jet.plugin.versions.KotlinRuntimeLibraryCoreUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class ProjectStructureUtil {
|
||||
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) {
|
||||
GlobalSearchScope scope = module.getModuleWithDependenciesAndLibrariesScope(
|
||||
ConfigureKotlinInProjectUtils.hasKotlinFilesOnlyInTests(module));
|
||||
return KotlinRuntimeLibraryUtil.getKotlinRuntimeMarkerClass(scope) != null;
|
||||
hasKotlinFilesOnlyInTests(module));
|
||||
return KotlinRuntimeLibraryCoreUtil.getKotlinRuntimeMarkerClass(scope) != null;
|
||||
}
|
||||
|
||||
public static boolean isJsKotlinModule(@NotNull final Module module) {
|
||||
@@ -162,7 +159,10 @@ public class ProjectStructureUtil {
|
||||
ModuleRootManager.getInstance(module).orderEntries().librariesOnly().forEachLibrary(new Processor<Library>() {
|
||||
@Override
|
||||
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)) {
|
||||
String path = PathUtil.getLocalPath(PathUtil.getLocalFile(file));
|
||||
if (path != null) {
|
||||
@@ -193,7 +193,11 @@ public class ProjectStructureUtil {
|
||||
ModuleRootManager.getInstance(module).orderEntries().librariesOnly().forEachLibrary(new Processor<Library>() {
|
||||
@Override
|
||||
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);
|
||||
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));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -549,4 +549,4 @@ public class ResolveElementCache {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -159,4 +159,4 @@ private class CaretBox<out E: JetExpression>(
|
||||
if (editor == null) return
|
||||
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() {}
|
||||
}
|
||||
+6
-7
@@ -22,14 +22,15 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
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.newvfs.NewVirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -153,16 +154,14 @@ public class BuiltInsReferenceResolver extends AbstractProjectComponent {
|
||||
|
||||
@NotNull
|
||||
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;
|
||||
|
||||
// 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.refresh(false, true);
|
||||
PathUtil.getLocalFile(vf).refresh(false, true);
|
||||
|
||||
PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(vf);
|
||||
assert psiDirectory != null : "No PsiDirectory for " + vf;
|
||||
-5
@@ -19,18 +19,13 @@ package org.jetbrains.jet.plugin.references
|
||||
import com.intellij.psi.PsiReference
|
||||
import com.intellij.psi.PsiElement
|
||||
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 org.jetbrains.jet.lang.psi.JetPropertyAccessor
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
||||
import org.jetbrains.jet.lang.psi.JetProperty
|
||||
import java.util.HashSet
|
||||
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.JetElement
|
||||
import org.jetbrains.jet.plugin.intentions.OperatorToFunctionIntention
|
||||
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||
+1
-1
@@ -30,4 +30,4 @@ fun Project.allScope(): GlobalSearchScope = GlobalSearchScope.allScope(this)
|
||||
|
||||
fun Project.projectScope(): GlobalSearchScope = GlobalSearchScope.projectScope(this)
|
||||
|
||||
fun PsiFile.fileScope(): GlobalSearchScope = GlobalSearchScope.fileScope(this)
|
||||
fun PsiFile.fileScope(): GlobalSearchScope = GlobalSearchScope.fileScope(this)
|
||||
+1
-1
@@ -46,4 +46,4 @@ public class JetPropertyShortNameIndex extends StringStubIndexExtension<JetPrope
|
||||
public Collection<JetProperty> get(String s, Project project, @NotNull GlobalSearchScope scope) {
|
||||
return super.get(s, project, JetSourceFilterScope.kotlinSourcesAndLibraries(scope, project));
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -16,7 +16,7 @@
|
||||
|
||||
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.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
@@ -25,7 +25,7 @@ import com.intellij.psi.search.DelegatingGlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
import org.jetbrains.jet.plugin.JetPluginUtil;
|
||||
import org.jetbrains.jet.plugin.configuration.JetModuleTypeManager;
|
||||
|
||||
public class JetSourceFilterScope extends DelegatingGlobalSearchScope {
|
||||
@NotNull
|
||||
@@ -55,11 +55,11 @@ public class JetSourceFilterScope extends DelegatingGlobalSearchScope {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (includeLibraries && StdFileTypes.CLASS == file.getFileType()) {
|
||||
if (includeLibraries && JavaClassFileType.INSTANCE == file.getFileType()) {
|
||||
return index.isInLibraryClasses(file);
|
||||
}
|
||||
|
||||
if (JetPluginUtil.isKtFileInGradleProjectInWrongFolder(file, project)) {
|
||||
if (JetModuleTypeManager.getInstance().isKtFileInGradleProjectInWrongFolder(file, getProject())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
-2
@@ -18,14 +18,12 @@ package org.jetbrains.jet.plugin.stubindex.resolve
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.annotations.Nullable
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassLikeInfo
|
||||
import org.jetbrains.jet.lang.resolve.lazy.declarations.*
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import org.jetbrains.jet.plugin.stubindex.JetAllPackagesIndex
|
||||
import org.jetbrains.jet.storage.StorageManager
|
||||
import java.util.Arrays
|
||||
|
||||
public class PluginDeclarationProviderFactory(
|
||||
private val project: Project,
|
||||
+1
-1
@@ -35,4 +35,4 @@ public class PluginDeclarationProviderFactoryService : DeclarationProviderFactor
|
||||
return PluginDeclarationProviderFactory(project, JetSourceFilterScope.kotlinSources(filesScope, project),
|
||||
storageManager, syntheticFiles)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -75,4 +75,4 @@ private val TOP_LEVEL_DECLARATION_INDICES: List<StringStubIndexExtension<out Jet
|
||||
JetFullClassNameIndex.getInstance(),
|
||||
JetTopLevelFunctionsFqnNameIndex.getInstance(),
|
||||
JetTopLevelPropertiesFqnNameIndex.getInstance()
|
||||
)
|
||||
)
|
||||
+1
-2
@@ -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");
|
||||
* 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 org.jetbrains.jet.lang.parsing.JetExpressionParsing.Precedence.*
|
||||
import org.jetbrains.jet.lang.psi.*
|
||||
import org.jetbrains.jet.utils.*
|
||||
|
||||
public object JetPsiPrecedences {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user