mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
java: util method shouldn't pretend it recognizes all .class file versions
This commit is contained in:
+4
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -185,8 +185,10 @@ public class AttachSourcesNotificationProvider extends EditorNotifications.Provi
|
||||
if (stream.readInt() == 0xCAFEBABE) {
|
||||
int minor = stream.readUnsignedShort();
|
||||
int major = stream.readUnsignedShort();
|
||||
StringBuilder info = new StringBuilder().append("bytecode version: ").append(major).append('.').append(minor);
|
||||
LanguageLevel level = ClsParsingUtil.getLanguageLevelByVersion(major);
|
||||
return "bytecode version: " + major + "." + minor + " (" + level.getName() + ")";
|
||||
if (level != null) info.append(" (").append(level.getName()).append(')');
|
||||
return info.toString();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -189,6 +189,7 @@ public class ClsParsingUtil {
|
||||
return StringUtil.isJavaIdentifier(identifier) && !JavaLexer.isKeyword(identifier, level);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LanguageLevel getLanguageLevelByVersion(int major) {
|
||||
switch (major) {
|
||||
case Opcodes.V1_1:
|
||||
@@ -213,7 +214,7 @@ public class ClsParsingUtil {
|
||||
return LanguageLevel.JDK_1_8;
|
||||
|
||||
default:
|
||||
return LanguageLevel.HIGHEST;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
myResult = new PsiClassStubImpl(JavaStubElementTypes.CLASS, myParent, fqn, shortName, null, stubFlags);
|
||||
|
||||
LanguageLevel languageLevel = ClsParsingUtil.getLanguageLevelByVersion(version);
|
||||
if (languageLevel == null) languageLevel = LanguageLevel.HIGHEST;
|
||||
((PsiClassStubImpl)myResult).setLanguageLevel(languageLevel);
|
||||
|
||||
myModList = new PsiModifierListStubImpl(myResult, packClassFlags(flags));
|
||||
|
||||
Reference in New Issue
Block a user