Merged resolve & code windows into one, adding icon to them.
#KT-1353 fixed
This commit is contained in:
@@ -135,11 +135,10 @@
|
||||
|
||||
<psi.treeChangePreprocessor implementation="org.jetbrains.jet.asJava.JetCodeBlockModificationListener"/>
|
||||
|
||||
<toolWindow id="CodeWindow"
|
||||
factoryClass="org.jetbrains.jet.plugin.internal.codewindow.BytecodeToolwindow$Factory"
|
||||
anchor="right"/>
|
||||
<toolWindow id="ResolveWindow"
|
||||
factoryClass="org.jetbrains.jet.plugin.internal.resolvewindow.ResolveToolwindow$Factory"
|
||||
anchor="right"/>
|
||||
<toolWindow id="Kotlin"
|
||||
factoryClass="org.jetbrains.jet.plugin.internal.KotlinInternalToolWindowFactory"
|
||||
anchor="right"
|
||||
icon="/org/jetbrains/jet/plugin/icons/kotlin16x16.png"
|
||||
/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.internal;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowFactory;
|
||||
import com.intellij.ui.content.ContentFactory;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import org.jetbrains.jet.plugin.internal.codewindow.BytecodeToolwindow;
|
||||
import org.jetbrains.jet.plugin.internal.resolvewindow.ResolveToolwindow;
|
||||
|
||||
/**
|
||||
* @author Evgeny Gerashchenko
|
||||
* @since 2/20/12
|
||||
*/
|
||||
public class KotlinInternalToolWindowFactory implements ToolWindowFactory {
|
||||
@Override
|
||||
public void createToolWindowContent(Project project, ToolWindow toolWindow) {
|
||||
ContentManager contentManager = toolWindow.getContentManager();
|
||||
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
|
||||
contentManager.addContent(contentFactory.createContent(new ResolveToolwindow(project), "Resolve", false));
|
||||
contentManager.addContent(contentFactory.createContent(new BytecodeToolwindow(project), "Bytecode", false));
|
||||
}
|
||||
}
|
||||
@@ -32,11 +32,8 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowFactory;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.ui.content.ContentFactory;
|
||||
import com.intellij.util.Alarm;
|
||||
import org.jetbrains.jet.codegen.ClassBuilderFactory;
|
||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||
@@ -57,6 +54,11 @@ import java.util.Scanner;
|
||||
|
||||
public class BytecodeToolwindow extends JPanel {
|
||||
private static final int UPDATE_DELAY = 500;
|
||||
private static final String DEFAULT_TEXT = "/*\n" +
|
||||
"Generated bytecode for Kotlin source file.\n" +
|
||||
"No Kotlin source file is opened.\n" +
|
||||
"*/";
|
||||
|
||||
private final Editor myEditor;
|
||||
private final Alarm myUpdateAlarm;
|
||||
private Location myCurrentLocation;
|
||||
@@ -86,18 +88,18 @@ public class BytecodeToolwindow extends JPanel {
|
||||
Editor editor = location.editor;
|
||||
|
||||
if (editor == null) {
|
||||
setText("");
|
||||
setText(DEFAULT_TEXT);
|
||||
}
|
||||
else {
|
||||
VirtualFile vFile = ((EditorEx) editor).getVirtualFile();
|
||||
if (vFile == null) {
|
||||
setText("");
|
||||
setText(DEFAULT_TEXT);
|
||||
return;
|
||||
}
|
||||
|
||||
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(vFile);
|
||||
if (!(psiFile instanceof JetFile)) {
|
||||
setText("");
|
||||
setText(DEFAULT_TEXT);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,15 +222,7 @@ public class BytecodeToolwindow extends JPanel {
|
||||
|
||||
return answer.toString();
|
||||
}
|
||||
|
||||
|
||||
public static class Factory implements ToolWindowFactory {
|
||||
@Override
|
||||
public void createToolWindowContent(Project project, ToolWindow toolWindow) {
|
||||
toolWindow.getContentManager().addContent(ContentFactory.SERVICE.getInstance().createContent(new BytecodeToolwindow(project), "", false));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Location {
|
||||
final Editor editor;
|
||||
final long modificationStamp;
|
||||
|
||||
@@ -28,14 +28,11 @@ import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowFactory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.ui.content.ContentFactory;
|
||||
import com.intellij.util.Alarm;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -69,14 +66,11 @@ public class ResolveToolwindow extends JPanel {
|
||||
|
||||
public static final String BAR = "\n\n===\n\n";
|
||||
|
||||
public static class Factory implements ToolWindowFactory {
|
||||
@Override
|
||||
public void createToolWindowContent(Project project, ToolWindow toolWindow) {
|
||||
toolWindow.getContentManager().addContent(ContentFactory.SERVICE.getInstance().createContent(new ResolveToolwindow(project), "", false));
|
||||
}
|
||||
}
|
||||
|
||||
private static final int UPDATE_DELAY = 500;
|
||||
private static final String DEFAULT_TEXT = "/*\n" +
|
||||
"Information about symbols resolved by\nKotlin compiler.\n" +
|
||||
"No Kotlin source file is opened.\n" +
|
||||
"*/";
|
||||
private final Editor myEditor;
|
||||
private final Alarm myUpdateAlarm;
|
||||
private BytecodeToolwindow.Location myCurrentLocation;
|
||||
@@ -105,18 +99,18 @@ public class ResolveToolwindow extends JPanel {
|
||||
private void render(BytecodeToolwindow.Location location, BytecodeToolwindow.Location oldLocation) {
|
||||
Editor editor = location.getEditor();
|
||||
if (editor == null) {
|
||||
setText("No editor");
|
||||
setText(DEFAULT_TEXT);
|
||||
}
|
||||
else {
|
||||
VirtualFile vFile = ((EditorEx) editor).getVirtualFile();
|
||||
if (vFile == null) {
|
||||
setText("");
|
||||
setText(DEFAULT_TEXT);
|
||||
return;
|
||||
}
|
||||
|
||||
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(vFile);
|
||||
if (!(psiFile instanceof JetFile)) {
|
||||
setText("");
|
||||
setText(DEFAULT_TEXT);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user