KT-5531 Introduce separate 'kotlin.internal.mode' property and use it to trigger red/black rectangles and debug information in error tooltips

#KT-5531 fixed
This commit is contained in:
Evgeny Gerashchenko
2014-07-31 13:19:35 +04:00
parent d4d25f6ed0
commit 2c7ec8a7ae
4 changed files with 51 additions and 3 deletions
+4
View File
@@ -103,6 +103,10 @@
<add-to-group group-id="KotlinToolsGroup" anchor="last"/>
</action>
<action id="KotlinInternalMode" class="org.jetbrains.jet.plugin.actions.internal.KotlinInternalModeToggleAction">
<add-to-group group-id="KotlinToolsGroup" anchor="last"/>
</action>
<action id="ExtractFunctionToScope" class="org.jetbrains.jet.plugin.refactoring.extractFunction.ExtractFunctionToScopeAction"
text="Extract Function to _Scope...">
<keyboard-shortcut keymap="$default" first-keystroke="control alt shift M"/>
@@ -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.actions.internal
import com.intellij.openapi.actionSystem.ToggleAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.ide.util.PropertiesComponent
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
public class KotlinInternalModeToggleAction: ToggleAction("Kotlin Internal Mode", "Show debug highlighting", null) {
public class object {
val INTERNAL_MODE_PROPERTY = "kotlin.internal.mode.enabled"
public fun isEnabled(): Boolean {
return PropertiesComponent.getInstance()!!.getBoolean(INTERNAL_MODE_PROPERTY, false)
}
}
override fun isSelected(e: AnActionEvent?): Boolean {
return isEnabled()
}
override fun setSelected(e: AnActionEvent?, state: Boolean) {
PropertiesComponent.getInstance()!!.setValue(INTERNAL_MODE_PROPERTY, "$state")
DaemonCodeAnalyzer.getInstance(e!!.getProject())!!.settingsChanged()
}
}
@@ -28,6 +28,7 @@ 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.caches.resolve.ResolvePackage;
/**
@@ -36,7 +37,7 @@ import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
public class DebugInfoAnnotator implements Annotator {
public static boolean isDebugInfoEnabled() {
return ApplicationManager.getApplication().isInternal();
return KotlinInternalModeToggleAction.OBJECT$.isEnabled();
}
@Override
@@ -46,6 +46,7 @@ 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.caches.resolve.ResolvePackage;
import org.jetbrains.jet.plugin.quickfix.JetIntentionActionsFactory;
import org.jetbrains.jet.plugin.quickfix.QuickFixes;
@@ -263,7 +264,7 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
@NotNull
private static String getMessage(@NotNull Diagnostic diagnostic) {
String message = IdeErrorMessages.RENDERER.render(diagnostic);
if (ApplicationManager.getApplication().isInternal() || ApplicationManager.getApplication().isUnitTestMode()) {
if (KotlinInternalModeToggleAction.OBJECT$.isEnabled() || ApplicationManager.getApplication().isUnitTestMode()) {
String factoryName = diagnostic.getFactory().getName();
if (message.startsWith("<html>")) {
message = String.format("<html>[%s] %s", factoryName, message.substring("<html>".length()));
@@ -280,7 +281,7 @@ public class JetPsiChecker implements Annotator, HighlightRangeExtension {
@NotNull
private static String getDefaultMessage(@NotNull Diagnostic diagnostic) {
String message = DefaultErrorMessages.RENDERER.render(diagnostic);
if (ApplicationManager.getApplication().isInternal() || ApplicationManager.getApplication().isUnitTestMode()) {
if (KotlinInternalModeToggleAction.OBJECT$.isEnabled() || ApplicationManager.getApplication().isUnitTestMode()) {
return String.format("[%s] %s", diagnostic.getFactory().getName(), message);
}
return message;