diff --git a/plugins/ByteCodeViewer/src/META-INF/plugin.xml b/plugins/ByteCodeViewer/src/META-INF/plugin.xml index 9a0135ae9121..a689bc291639 100644 --- a/plugins/ByteCodeViewer/src/META-INF/plugin.xml +++ b/plugins/ByteCodeViewer/src/META-INF/plugin.xml @@ -5,11 +5,17 @@ Viewing java bytecode inside IntelliJ IDEA. JetBrains + + + + + + diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.java b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.java index a5fc96c7198b..40c505f96762 100644 --- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.java +++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.java @@ -5,6 +5,7 @@ import com.intellij.ide.util.JavaAnonymousClassesHelper; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; @@ -35,6 +36,8 @@ import java.io.StringWriter; * Date: 5/7/12 */ public class ByteCodeViewerManager extends DockablePopupManager { + private static final ExtensionPointName CLASS_SEARCHER_EP = ExtensionPointName.create("ByteCodeViewer.classSearcher"); + private static final Logger LOG = Logger.getInstance("#" + ByteCodeViewerManager.class.getName()); public static final String TOOLWINDOW_ID = "Byte Code Viewer"; @@ -232,13 +235,13 @@ public class ByteCodeViewerManager extends DockablePopupManager + diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index fa0fffb25f13..5d80f548fd61 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -26,6 +26,7 @@ org.intellij.intelliLang AntSupport cucumber + ByteCodeViewer @@ -1429,6 +1430,10 @@ + + + + diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/byteCodeViewer/GroovyScriptClassSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/byteCodeViewer/GroovyScriptClassSearcher.java new file mode 100644 index 000000000000..3365dc54f5c5 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/byteCodeViewer/GroovyScriptClassSearcher.java @@ -0,0 +1,50 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.byteCodeViewer; + +import com.intellij.byteCodeViewer.ClassSearcher; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiTypeParameter; +import com.intellij.psi.util.PsiTreeUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.groovy.GroovyFileType; +import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; + +/** + * Created by Max Medvedev on 8/23/13 + */ +public class GroovyScriptClassSearcher implements ClassSearcher { + @Nullable + @Override + public PsiClass findClass(@NotNull PsiElement place) { + if (place.getLanguage() == GroovyFileType.GROOVY_LANGUAGE) { + PsiClass containingClass = PsiTreeUtil.getParentOfType(place, PsiClass.class, false); + while (containingClass instanceof PsiTypeParameter) { + containingClass = PsiTreeUtil.getParentOfType(containingClass, PsiClass.class); + } + if (containingClass != null) return containingClass; + + PsiFile file = place.getContainingFile(); + if (file instanceof GroovyFile && ((GroovyFile)file).isScript()) { + return ((GroovyFile)file).getScriptClass(); + } + } + return null; + } +}