From bacb13f0a14d44d480a2596bd5c1fc3a9842bded Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 7 Jan 2016 11:39:58 +0100 Subject: [PATCH] Cleanup (minor optimization; dead code dropped) --- .../psi/impl/compiled/ClsFileImpl.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java index 820d13c2cdbb..7f963e18cbc0 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 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. @@ -34,11 +34,11 @@ import com.intellij.openapi.project.DefaultProjectFactory; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.roots.FileIndexFacade; import com.intellij.openapi.ui.Queryable; -import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.util.text.StringUtilRt; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; @@ -588,10 +588,8 @@ public class ClsFileImpl extends ClsRepositoryPsiElement try { ClassReader reader = new ClassReader(bytes); - String internalName = reader.getClassName(); String className = file.getNameWithoutExtension(); - String fqn = StubBuildingVisitor.getFqn(internalName, className, null); - String packageName = getPackageName(fqn, className); + String packageName = getPackageName(reader.getClassName()); PsiJavaFileStubImpl stub = new PsiJavaFileStubImpl(packageName, true); try { @@ -611,6 +609,11 @@ public class ClsFileImpl extends ClsRepositoryPsiElement } } + private static String getPackageName(String internalName) { + int p = internalName.lastIndexOf('/'); + return p > 0 ? internalName.substring(0, p).replace('/', '.') : StringUtilRt.EMPTY_STRING; + } + private static final InnerClassSourceStrategy STRATEGY = new InnerClassSourceStrategy() { @Nullable @Override @@ -618,7 +621,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement String baseName = outerClass.getNameWithoutExtension(); VirtualFile dir = outerClass.getParent(); assert dir != null : outerClass; - return dir.findChild(baseName + "$" + innerName + ".class"); + return dir.findChild(baseName + '$' + innerName + ".class"); } @Override @@ -630,14 +633,4 @@ public class ClsFileImpl extends ClsRepositoryPsiElement catch (IOException ignored) { } } }; - - private static String getPackageName(String fqn, String shortName) { - return fqn == null || Comparing.equal(shortName, fqn) ? "" : fqn.substring(0, fqn.lastIndexOf('.')); - } - - /** @deprecated use {@link #ClsFileImpl(FileViewProvider)} (to remove in IDEA 15) */ - @SuppressWarnings("unused") - public ClsFileImpl(@NotNull PsiManager manager, @NotNull FileViewProvider viewProvider) { - this(viewProvider); - } -} +} \ No newline at end of file