mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java: .class stub builder API cleaned from explicit ASM dependency
This commit is contained in:
@@ -567,15 +567,13 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
|
||||
return dir.findChild(baseName + "$" + innerName + ".class");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassReader readerForInnerClass(VirtualFile innerClass) {
|
||||
public void accept(VirtualFile innerClass, StubBuildingVisitor<VirtualFile> visitor) {
|
||||
try {
|
||||
return new ClassReader(innerClass.contentsToByteArray());
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
byte[] bytes = innerClass.contentsToByteArray();
|
||||
new ClassReader(bytes).accept(visitor, ClassReader.SKIP_FRAMES);
|
||||
}
|
||||
catch (IOException ignored) { }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-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.
|
||||
@@ -13,19 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.psi.impl.compiled;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public interface InnerClassSourceStrategy<T> {
|
||||
@Nullable
|
||||
T findInnerClass(String name, T outerClass);
|
||||
|
||||
@Nullable
|
||||
ClassReader readerForInnerClass(T innerClass);
|
||||
void accept(T innerClass, StubBuildingVisitor<T> visitor);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
public static final String FLOAT_NEGATIVE_INF = "-1.0f / 0.0";
|
||||
public static final String FLOAT_NAN = "0.0f / 0.0";
|
||||
|
||||
public static final int ASM_API = Opcodes.ASM5;
|
||||
private static final int ASM_API = Opcodes.ASM5;
|
||||
|
||||
@NonNls private static final String SYNTHETIC_CLASS_INIT_METHOD = "<clinit>";
|
||||
@NonNls private static final String SYNTHETIC_INIT_METHOD = "<init>";
|
||||
@@ -207,6 +207,9 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
case Opcodes.V1_7:
|
||||
return LanguageLevel.JDK_1_7;
|
||||
|
||||
case Opcodes.V1_8:
|
||||
return LanguageLevel.JDK_1_8;
|
||||
|
||||
default:
|
||||
return LanguageLevel.HIGHEST;
|
||||
}
|
||||
@@ -320,14 +323,11 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
return;
|
||||
}
|
||||
|
||||
final T innerSource = myInnersStrategy.findInnerClass(innerName, mySource);
|
||||
if (innerSource == null) return;
|
||||
|
||||
final ClassReader reader = myInnersStrategy.readerForInnerClass(innerSource);
|
||||
if (reader == null) return;
|
||||
|
||||
final StubBuildingVisitor<T> classVisitor = new StubBuildingVisitor<T>(innerSource, myInnersStrategy, myResult, access, innerName);
|
||||
reader.accept(classVisitor, ClassReader.SKIP_FRAMES);
|
||||
T innerClass = myInnersStrategy.findInnerClass(innerName, mySource);
|
||||
if (innerClass != null) {
|
||||
StubBuildingVisitor<T> visitor = new StubBuildingVisitor<T>(innerClass, myInnersStrategy, myResult, access, innerName);
|
||||
myInnersStrategy.accept(innerClass, visitor);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCorrectName(String name) {
|
||||
|
||||
Reference in New Issue
Block a user