Merge remote-tracking branch 'origin/master' into develar/is
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Wed, 13 Jul 2016 11:43:03 +0000 (13:43 +0200)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Wed, 13 Jul 2016 11:43:03 +0000 (13:43 +0200)
71 files changed:
build/groovy/org/jetbrains/intellij/build/ApplicationInfoProperties.groovy
build/groovy/org/jetbrains/intellij/build/BuildContext.groovy
build/groovy/org/jetbrains/intellij/build/IdeaCommunityProperties.groovy
build/groovy/org/jetbrains/intellij/build/ProductProperties.groovy
build/groovy/org/jetbrains/intellij/build/SignTool.groovy
build/groovy/org/jetbrains/intellij/build/impl/BuildTasksImpl.groovy
build/groovy/org/jetbrains/intellij/build/impl/LinuxDistributionBuilder.groovy
build/groovy/org/jetbrains/intellij/build/impl/MacDistributionBuilder.groovy
build/groovy/org/jetbrains/intellij/build/impl/MacDmgBuilder.groovy
build/groovy/org/jetbrains/intellij/build/impl/WinExeInstallerBuilder.groovy
build/groovy/org/jetbrains/intellij/build/impl/WindowsDistributionBuilder.groovy
build/scripts/layouts.gant
java/execution/openapi/src/com/intellij/execution/JavaExecutionUtil.java
java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java
java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaModuleNameIndex.java [new file with mode: 0644]
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClassFileStubBuilder.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java [new file with mode: 0644]
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleReferenceImpl.java [new file with mode: 0644]
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsPackageStatementImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/compiled/ModuleStubBuildingVisitor.java [new file with mode: 0644]
java/java-psi-impl/src/com/intellij/psi/impl/compiled/StubBuildingVisitor.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/ClsStubPsiFactory.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaClassElementType.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaModuleElementType.java [new file with mode: 0644]
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaStubElementTypes.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/PsiClassStub.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/PsiJavaFileStub.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/PsiJavaModuleStub.java [new file with mode: 0644]
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/SourceStubPsiFactory.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/StubPsiFactory.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiClassStubImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiJavaFileStubImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiJavaModuleStubImpl.java [new file with mode: 0644]
java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/index/JavaStubIndexKeys.java
java/java-psi-impl/src/com/intellij/psi/impl/source/JavaFileElementType.java
java/java-psi-impl/src/com/intellij/psi/impl/source/JavaLightStubBuilder.java
java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaModuleImpl.java
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advFixture/UsageOfProtectedAnnotationOutsideAPackage.java [new file with mode: 0644]
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/AmbiguousMethodCallIDEA67671.java
java/java-tests/testData/psi/cls/mirror/module-info.txt [new file with mode: 0644]
java/java-tests/testData/psi/cls/stubBuilder/module-info.class [new file with mode: 0644]
java/java-tests/testData/psi/cls/stubBuilder/module-info.txt [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingFixtureTest.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/ModuleHighlightingTest.java [deleted file]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/ModuleHighlightingTest.kt [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java
java/java-tests/testSrc/com/intellij/psi/ClsMirrorBuildingTest.java
java/java-tests/testSrc/com/intellij/psi/ClsPsiTest.java
java/java-tests/testSrc/com/intellij/psi/ClsStubBuilderTest.java
java/java-tests/testSrc/com/intellij/psi/JavaStubBuilderTest.java
platform/core-impl/src/com/intellij/extapi/psi/StubBasedPsiElementBase.java
platform/core-impl/src/com/intellij/openapi/application/impl/ApplicationInfoImpl.java
platform/icons/src/process/big/step_2@2x_dark.png [moved from platform/icons/src/process/big/step_2_dark@2x.png with 100% similarity]
platform/platform-api/src/com/intellij/ui/components/ScrollPainter.java
platform/platform-api/src/com/intellij/ui/paint/RectanglePainter.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorView.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java
platform/platform-resources/src/brokenPlugins.txt
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionJdk6Test.java [new file with mode: 0644]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionJdk7Test.java [new file with mode: 0644]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionTest.java [deleted file]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionTestBase.java [new file with mode: 0644]
plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/IdeaDecompiler.kt
python/educational-core/student/resources/icons/com/jetbrains/edu/learning/LessonCompl@2x.png [moved from python/educational-core/student/resources/icons/com/jetbrains/edu/learning/LessonComp@2x.png with 100% similarity]
python/educational-python/student-python/resources/icons/com/jetbrains/edu/learning/EducationalProjectType@2x_dark.png [moved from python/educational-python/student-python/resources/icons/com/jetbrains/edu/learning/EducationalProjectType_dark@2x.png with 100% similarity]
python/helpers/pydev/_pydev_bundle/pydev_ipython_console_011.py
resources/src/META-INF/IdeaPlugin.xml
xml/openapi/src/com/intellij/xml/breadcrumbs/BreadcrumbsComponent.java

index 6ef8d0080b51214ab769b8e48239bfe8d6a01287..ed1055dc6897c8ca2ecf09eea08e79c4ee855142 100644 (file)
  * limitations under the License.
  */
 package org.jetbrains.intellij.build
+
+import java.text.MessageFormat
+
 /**
  * @author nik
  */
 class ApplicationInfoProperties {
   final String majorVersion
   final String minorVersion
+  final String microVersion
+  final String patchVersion
+  final String fullVersionFormat
   final String shortProductName
   final String minorVersionMainPart
   final String productName
@@ -30,7 +36,10 @@ class ApplicationInfoProperties {
   ApplicationInfoProperties(String appInfoXmlPath) {
     def root = new XmlParser().parse(new File(appInfoXmlPath))
     majorVersion = root.version.first().@major
-    minorVersion = root.version.first().@minor
+    minorVersion = root.version.first().@minor ?: "0"
+    microVersion = root.version.first().@micro ?: "0"
+    patchVersion = root.version.first().@patch ?: "0"
+    fullVersionFormat = root.version.first().@full ?: "{0}.{1}"
     shortProductName = root.names.first().@product
     productName = root.names.first().@fullname
     companyName = root.company.first().@name
@@ -39,4 +48,8 @@ class ApplicationInfoProperties {
   }
 
   public String getUpperCaseProductName() { shortProductName.toUpperCase() }
+
+  public String getFullVersion() {
+    MessageFormat.format(fullVersionFormat, majorVersion, minorVersion, microVersion, patchVersion)
+  }
 }
\ No newline at end of file
index 1ee57ba15df562eaff40e58aa372e9e64e46147f..f73294e7b9bf679be7b5744b9f98f51125ac4fb1 100644 (file)
@@ -73,6 +73,9 @@ abstract class BuildContext {
 
   abstract void signExeFile(String path)
 
+  /**
+   * Execute a build step or skip it if {@code stepId} is included into {@link BuildOptions#buildStepsToSkip}
+   */
   abstract void executeStep(String stepMessage, String stepId, Closure step)
 
   public static BuildContext createContext(GantBuilder ant, JpsGantProjectBuilder projectBuilder, JpsProject project, JpsGlobal global,
@@ -113,7 +116,7 @@ abstract class BuildPaths {
   String distAll
 
   /**
-   * Path to a directory where temporary files required for a particular build steps can be stored
+   * Path to a directory where temporary files required for a particular build step can be stored
    */
   String temp
 
index 89c5025ed4ec9febb5e14b1bfc1bf9c8736420da..d8706727fac38fc4d0f9ffad519f737fc4fa125c 100644 (file)
@@ -25,9 +25,6 @@ class IdeaCommunityProperties extends ProductProperties {
     productCode = "IC"
     applicationInfoModule = "community-resources"
     additionalIDEPropertiesFilePaths = ["$home/build/conf/ideaCE.properties"]
-    maySkipAndroidPlugin = true
-    relativeAndroidHome = "android"
-    relativeAndroidToolsBaseHome = "android/tools-base"
     toolsJarRequired = true
   }
 
@@ -98,5 +95,5 @@ class IdeaCommunityProperties extends ProductProperties {
   String systemSelector(ApplicationInfoProperties applicationInfo) { "IdeaIC${applicationInfo.majorVersion}.${applicationInfo.minorVersionMainPart}" }
 
   @Override
-  String baseArtifactName(String buildNumber) { "ideaIC-$buildNumber" }
+  String baseArtifactName(ApplicationInfoProperties applicationInfo, String buildNumber) { "ideaIC-$buildNumber" }
 }
\ No newline at end of file
index a15fb138f60860afed70fe34bbc33217004f07a0..56d89a174c07a9c73de6f5e2cc5f6c7dd5b93abb 100644 (file)
@@ -78,7 +78,7 @@ public abstract class ProductProperties {
   /**
    * Base file name (without extension) for product archives and installers (*.exe, *.tar.gz, *.dmg)
    */
-  abstract String baseArtifactName(String buildNumber)
+  abstract String baseArtifactName(ApplicationInfoProperties applicationInfo, String buildNumber)
 
   /**
    * @return instance of the class containing properties specific for Windows distribution or {@code null} if the product doesn't have Windows distribution
@@ -97,10 +97,6 @@ public abstract class ProductProperties {
 
   boolean setPluginAndIDEVersionInPluginXml = true
 
-  boolean maySkipAndroidPlugin
-  String relativeAndroidHome
-  String relativeAndroidToolsBaseHome
-
   /**
    * Path to a directory containing yjpagent*.dll, libyjpagent-linux*.so and libyjpagent.jnilib files, which will be copied to 'bin'
    * directories of Windows, Linux and Mac OS distributions. If {@code null} no agent files will be bundled.
index 34f8bc98181356f00720fc949cc8af710ea21861..7302fd27cfe0f0c641573b0e71ce3dd185bde4b7 100644 (file)
 package org.jetbrains.intellij.build
 
 /**
+ * Implement this interfaces and pass the implementation to {@link BuildContext#createContext} method to sign the product's *.exe files.
+ *
  * @author nik
  */
 interface SignTool {
+  /**
+   * @param path absolute path (with '/' as a separator) to *.exe file to be signed
+   */
   void signExeFile(String path, BuildContext context)
 }
\ No newline at end of file
index 105885d715bd79af1c347811338aa9a05698d09d..f805b981d6f2fb04b144cccccf6b81a784cfe5f0 100644 (file)
@@ -199,7 +199,9 @@ idea.fatal.error.notification=disabled
 
   @Override
   void buildDistributions() {
-    layoutShared()
+    buildContext.messages.block("Copy files shared among all distributions") {
+      layoutShared()
+    }
     def propertiesFile = patchIdeaPropertiesFile()
 
     WindowsDistributionBuilder windowsBuilder = null
index 59ed23170953cb6a58fb0cf5984bcf6770724bc3..1b6549a61c5747e9ea76be1fbd79022c5361f21e 100644 (file)
@@ -124,7 +124,7 @@ class LinuxDistributionBuilder {
   private void buildTarGz(String jreDirectoryPath) {
     def tarRoot = customizer.rootDirectoryName(buildContext.buildNumber)
     def suffix = jreDirectoryPath != null ? "" : "-no-jdk"
-    def tarPath = "$buildContext.paths.artifacts/${buildContext.productProperties.baseArtifactName(buildContext.buildNumber)}${suffix}.tar"
+    def tarPath = "$buildContext.paths.artifacts/${buildContext.productProperties.baseArtifactName(buildContext.applicationInfo, buildContext.buildNumber)}${suffix}.tar"
     def extraBins = customizer.extraExecutables
     def paths = [buildContext.paths.distAll, unixDistPath]
     if (jreDirectoryPath != null) {
index 7b0650a1a9ad517d2034f0951dcd3118c4e58faa..172479fa1e6f18f8c87ddddfb877f289ee6123ee 100644 (file)
@@ -208,7 +208,7 @@ class MacDistributionBuilder {
       def extraBins = customizer.extraExecutables
       def allPaths = [buildContext.paths.distAll, macDistPath]
       def zipRoot = customizer.rootDirectoryName(buildContext.applicationInfo, buildContext.buildNumber)
-      def targetPath = "$buildContext.paths.artifacts/${buildContext.productProperties.baseArtifactName(buildContext.buildNumber)}.mac.zip"
+      def targetPath = "$buildContext.paths.artifacts/${buildContext.productProperties.baseArtifactName(buildContext.applicationInfo, buildContext.buildNumber)}.mac.zip"
       buildContext.ant.zip(zipfile: targetPath) {
         allPaths.each {
           zipfileset(dir: it, prefix: zipRoot) {
index 42048feb7a5bb4a00c5daff561bf9ebaa87e5941..ed7e508e42395d77f84e33340218016c57c02618 100644 (file)
@@ -65,7 +65,7 @@ class MacDmgBuilder {
 
   private void doSignAndBuildDmg(String macZipPath, String jreArchivePath) {
     def suffix = jreArchivePath != null ? "" : "-no-jdk"
-    String targetFileName = buildContext.productProperties.baseArtifactName(buildContext.buildNumber) + suffix
+    String targetFileName = buildContext.productProperties.baseArtifactName(buildContext.applicationInfo, buildContext.buildNumber) + suffix
     def sitFilePath = "$artifactsPath/${targetFileName}.sit"
     ant.copy(file: macZipPath, tofile: sitFilePath)
     ftpAction("mkdir") {}
index 4e3f2b6977ca4577f7d0c9446516b4037447de1e..bf23841eab5368e5fe3e0b3a1e0e04c8f9be0be6 100644 (file)
@@ -44,7 +44,7 @@ class WinExeInstallerBuilder {
     }
 
     String communityHome = buildContext.paths.communityHome
-    String outFileName = buildContext.productProperties.baseArtifactName(buildContext.buildNumber)
+    String outFileName = buildContext.productProperties.baseArtifactName(buildContext.applicationInfo, buildContext.buildNumber)
     buildContext.messages.progress("Building Windows installer $outFileName")
 
     def box = "$buildContext.paths.temp/winInstaller"
index fe3cb5adb8e5c86b2c5238c020742070825e3ba6..6d0484b21956c364bca19c0af51d0a5d89597294 100644 (file)
@@ -197,7 +197,7 @@ IDS_VM_OPTIONS=$vmOptions
 
   private void buildWinZip(String jreDirectoryPath, String zipNameSuffix) {
     buildContext.messages.block("Build Windows ${zipNameSuffix}.zip distribution") {
-      def targetPath = "$buildContext.paths.artifacts/${buildContext.productProperties.baseArtifactName(buildContext.buildNumber)}${zipNameSuffix}.zip"
+      def targetPath = "$buildContext.paths.artifacts/${buildContext.productProperties.baseArtifactName(buildContext.applicationInfo, buildContext.buildNumber)}${zipNameSuffix}.zip"
       def zipPrefix = customizer.rootDirectoryName(buildContext.buildNumber)
       def dirs = [buildContext.paths.distAll, winDistPath]
       if (jreDirectoryPath != null) {
index b7d57d5d4ac3fa17a1d82806f8012906224a72ef..4aac9d4f52b68c33159eace68be888b049292952 100644 (file)
@@ -18,6 +18,8 @@ import org.jetbrains.intellij.build.BuildContext
 import org.jetbrains.intellij.build.BuildOptions
 import org.jetbrains.intellij.build.BuildTasks
 import org.jetbrains.intellij.build.IdeaCommunityProperties
+import org.jetbrains.jps.model.module.JpsModule
+import org.jetbrains.jps.util.JpsPathUtil
 
 import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
 
@@ -37,14 +39,6 @@ boolean setPluginAndIDEVersionInPluginXml() {
   return !isDefined("productProperties") || productProperties.setPluginAndIDEVersionInPluginXml
 }
 
-String relativeAndroidHome() {
-  return isDefined("productProperties") ? productProperties.relativeAndroidHome : "android"
-}
-
-String relativeAndroidToolsBaseHome() {
-  return isDefined("productProperties") ? productProperties.relativeAndroidToolsBaseHome : relativeAndroidHome() + "/tools-base"
-}
-
 List<String> getExcludedPlugins() {
   return isDefined("productProperties") ? productProperties.excludedPlugins : []
 }
@@ -251,7 +245,7 @@ def layoutFull(BuildContext context) {
       }
     }
 
-    layoutCommunityPlugins(home, context.productProperties.maySkipAndroidPlugin)
+    layoutCommunityPlugins(home, context)
 
     dir("plugins") {
       dir("javaFX") {
@@ -292,22 +286,22 @@ def layoutFull(BuildContext context) {
   return info
 }
 
-public def layoutCommunityPlugins(String home, boolean maySkipAndroidPlugin = false) {
+public def layoutCommunityPlugins(String home, BuildContext buildContext = null) {
   if (!isDefined("pluginFilter") || pluginFilter.contains("android")) {
-    def androidHome = relativeAndroidHome()
-    def androidToolsBaseHome = relativeAndroidToolsBaseHome()
-    if (new File("$home/$androidHome").exists()) {
-      layoutAndroid("$home/$androidHome", "$home/$androidToolsBaseHome")
+    if (buildContext == null) {
+      projectBuilder.error("Cannot build Android plugin: buildContext isn't defined")
     }
-    else {
-      def message = "Android plugin sources aren't found at ${androidHome}"
-      if (maySkipAndroidPlugin) {
-        projectBuilder.warning("$message. Android plugin is excluded from layout.")
-      }
-      else {
-        projectBuilder.error(message)
-      }
+    def androidModule = buildContext.findModule("android")
+    def sdklibModule = buildContext.findModule("sdklib")
+    if (androidModule == null) projectBuilder.error("Cannot build Android plugin: 'android' module isn't included into the project")
+    if (sdklibModule == null) projectBuilder.error("Cannot build Android plugin: 'sdklib' module isn't included into the project")
+
+    def androidHome = JpsPathUtil.urlToPath(androidModule.contentRootsList.urls.first())
+    def androidToolsBaseHome = JpsPathUtil.urlToFile(sdklibModule.contentRootsList.urls.first()).parentFile.canonicalPath
+    [androidHome, androidToolsBaseHome].each {
+      if (!new File(it).exists()) projectBuilder.error("Cannot build Android plugin: $it doesn't exist")
     }
+    layoutAndroid(androidHome, androidToolsBaseHome)
   }
 
   dir("plugins") {
@@ -784,7 +778,7 @@ def reorder(String home, String targetDirectory) {
 def layoutAndroid(String androidHome, String androidToolsBaseHome) {
   dir("plugins") {
     layoutPlugin("android") {
-      fileset(dir: "${androidHome}/android/lib") {
+      fileset(dir: "$androidHome/lib") {
         include(name: "**/*.jar")
         exclude(name: "**/fest-*.jar")
         exclude(name: "src/*.jar")
@@ -834,13 +828,13 @@ def layoutAndroid(String androidHome, String androidToolsBaseHome) {
         module("instant-run-runtime")
       }
       jar("androidAnnotations.jar") {
-        fileset(dir: "$androidHome/android/annotations")
+        fileset(dir: "$androidHome/annotations")
       }
       dir("jps") {
         jar("android-gradle-jps.jar") { module("android-gradle-jps") }
       }
       dir("device-art-resources") {
-        fileset(dir: "$androidHome/android/device-art-resources")
+        fileset(dir: "$androidHome/device-art-resources")
       }
 
       dir("jps") {
index 3682b874d72af36962e845ee4e5211f4d1e0aced..f228453fc21eb55ae8fc6dfc183cdfbbfb5ec605 100644 (file)
@@ -28,18 +28,14 @@ import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleUtilCore;
 import com.intellij.openapi.project.DumbService;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.ProjectFileIndex;
-import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.ClassUtil;
 import com.intellij.psi.util.PsiClassUtil;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtilCore;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -188,7 +184,6 @@ public class JavaExecutionUtil {
     return name == null || name.startsWith(ExecutionBundle.message("run.configuration.unnamed.name.prefix"));
   }
 
-  @Nullable
   public static Location stepIntoSingleClass(@NotNull final Location location) {
     PsiElement element = location.getPsiElement();
     if (!(element instanceof PsiClassOwner)) {
@@ -196,11 +191,6 @@ public class JavaExecutionUtil {
       element = PsiTreeUtil.getParentOfType(element, PsiClassOwner.class);
       if (element == null) return location;
     }
-    final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
-    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(location.getProject()).getFileIndex();
-    if (virtualFile == null || !fileIndex.isInSource(virtualFile)) {
-      return null;
-    }
     final PsiClassOwner psiFile = (PsiClassOwner)element;
     final PsiClass[] classes = psiFile.getClasses();
     if (classes.length != 1) return location;
index 388c819d202a35315f7ddd66349a118add012722..c214f2fa2ae8fe02f81d158421b8ff0d801bbe24 100644 (file)
@@ -48,6 +48,7 @@ import com.intellij.psi.util.*;
 import com.intellij.util.ObjectUtils;
 import com.intellij.util.containers.MostlySingularMultiMap;
 import gnu.trove.THashMap;
+import gnu.trove.THashSet;
 import gnu.trove.TObjectIntHashMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -88,6 +89,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
     }
   };
   private final Map<PsiClass, MostlySingularMultiMap<MethodSignature, PsiMethod>> myDuplicateMethods = new THashMap<>();
+  private final Set<PsiClass> myOverrideEquivalentMethodsVisitedClasses = new THashSet<>();
   private LanguageLevel myLanguageLevel;
   private JavaSdkVersion myJavaSdkVersion;
 
@@ -194,6 +196,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
       myFile = null;
       myHolder = null;
       myDuplicateMethods.clear();
+      myOverrideEquivalentMethodsVisitedClasses.clear();
     }
 
     return success;
@@ -896,6 +899,10 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
       if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkMethodMustHaveBody(method, aClass));
       if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkConstructorCallsBaseClassConstructor(method, myRefCountHolder, myResolveHelper));
       if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkStaticMethodOverride(method,myFile));
+      if (!myHolder.hasErrorResults() && aClass != null &&
+          myOverrideEquivalentMethodsVisitedClasses.add(aClass)) {
+        myHolder.addAll(GenericsHighlightUtil.checkOverrideEquivalentMethods(aClass));
+      }
     }
     else if (parent instanceof PsiClass) {
       PsiClass aClass = (PsiClass)parent;
@@ -909,7 +916,9 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
           myHolder.add(HighlightClassUtil.checkClassDoesNotCallSuperConstructorOrHandleExceptions(aClass, myRefCountHolder, myResolveHelper));
         }
         if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkOverrideEquivalentInheritedMethods(aClass, myFile, myLanguageLevel));
-        if (!myHolder.hasErrorResults()) myHolder.addAll(GenericsHighlightUtil.checkOverrideEquivalentMethods(aClass));
+        if (!myHolder.hasErrorResults() && myOverrideEquivalentMethodsVisitedClasses.add(aClass)) {
+          myHolder.addAll(GenericsHighlightUtil.checkOverrideEquivalentMethods(aClass));
+        }
         if (!myHolder.hasErrorResults()) myHolder.add(HighlightClassUtil.checkCyclicInheritance(aClass));
       }
       catch (IndexNotReadyException ignored) {
@@ -1067,7 +1076,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
       }
     }
 
-    if (parent instanceof PsiAnonymousClass && ref.equals(((PsiAnonymousClass)parent).getBaseClassReference())) {
+    if (parent instanceof PsiAnonymousClass && ref.equals(((PsiAnonymousClass)parent).getBaseClassReference()) &&
+        myOverrideEquivalentMethodsVisitedClasses.add((PsiClass)parent)) {
       PsiClass aClass = (PsiClass)parent;
       myHolder.addAll(GenericsHighlightUtil.checkOverrideEquivalentMethods(aClass));
     }
diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaModuleNameIndex.java b/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaModuleNameIndex.java
new file mode 100644 (file)
index 0000000..ea77bd1
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ * 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.
+ */
+
+/*
+ * @author max
+ */
+package com.intellij.psi.impl.java.stubs.index;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiJavaModule;
+import com.intellij.psi.impl.search.JavaSourceFilterScope;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.stubs.StringStubIndexExtension;
+import com.intellij.psi.stubs.StubIndex;
+import com.intellij.psi.stubs.StubIndexKey;
+import com.intellij.util.indexing.FileBasedIndex;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+public class JavaModuleNameIndex extends StringStubIndexExtension<PsiJavaModule> {
+  private static final JavaModuleNameIndex ourInstance = new JavaModuleNameIndex();
+
+  public static JavaModuleNameIndex getInstance() {
+    return ourInstance;
+  }
+
+  @Override
+  public int getVersion() {
+    return super.getVersion() + (FileBasedIndex.ourEnableTracingOfKeyHashToVirtualFileMapping ? 2 : 0);
+  }
+
+  @NotNull
+  @Override
+  public StubIndexKey<String, PsiJavaModule> getKey() {
+    return JavaStubIndexKeys.MODULE_NAMES;
+  }
+
+  @Override
+  public Collection<PsiJavaModule> get(@NotNull String name, @NotNull Project project, @NotNull GlobalSearchScope scope) {
+    return StubIndex.getElements(getKey(), name, project, new JavaSourceFilterScope(scope), PsiJavaModule.class);
+  }
+
+  @Override
+  public boolean traceKeyHashToVirtualFileMapping() {
+    return FileBasedIndex.ourEnableTracingOfKeyHashToVirtualFileMapping;
+  }
+}
\ No newline at end of file
index ece69327e408f17811df24085f5c0121962aa88f..7811ea8626d54b54259fba43d297d0050ba7edf7 100644 (file)
@@ -38,7 +38,7 @@ import static com.intellij.psi.compiled.ClassFileDecompilers.Full;
 public class ClassFileStubBuilder implements BinaryFileStubBuilder {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.compiled.ClassFileStubBuilder");
 
-  public static final int STUB_VERSION = 15;
+  public static final int STUB_VERSION = 17;
 
   @Override
   public boolean acceptsFile(@NotNull VirtualFile file) {
index 12d9fa439822257c50ff6c2ac8e9f9383f48112c..784d0a03042a15312f7784103f0c2134fbc72eab 100644 (file)
@@ -34,7 +34,6 @@ 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.Computable;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.ModificationTracker;
 import com.intellij.openapi.util.Pair;
@@ -46,7 +45,7 @@ import com.intellij.psi.compiled.ClassFileDecompilers;
 import com.intellij.psi.impl.DebugUtil;
 import com.intellij.psi.impl.JavaPsiImplementationHelper;
 import com.intellij.psi.impl.PsiFileEx;
-import com.intellij.psi.impl.java.stubs.PsiClassStub;
+import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
 import com.intellij.psi.impl.java.stubs.PsiJavaFileStub;
 import com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl;
 import com.intellij.psi.impl.source.PsiFileImpl;
@@ -64,7 +63,7 @@ import com.intellij.psi.util.CachedValuesManager;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.reference.SoftReference;
 import com.intellij.util.ArrayUtil;
-import com.intellij.util.Function;
+import com.intellij.util.BitUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.cls.ClsFormatException;
 import org.jetbrains.annotations.NonNls;
@@ -72,10 +71,10 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.org.objectweb.asm.Attribute;
 import org.jetbrains.org.objectweb.asm.ClassReader;
+import org.jetbrains.org.objectweb.asm.Opcodes;
 
 import java.io.IOException;
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -100,7 +99,6 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
   private volatile SoftReference<StubTree> myStub;
   private volatile TreeElement myMirrorFileElement;
   private volatile ClsPackageStatementImpl myPackageStatement;
-  private volatile LanguageLevel myLanguageLevel;
   private boolean myIsPhysical = true;
   private boolean myInvalidated;
 
@@ -167,7 +165,14 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
   @Override
   @NotNull
   public PsiElement[] getChildren() {
-    return getClasses(); // TODO : package statement?
+    PsiJavaModule module = getModuleDeclaration();
+    if (module != null) {
+      return new PsiElement[]{module};
+    }
+    else {
+      PsiPackageStatement pkg = getPackageStatement();
+      return pkg != null ? ArrayUtil.prepend(pkg, getClasses(), PsiElement.class) : getClasses();
+    }
   }
 
   @Override
@@ -178,11 +183,41 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
 
   @Override
   public PsiPackageStatement getPackageStatement() {
-    getStub(); // Make sure myPackageStatement initializes.
-
     ClsPackageStatementImpl statement = myPackageStatement;
-    if (statement == null) statement = new ClsPackageStatementImpl(this);
-    return statement.getPackageName() != null ? statement : null;
+    if (statement == null) {
+      statement = ClsPackageStatementImpl.NULL_PACKAGE;
+      PsiClassHolderFileStub<?> stub = getStub();
+      if (!(stub instanceof PsiJavaFileStub) || stub.findChildStubByType(JavaStubElementTypes.MODULE) == null) {
+        String packageName = findPackageName(stub);
+        if (packageName != null) {
+          statement = new ClsPackageStatementImpl(this, packageName);
+        }
+      }
+      myPackageStatement = statement;
+    }
+    return statement != ClsPackageStatementImpl.NULL_PACKAGE ? statement : null;
+  }
+
+  private static String findPackageName(PsiClassHolderFileStub<?> stub) {
+    String packageName = null;
+
+    if (stub instanceof PsiJavaFileStub) {
+      packageName = ((PsiJavaFileStub)stub).getPackageName();
+    }
+    else {
+      PsiClass[] psiClasses = stub.getClasses();
+      if (psiClasses.length > 0) {
+        String className = psiClasses[0].getQualifiedName();
+        if (className != null) {
+          int index = className.lastIndexOf('.');
+          if (index >= 0) {
+            packageName = className.substring(0, index);
+          }
+        }
+      }
+    }
+
+    return !StringUtil.isEmpty(packageName) ? packageName : null;
   }
 
   @Override
@@ -244,23 +279,21 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
   @Override
   @NotNull
   public LanguageLevel getLanguageLevel() {
-    LanguageLevel level = myLanguageLevel;
-    if (level == null) {
-      List classes = ApplicationManager.getApplication().runReadAction(new Computable<List>() {
-        @Override
-        public List compute() {
-          return getStub().getChildrenStubs();
-        }
-      });
-      myLanguageLevel = level = !classes.isEmpty() ? ((PsiClassStub<?>)classes.get(0)).getLanguageLevel() : LanguageLevel.HIGHEST;
+    PsiClassHolderFileStub<?> stub = getStub();
+    if (stub instanceof PsiJavaFileStub) {
+      LanguageLevel level = ((PsiJavaFileStub)stub).getLanguageLevel();
+      if (level != null) {
+        return level;
+      }
     }
-    return level;
+    return LanguageLevel.HIGHEST;
   }
 
   @Nullable
   @Override
   public PsiJavaModule getModuleDeclaration() {
-    return null;
+    PsiClassHolderFileStub<?> stub = getStub();
+    return stub instanceof PsiJavaFileStub ? ((PsiJavaFileStub)stub).getModule() : null;
   }
 
   @Override
@@ -282,11 +315,17 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
   public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
     buffer.append(BANNER);
 
-    appendText(getPackageStatement(), 0, buffer, "\n\n");
+    PsiJavaModule module = getModuleDeclaration();
+    if (module != null) {
+      appendText(module, 0, buffer);
+    }
+    else {
+      appendText(getPackageStatement(), 0, buffer, "\n\n");
 
-    PsiClass[] classes = getClasses();
-    if (classes.length > 0) {
-      appendText(classes[0], 0, buffer);
+      PsiClass[] classes = getClasses();
+      if (classes.length > 0) {
+        appendText(classes[0], 0, buffer);
+      }
     }
   }
 
@@ -298,13 +337,19 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
     }
 
     PsiJavaFile mirrorFile = (PsiJavaFile)mirrorElement;
-    setMirrorIfPresent(getPackageStatement(), mirrorFile.getPackageStatement());
-    setMirrors(getClasses(), mirrorFile.getClasses());
+    PsiJavaModule module = getModuleDeclaration();
+    if (module != null) {
+      setMirror(module, mirrorFile.getModuleDeclaration());
+    }
+    else {
+      setMirrorIfPresent(getPackageStatement(), mirrorFile.getPackageStatement());
+      setMirrors(getClasses(), mirrorFile.getClasses());
+    }
   }
 
-  @SuppressWarnings("deprecation")
   @Override
   @NotNull
+  @SuppressWarnings("deprecation")
   public PsiElement getNavigationElement() {
     for (ClsCustomNavigationPolicy customNavigationPolicy : Extensions.getExtensions(ClsCustomNavigationPolicy.EP_NAME)) {
       if (customNavigationPolicy instanceof ClsCustomNavigationPolicyEx) {
@@ -535,14 +580,11 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
       }
     }
 
-    ClsPackageStatementImpl packageStatement = new ClsPackageStatementImpl(this);
     synchronized (myMirrorLock) {
       putUserData(CLS_DOCUMENT_LINK_KEY, null);
       myMirrorFileElement = null;
-      myPackageStatement = packageStatement;
+      myPackageStatement = null;
     }
-
-    myLanguageLevel = null;
   }
 
   @Override
@@ -590,18 +632,6 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
 
   @Nullable
   public static PsiJavaFileStub buildFileStub(@NotNull VirtualFile file, @NotNull byte[] bytes) throws ClsFormatException {
-    return buildFileStub(file, bytes, new Function<String, PsiJavaFileStub>() {
-      @Override
-      public PsiJavaFileStub fun(String packageName) {
-        return new PsiJavaFileStubImpl(packageName, true);
-      }
-    });
-  }
-
-  @Nullable
-  public static PsiJavaFileStub buildFileStub(@NotNull VirtualFile file,
-                                              @NotNull byte[] bytes,
-                                              @NotNull Function<String, PsiJavaFileStub> stubBuilder) throws ClsFormatException {
     try {
       if (ClassFileViewProvider.isInnerClass(file, bytes)) {
         return null;
@@ -609,21 +639,29 @@ public class ClsFileImpl extends ClsRepositoryPsiElement<PsiClassHolderFileStub>
 
       ClassReader reader = new ClassReader(bytes);
       String className = file.getNameWithoutExtension();
-      String packageName = getPackageName(reader.getClassName());
-      PsiJavaFileStub stub = stubBuilder.fun(packageName);
-
-      try {
-        FileContentPair source = new FileContentPair(file, bytes);
-        StubBuildingVisitor<FileContentPair> visitor = new StubBuildingVisitor<FileContentPair>(source, STRATEGY, stub, 0, className);
+      String internalName = reader.getClassName();
+      boolean module = internalName.endsWith("/module-info") && BitUtil.isSet(reader.getAccess(), Opcodes.ACC_MODULE);
+      String packageName = getPackageName(internalName);
+      LanguageLevel level = ClsParsingUtil.getLanguageLevelByVersion(reader.readShort(6));
+
+      if (module) {
+        PsiJavaFileStub stub = new PsiJavaFileStubImpl(null, "", level, true);
+        ModuleStubBuildingVisitor visitor = new ModuleStubBuildingVisitor(stub, packageName);
         reader.accept(visitor, EMPTY_ATTRIBUTES, ClassReader.SKIP_FRAMES);
-        PsiClassStub<?> result = visitor.getResult();
-        if (result == null) return null;
+        if (visitor.getResult() != null) return stub;
       }
-      catch (OutOfOrderInnerClassException e) {
-        return null;
+      else {
+        PsiJavaFileStub stub = new PsiJavaFileStubImpl(null, packageName, level, true);
+        try {
+          FileContentPair source = new FileContentPair(file, bytes);
+          StubBuildingVisitor<FileContentPair> visitor = new StubBuildingVisitor<FileContentPair>(source, STRATEGY, stub, 0, className);
+          reader.accept(visitor, EMPTY_ATTRIBUTES, ClassReader.SKIP_FRAMES);
+          if (visitor.getResult() != null) return stub;
+        }
+        catch (OutOfOrderInnerClassException ignored) { }
       }
 
-      return stub;
+      return null;
     }
     catch (Exception e) {
       throw new ClsFormatException(file.getPath() + ": " + e.getMessage(), e);
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleImpl.java
new file mode 100644 (file)
index 0000000..fc5d490
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ * 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 com.intellij.psi.impl.compiled;
+
+import com.intellij.psi.JavaElementVisitor;
+import com.intellij.psi.PsiElementVisitor;
+import com.intellij.psi.PsiJavaModule;
+import com.intellij.psi.PsiJavaModuleReference;
+import com.intellij.psi.impl.java.stubs.PsiJavaModuleStub;
+import com.intellij.psi.impl.source.SourceTreeToPsiMap;
+import com.intellij.psi.impl.source.tree.JavaElementType;
+import com.intellij.psi.impl.source.tree.TreeElement;
+import org.jetbrains.annotations.NotNull;
+
+public class ClsJavaModuleImpl extends ClsRepositoryPsiElement<PsiJavaModuleStub> implements PsiJavaModule {
+  private PsiJavaModuleReference myReference;
+
+  public ClsJavaModuleImpl(PsiJavaModuleStub stub) {
+    super(stub);
+    myReference = new ClsJavaModuleReferenceImpl(this, stub.getName());
+  }
+
+  @NotNull
+  @Override
+  public PsiJavaModuleReference getNameElement() {
+    return myReference;
+  }
+
+  @NotNull
+  @Override
+  public String getModuleName() {
+    return myReference.getReferenceText();
+  }
+
+  @Override
+  public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
+    buffer.append("module ").append(getModuleName()).append(" { /* compiled code */ }");
+  }
+
+  @Override
+  public void setMirror(@NotNull TreeElement element) throws InvalidMirrorException {
+    setMirrorCheckingType(element, JavaElementType.MODULE);
+    setMirror(getNameElement(), SourceTreeToPsiMap.<PsiJavaModule>treeToPsiNotNull(element).getNameElement());
+  }
+
+  @Override
+  public void accept(@NotNull PsiElementVisitor visitor) {
+    if (visitor instanceof JavaElementVisitor) {
+      ((JavaElementVisitor)visitor).visitModule(this);
+    }
+    else {
+      visitor.visitElement(this);
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "PsiJavaModule:" + getModuleName();
+  }
+}
\ No newline at end of file
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleReferenceImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsJavaModuleReferenceImpl.java
new file mode 100644 (file)
index 0000000..d290f3a
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ * 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 com.intellij.psi.impl.compiled;
+
+import com.intellij.psi.JavaElementVisitor;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiElementVisitor;
+import com.intellij.psi.PsiJavaModuleReference;
+import com.intellij.psi.impl.source.tree.JavaElementType;
+import com.intellij.psi.impl.source.tree.TreeElement;
+import org.jetbrains.annotations.NotNull;
+
+public class ClsJavaModuleReferenceImpl extends ClsElementImpl implements PsiJavaModuleReference {
+  private final PsiElement myParent;
+  private final String myText;
+
+  public ClsJavaModuleReferenceImpl(PsiElement parent, String text) {
+    myParent = parent;
+    myText = text;
+  }
+
+  @NotNull
+  @Override
+  public PsiElement[] getChildren() {
+    return EMPTY_ARRAY;
+  }
+
+  @Override
+  public PsiElement getParent() {
+    return myParent;
+  }
+
+  @Override
+  public void appendMirrorText(int indentLevel, @NotNull StringBuilder buffer) {
+    buffer.append(getReferenceText());
+  }
+
+  @Override
+  public void setMirror(@NotNull TreeElement element) throws InvalidMirrorException {
+    setMirrorCheckingType(element, JavaElementType.MODULE_REFERENCE);
+  }
+
+  @NotNull
+  @Override
+  public String getReferenceText() {
+    return myText;
+  }
+
+  @Override
+  public void accept(@NotNull PsiElementVisitor visitor) {
+    if (visitor instanceof JavaElementVisitor) {
+      ((JavaElementVisitor)visitor).visitModuleReference(this);
+    }
+    else {
+      visitor.visitElement(this);
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "PsiJavaModuleReference";
+  }
+}
\ No newline at end of file
index 91218800cac53b82a23c2ab8fd864e5ef8571830..c9ad69e988173b7a7dfb126fbc44f4168d140629 100644 (file)
@@ -21,22 +21,18 @@ import com.intellij.psi.impl.source.tree.TreeElement;
 import org.jetbrains.annotations.NotNull;
 
 class ClsPackageStatementImpl extends ClsElementImpl implements PsiPackageStatement {
+  static ClsPackageStatementImpl NULL_PACKAGE = new ClsPackageStatementImpl();
+
   private final ClsFileImpl myFile;
   private final String myPackageName;
 
-  public ClsPackageStatementImpl(@NotNull ClsFileImpl file) {
+  private ClsPackageStatementImpl() {
+    myFile = null;
+    myPackageName = null;
+  }
+
+  public ClsPackageStatementImpl(@NotNull ClsFileImpl file, String packageName) {
     myFile = file;
-    String packageName = null;
-    PsiClass[] psiClasses = file.getClasses();
-    if (psiClasses.length > 0) {
-      String className = psiClasses[0].getQualifiedName();
-      if (className != null) {
-        int index = className.lastIndexOf('.');
-        if (index >= 0) {
-          packageName = className.substring(0, index);
-        }
-      }
-    }
     myPackageName = packageName;
   }
 
@@ -69,7 +65,7 @@ class ClsPackageStatementImpl extends ClsElementImpl implements PsiPackageStatem
   @Override
   public void appendMirrorText(final int indentLevel, @NotNull final StringBuilder buffer) {
     if (myPackageName != null) {
-      buffer.append("package ").append(getPackageName()).append(";");
+      buffer.append("package ").append(getPackageName()).append(';');
     }
   }
 
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ModuleStubBuildingVisitor.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ModuleStubBuildingVisitor.java
new file mode 100644 (file)
index 0000000..e6e3888
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ * 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 com.intellij.psi.impl.compiled;
+
+import com.intellij.psi.impl.java.stubs.PsiJavaFileStub;
+import com.intellij.psi.impl.java.stubs.PsiJavaModuleStub;
+import com.intellij.psi.impl.java.stubs.impl.PsiJavaModuleStubImpl;
+import org.jetbrains.org.objectweb.asm.ClassVisitor;
+import org.jetbrains.org.objectweb.asm.ModuleVisitor;
+import org.jetbrains.org.objectweb.asm.Opcodes;
+
+public class ModuleStubBuildingVisitor extends ClassVisitor {
+  private final PsiJavaFileStub myParent;
+  private final String myModuleName;
+  private PsiJavaModuleStub myResult;
+
+  public ModuleStubBuildingVisitor(PsiJavaFileStub parent, String moduleName) {
+    super(Opcodes.ASM6);
+    myParent = parent;
+    myModuleName = moduleName;
+  }
+
+  public PsiJavaModuleStub getResult() {
+    return myResult;
+  }
+
+  @Override
+  public ModuleVisitor visitModule() {
+    myResult = new PsiJavaModuleStubImpl(myParent, myModuleName);
+    return null;
+  }
+}
\ No newline at end of file
index 7b2f38baa8b3153773a6e6e359feb21d5203fa95..3ecf64d24ab1e05a7d7c5a55977c5eab2872b6a0 100644 (file)
@@ -108,10 +108,6 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
     byte stubFlags = PsiClassStubImpl.packFlags(isDeprecated, isInterface, isEnum, false, false, isAnnotationType, false, false);
     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));
 
     ClassInfo info = null;
index 112b75a7bf120d66f0fde33c8a3e71772db2d991..fedd8d58a9eeac80f57e015bbe2d74bb4d2d6cac 100644 (file)
@@ -21,6 +21,7 @@ package com.intellij.psi.impl.java.stubs;
 
 import com.intellij.psi.*;
 import com.intellij.psi.impl.compiled.*;
+import com.intellij.psi.impl.compiled.ClsJavaModuleImpl;
 
 public class ClsStubPsiFactory extends StubPsiFactory {
   public static final ClsStubPsiFactory INSTANCE = new ClsStubPsiFactory();
@@ -99,4 +100,9 @@ public class ClsStubPsiFactory extends StubPsiFactory {
   public PsiNameValuePair createNameValuePair(PsiNameValuePairStub stub) {
     return null; // todo
   }
+
+  @Override
+  public PsiJavaModule createModule(PsiJavaModuleStub stub) {
+    return new ClsJavaModuleImpl(stub);
+  }
 }
\ No newline at end of file
index 688a6b0b58ffad5d7e0b974773c3a2b6877a4320..db62d0b4554d660ed9372ef180b9da33b2ef3d7c 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.psi.impl.java.stubs;
 import com.intellij.lang.ASTNode;
 import com.intellij.lang.LighterAST;
 import com.intellij.lang.LighterASTNode;
-import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.JavaTokenType;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiNameHelper;
@@ -39,7 +38,6 @@ import com.intellij.psi.stubs.StubInputStream;
 import com.intellij.psi.stubs.StubOutputStream;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.util.io.StringRef;
-import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.IOException;
@@ -48,7 +46,7 @@ import java.io.IOException;
  * @author max
  */
 public abstract class JavaClassElementType extends JavaStubElementType<PsiClassStub, PsiClass> {
-  public JavaClassElementType(@NotNull @NonNls final String id) {
+  public JavaClassElementType(@NotNull String id) {
     super(id);
   }
 
@@ -148,12 +146,11 @@ public abstract class JavaClassElementType extends JavaStubElementType<PsiClassS
   }
 
   @Override
-  public void serialize(@NotNull final PsiClassStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
+  public void serialize(@NotNull PsiClassStub stub, @NotNull StubOutputStream dataStream) throws IOException {
     dataStream.writeByte(((PsiClassStubImpl)stub).getFlags());
     if (!stub.isAnonymous()) {
       dataStream.writeName(stub.getName());
       dataStream.writeName(stub.getQualifiedName());
-      dataStream.writeByte(stub.getLanguageLevel().ordinal());
       dataStream.writeName(stub.getSourceFileName());
     }
     else {
@@ -163,7 +160,7 @@ public abstract class JavaClassElementType extends JavaStubElementType<PsiClassS
 
   @NotNull
   @Override
-  public PsiClassStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
+  public PsiClassStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
     byte flags = dataStream.readByte();
     boolean isAnonymous = PsiClassStubImpl.isAnonymous(flags);
     boolean isEnumConst = PsiClassStubImpl.isEnumConstInitializer(flags);
@@ -172,11 +169,9 @@ public abstract class JavaClassElementType extends JavaStubElementType<PsiClassS
     if (!isAnonymous) {
       StringRef name = dataStream.readName();
       StringRef qname = dataStream.readName();
-      int languageLevelId = dataStream.readByte();
       StringRef sourceFileName = dataStream.readName();
       PsiClassStubImpl classStub = new PsiClassStubImpl(type, parentStub, StringRef.toString(qname), StringRef.toString(name), null, flags);
-      classStub.setLanguageLevel(LanguageLevel.values()[languageLevelId]);
-      classStub.setSourceFileName(sourceFileName);
+      classStub.setSourceFileName(StringRef.toString(sourceFileName));
       return classStub;
     }
     else {
@@ -186,7 +181,7 @@ public abstract class JavaClassElementType extends JavaStubElementType<PsiClassS
   }
 
   @Override
-  public void indexStub(@NotNull final PsiClassStub stub, @NotNull final IndexSink sink) {
+  public void indexStub(@NotNull PsiClassStub stub, @NotNull IndexSink sink) {
     boolean isAnonymous = stub.isAnonymous();
     if (isAnonymous) {
       String baseRef = stub.getBaseClassReferenceText();
@@ -212,4 +207,4 @@ public abstract class JavaClassElementType extends JavaStubElementType<PsiClassS
     final String name = stub.getName();
     return name != null ? name : super.getId(stub);
   }
-}
+}
\ No newline at end of file
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaModuleElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaModuleElementType.java
new file mode 100644 (file)
index 0000000..8206720
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ * 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 com.intellij.psi.impl.java.stubs;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.lang.LighterAST;
+import com.intellij.lang.LighterASTNode;
+import com.intellij.psi.PsiJavaModule;
+import com.intellij.psi.impl.java.stubs.impl.PsiJavaModuleStubImpl;
+import com.intellij.psi.impl.java.stubs.index.JavaStubIndexKeys;
+import com.intellij.psi.impl.source.PsiJavaModuleImpl;
+import com.intellij.psi.impl.source.tree.CompositeElement;
+import com.intellij.psi.impl.source.tree.JavaElementType;
+import com.intellij.psi.impl.source.tree.JavaSourceUtil;
+import com.intellij.psi.impl.source.tree.LightTreeUtil;
+import com.intellij.psi.stubs.IndexSink;
+import com.intellij.psi.stubs.StubElement;
+import com.intellij.psi.stubs.StubInputStream;
+import com.intellij.psi.stubs.StubOutputStream;
+import com.intellij.util.io.StringRef;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.IOException;
+
+public class JavaModuleElementType extends JavaStubElementType<PsiJavaModuleStub, PsiJavaModule> {
+  public JavaModuleElementType() {
+    super("MODULE");
+  }
+
+  @NotNull
+  @Override
+  public ASTNode createCompositeNode() {
+    return new CompositeElement(this);
+  }
+
+  @Override
+  public PsiJavaModule createPsi(@NotNull PsiJavaModuleStub stub) {
+    return getPsiFactory(stub).createModule(stub);
+  }
+
+  @Override
+  public PsiJavaModule createPsi(@NotNull ASTNode node) {
+    return new PsiJavaModuleImpl(node);
+  }
+
+  @Override
+  public PsiJavaModuleStub createStub(LighterAST tree, LighterASTNode node, StubElement parentStub) {
+    LighterASTNode ref = LightTreeUtil.requiredChildOfType(tree, node, JavaElementType.MODULE_REFERENCE);
+    return new PsiJavaModuleStubImpl(parentStub, JavaSourceUtil.getReferenceText(tree, ref));
+  }
+
+  @Override
+  public void serialize(@NotNull PsiJavaModuleStub stub, @NotNull StubOutputStream dataStream) throws IOException {
+    dataStream.writeName(stub.getName());
+  }
+
+  @NotNull
+  @Override
+  public PsiJavaModuleStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
+    String name = StringRef.toString(dataStream.readName());
+    return new PsiJavaModuleStubImpl(parentStub, name);
+  }
+
+  @Override
+  public void indexStub(@NotNull PsiJavaModuleStub stub, @NotNull IndexSink sink) {
+    sink.occurrence(JavaStubIndexKeys.MODULE_NAMES, stub.getName());
+  }
+}
\ No newline at end of file
index 3eaa88c6d8e62014a24bc270ecc3c1e3c1e2e332..03591f90e27e718a159b408a4cae88fb8ffa0156 100644 (file)
@@ -36,6 +36,7 @@ public interface JavaStubElementTypes {
   JavaTypeParameterListElementType TYPE_PARAMETER_LIST = new JavaTypeParameterListElementType();
   JavaClassInitializerElementType CLASS_INITIALIZER = new JavaClassInitializerElementType();
   JavaImportListElementType IMPORT_LIST = new JavaImportListElementType();
+  JavaModuleElementType MODULE = new JavaModuleElementType();
 
   JavaClassElementType CLASS = new JavaClassElementType("CLASS") {
     @NotNull
index 0803c882bb0b5493f1d125574973357b671b4c6b..b2e5df99f54d5b6bcc90da0d259aede55ff5317b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 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.
@@ -21,17 +21,11 @@ package com.intellij.psi.impl.java.stubs;
 
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.PsiClass;
-import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.Nullable;
 
 public interface PsiClassStub<T extends PsiClass> extends PsiMemberStub<T> {
-  @NonNls
-  @Nullable
-  String getQualifiedName();
-
-  @NonNls 
-  @Nullable
-  String getBaseClassReferenceText();
+  @Nullable String getQualifiedName();
+  @Nullable String getBaseClassReferenceText();
 
   boolean hasDeprecatedAnnotation();
   boolean isInterface();
@@ -41,6 +35,8 @@ public interface PsiClassStub<T extends PsiClass> extends PsiMemberStub<T> {
   boolean isAnonymousInQualifiedNew();
   boolean isAnnotationType();
 
+  @Nullable String getSourceFileName();
+
+  /** @deprecated use {@link PsiJavaFileStub#getLanguageLevel()} (to be removed in IDEA 18) */
   LanguageLevel getLanguageLevel();
-  String getSourceFileName();
 }
\ No newline at end of file
index d1b8242dd53708de6e663390683fb76fd3c0c907..b4d081513d491a900adf6b2ef0b0cfb096d5a8aa 100644 (file)
  */
 package com.intellij.psi.impl.java.stubs;
 
+import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.PsiJavaFile;
+import com.intellij.psi.PsiJavaModule;
 import com.intellij.psi.stubs.PsiClassHolderFileStub;
 
 public interface PsiJavaFileStub extends PsiClassHolderFileStub<PsiJavaFile> {
+  PsiJavaModule getModule();
+
   String getPackageName();
+  LanguageLevel getLanguageLevel();
   boolean isCompiled();
+
   StubPsiFactory getPsiFactory();
 
-  /** @deprecated override {@link #getPsiFactory()} instead (to be removed in IDEA 17) */
+  /** @deprecated override {@link #getPsiFactory()} instead (to be removed in IDEA 18) */
   @SuppressWarnings("unused")
   void setPsiFactory(StubPsiFactory factory);
 }
\ No newline at end of file
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/PsiJavaModuleStub.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/PsiJavaModuleStub.java
new file mode 100644 (file)
index 0000000..3a301c8
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ * 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 com.intellij.psi.impl.java.stubs;
+
+import com.intellij.psi.PsiJavaModule;
+import com.intellij.psi.stubs.StubElement;
+
+public interface PsiJavaModuleStub extends StubElement<PsiJavaModule> {
+  String getName();
+}
\ No newline at end of file
index 945f1360a5d5e289c7491d3124443fd52b2b2a39..453cbbfc0a27e9fec51664dc0c88a90bf58368c9 100644 (file)
@@ -111,4 +111,9 @@ public class SourceStubPsiFactory extends StubPsiFactory {
   public PsiNameValuePair createNameValuePair(PsiNameValuePairStub stub) {
     return new PsiNameValuePairImpl(stub);
   }
+
+  @Override
+  public PsiJavaModule createModule(PsiJavaModuleStub stub) {
+    return new PsiJavaModuleImpl(stub);
+  }
 }
\ No newline at end of file
index 5b733ceffc6d83b9461007aa7c581fdb43df3f6a..40a23f5b48c7960f713f8f2157d01250e6f4cc49 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 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.
@@ -51,4 +51,8 @@ public abstract class StubPsiFactory {
   public abstract PsiAnnotationParameterList createAnnotationParameterList(PsiAnnotationParameterListStub stub);
 
   public abstract PsiNameValuePair createNameValuePair(PsiNameValuePairStub stub);
-}
+
+  public PsiJavaModule createModule(PsiJavaModuleStub stub) {
+    return null;
+  }
+}
\ No newline at end of file
index 9bfeb7def65873772c3244c94ec997c35315b00c..da7edfa9ec1181dffa644e3d1dbfaf4b6b851e56 100644 (file)
@@ -21,21 +21,16 @@ import com.intellij.psi.PsiClass;
 import com.intellij.psi.impl.DebugUtil;
 import com.intellij.psi.impl.java.stubs.JavaClassElementType;
 import com.intellij.psi.impl.java.stubs.PsiClassStub;
+import com.intellij.psi.impl.java.stubs.PsiJavaFileStub;
 import com.intellij.psi.stubs.StubBase;
 import com.intellij.psi.stubs.StubElement;
 import com.intellij.util.BitUtil;
-import com.intellij.util.io.StringRef;
 import org.jetbrains.annotations.Nullable;
 
 /**
  * @author max
  */
 public class PsiClassStubImpl<T extends PsiClass> extends StubBase<T> implements PsiClassStub<T> {
-  private final String myQualifiedName;
-  private final String myName;
-  private final String myBaseRefText;
-  private final byte myFlags;
-
   private static final int DEPRECATED = 0x01;
   private static final int INTERFACE = 0x02;
   private static final int ENUM = 0x04;
@@ -45,8 +40,11 @@ public class PsiClassStubImpl<T extends PsiClass> extends StubBase<T> implements
   private static final int IN_QUALIFIED_NEW = 0x40;
   private static final int DEPRECATED_ANNOTATION = 0x80;
 
-  private LanguageLevel myLanguageLevel;
-  private StringRef mySourceFileName;
+  private final String myQualifiedName;
+  private final String myName;
+  private final String myBaseRefText;
+  private final byte myFlags;
+  private String mySourceFileName;
 
   public PsiClassStubImpl(final JavaClassElementType type,
                           final StubElement parent,
@@ -125,26 +123,25 @@ public class PsiClassStubImpl<T extends PsiClass> extends StubBase<T> implements
 
   @Override
   public LanguageLevel getLanguageLevel() {
-    return myLanguageLevel != null ? myLanguageLevel : LanguageLevel.HIGHEST;
+    StubElement parent = getParentStub();
+    if (parent instanceof PsiJavaFileStub) {
+      LanguageLevel level = ((PsiJavaFileStub)parent).getLanguageLevel();
+      if (level != null) {
+        return level;
+      }
+    }
+    return LanguageLevel.HIGHEST;
   }
 
   @Override
   public String getSourceFileName() {
-    return StringRef.toString(mySourceFileName);
-  }
-
-  public void setLanguageLevel(final LanguageLevel languageLevel) {
-    myLanguageLevel = languageLevel;
+    return mySourceFileName;
   }
 
-  public void setSourceFileName(final StringRef sourceFileName) {
+  public void setSourceFileName(String sourceFileName) {
     mySourceFileName = sourceFileName;
   }
 
-  public void setSourceFileName(final String sourceFileName) {
-    mySourceFileName = StringRef.fromString(sourceFileName);
-  }
-
   @Override
   public boolean isAnonymousInQualifiedNew() {
     return BitUtil.isSet(myFlags, IN_QUALIFIED_NEW);
@@ -174,7 +171,8 @@ public class PsiClassStubImpl<T extends PsiClass> extends StubBase<T> implements
     return flags;
   }
 
-  @SuppressWarnings({"HardCodedStringLiteral"})
+  @Override
+  @SuppressWarnings("SpellCheckingInspection")
   public String toString() {
     StringBuilder builder = new StringBuilder();
     builder.append("PsiClassStub[");
index 19bf0e6080c761f4bffc0f4b638f0010b190adb8..7e18926a6946692cf2f376cb5cb2707ca32b179d 100644 (file)
  */
 package com.intellij.psi.impl.java.stubs.impl;
 
+import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiJavaFile;
+import com.intellij.psi.PsiJavaModule;
 import com.intellij.psi.impl.java.stubs.*;
 import com.intellij.psi.stubs.PsiFileStubImpl;
+import com.intellij.psi.stubs.StubElement;
 import com.intellij.psi.tree.IStubFileElementType;
-import com.intellij.util.io.StringRef;
 import org.jetbrains.annotations.NotNull;
 
 /**
  * @author max
  */
 public class PsiJavaFileStubImpl extends PsiFileStubImpl<PsiJavaFile> implements PsiJavaFileStub {
-  private final StringRef myPackageName;
+  private final String myPackageName;
+  private final LanguageLevel myLanguageLevel;
   private final boolean myCompiled;
   private StubPsiFactory myFactory;
 
-  public PsiJavaFileStubImpl(PsiJavaFile file, StringRef packageName, boolean compiled) {
+  public PsiJavaFileStubImpl(String packageName, boolean compiled) {
+    this(null, packageName, null, compiled);
+  }
+
+  public PsiJavaFileStubImpl(PsiJavaFile file, String packageName, LanguageLevel languageLevel, boolean compiled) {
     super(file);
     myPackageName = packageName;
+    myLanguageLevel = languageLevel;
     myCompiled = compiled;
     myFactory = compiled ? ClsStubPsiFactory.INSTANCE : SourceStubPsiFactory.INSTANCE;
   }
 
-  public PsiJavaFileStubImpl(String packageName, boolean compiled) {
-    this(null, StringRef.fromString(packageName), compiled);
-  }
-
   @NotNull
   @Override
   public IStubFileElementType getType() {
@@ -54,9 +58,20 @@ public class PsiJavaFileStubImpl extends PsiFileStubImpl<PsiJavaFile> implements
     return getChildrenByType(JavaStubElementTypes.CLASS, PsiClass.ARRAY_FACTORY);
   }
 
+  @Override
+  public PsiJavaModule getModule() {
+    StubElement<PsiJavaModule> moduleStub = findChildStubByType(JavaStubElementTypes.MODULE);
+    return moduleStub != null ? moduleStub.getPsi() : null;
+  }
+
   @Override
   public String getPackageName() {
-    return StringRef.toString(myPackageName);
+    return myPackageName;
+  }
+
+  @Override
+  public LanguageLevel getLanguageLevel() {
+    return myLanguageLevel;
   }
 
   @Override
@@ -74,11 +89,6 @@ public class PsiJavaFileStubImpl extends PsiFileStubImpl<PsiJavaFile> implements
     myFactory = factory;
   }
 
-  @Override
-  public String toString() {
-    return "PsiJavaFileStub [" + myPackageName + "]";
-  }
-
   @Override
   public boolean equals(Object o) {
     if (this == o) return true;
@@ -88,6 +98,7 @@ public class PsiJavaFileStubImpl extends PsiFileStubImpl<PsiJavaFile> implements
 
     if (myCompiled != stub.myCompiled) return false;
     if (myPackageName != null ? !myPackageName.equals(stub.myPackageName) : stub.myPackageName != null) return false;
+    if (myLanguageLevel != stub.myLanguageLevel) return false;
 
     return true;
   }
@@ -95,7 +106,13 @@ public class PsiJavaFileStubImpl extends PsiFileStubImpl<PsiJavaFile> implements
   @Override
   public int hashCode() {
     int result = myPackageName != null ? myPackageName.hashCode() : 0;
+    result = 31 * result + (myLanguageLevel != null ? myLanguageLevel.hashCode() : 0);
     result = 31 * result + (myCompiled ? 1 : 0);
     return result;
   }
+
+  @Override
+  public String toString() {
+    return "PsiJavaFileStub [" + myPackageName + "]";
+  }
 }
\ No newline at end of file
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiJavaModuleStubImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiJavaModuleStubImpl.java
new file mode 100644 (file)
index 0000000..ad2ccc9
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ * 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 com.intellij.psi.impl.java.stubs.impl;
+
+import com.intellij.psi.PsiJavaModule;
+import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
+import com.intellij.psi.impl.java.stubs.PsiJavaModuleStub;
+import com.intellij.psi.stubs.StubBase;
+import com.intellij.psi.stubs.StubElement;
+
+public class PsiJavaModuleStubImpl extends StubBase<PsiJavaModule> implements PsiJavaModuleStub {
+  private final String myName;
+
+  public PsiJavaModuleStubImpl(StubElement parent, String name) {
+    super(parent, JavaStubElementTypes.MODULE);
+    myName = name;
+  }
+
+  @Override
+  public String getName() {
+    return myName;
+  }
+
+  @Override
+  public String toString() {
+    return "PsiJavaModuleStub:" + getName();
+  }
+}
\ No newline at end of file
index a3e247f73de834f7cc842c906e4abb21f4ecd2af..5d9b78e09ed31becff0fdc6c5fa7d130216347db 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 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.
@@ -31,8 +31,8 @@ public class JavaStubIndexKeys {
   public static final StubIndexKey<String, PsiAnonymousClass> ANONYMOUS_BASEREF = StubIndexKey.createIndexKey("java.anonymous.baseref");
   public static final StubIndexKey<String, PsiMethod> METHOD_TYPES = StubIndexKey.createIndexKey("java.method.parameter.types");
   public static final StubIndexKey<String, PsiClass> CLASS_SHORT_NAMES = StubIndexKey.createIndexKey("java.class.shortname");
-  public static final StubIndexKey<Integer,PsiClass> CLASS_FQN = StubIndexKey.createIndexKey("java.class.fqn");
+  public static final StubIndexKey<Integer, PsiClass> CLASS_FQN = StubIndexKey.createIndexKey("java.class.fqn");
+  public static final StubIndexKey<String, PsiJavaModule> MODULE_NAMES = StubIndexKey.createIndexKey("java.module.name");
 
-  private JavaStubIndexKeys() {
-  }
-}
+  private JavaStubIndexKeys() { }
+}
\ No newline at end of file
index 1cd0803cba7409c4ebdfd8ba09a9bf7b9f730983..324c86edf580fa3017a2fe3400bfa19b9a46f77f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 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.
@@ -38,7 +38,7 @@ import java.io.IOException;
  * @author max
  */
 public class JavaFileElementType extends ILightStubFileElementType<PsiJavaFileStub> {
-  public static final int STUB_VERSION = 24;
+  public static final int STUB_VERSION = 26;
 
   public JavaFileElementType() {
     super("java.FILE", JavaLanguage.INSTANCE);
@@ -92,20 +92,23 @@ public class JavaFileElementType extends ILightStubFileElementType<PsiJavaFileSt
   }
 
   @Override
-  public void serialize(@NotNull final PsiJavaFileStub stub, @NotNull final StubOutputStream dataStream) throws IOException {
+  public void serialize(@NotNull PsiJavaFileStub stub, @NotNull StubOutputStream dataStream) throws IOException {
     dataStream.writeBoolean(stub.isCompiled());
+    LanguageLevel level = stub.getLanguageLevel();
+    dataStream.writeByte(level != null ? level.ordinal() : -1);
     dataStream.writeName(stub.getPackageName());
   }
 
   @NotNull
   @Override
-  public PsiJavaFileStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException {
+  public PsiJavaFileStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
     boolean compiled = dataStream.readBoolean();
-    StringRef packName = dataStream.readName();
-    return new PsiJavaFileStubImpl(null, packName, compiled);
+    int level = dataStream.readByte();
+    StringRef packageName = dataStream.readName();
+    return new PsiJavaFileStubImpl(null, StringRef.toString(packageName), level >= 0 ? LanguageLevel.values()[level] : null, compiled);
   }
 
   @Override
-  public void indexStub(@NotNull final PsiJavaFileStub stub, @NotNull final IndexSink sink) {
-  }
-}
+  @SuppressWarnings("LambdaUnfriendlyMethodOverload")
+  public void indexStub(@NotNull PsiJavaFileStub stub, @NotNull IndexSink sink) { }
+}
\ No newline at end of file
index cd9e053468cd5d2543a81962c279fda097319a0b..3f6b9309f86c16a7931b158f37fe3b09dc25215a 100644 (file)
@@ -28,7 +28,6 @@ import com.intellij.psi.stubs.LightStubBuilder;
 import com.intellij.psi.stubs.StubElement;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.tree.TokenSet;
-import com.intellij.util.io.StringRef;
 import org.jetbrains.annotations.NotNull;
 
 public class JavaLightStubBuilder extends LightStubBuilder {
@@ -47,7 +46,7 @@ public class JavaLightStubBuilder extends LightStubBuilder {
         refText = JavaSourceUtil.getReferenceText(tree, ref);
       }
     }
-    return new PsiJavaFileStubImpl((PsiJavaFile)file, StringRef.fromString(refText), false);
+    return new PsiJavaFileStubImpl((PsiJavaFile)file, refText, null, false);
   }
 
   @Override
@@ -122,6 +121,7 @@ public class JavaLightStubBuilder extends LightStubBuilder {
     private boolean seenNew;
 
     @Override
+    @SuppressWarnings("IfStatementWithIdenticalBranches")
     public boolean visit(IElementType type) {
       if (ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(type)) {
         return true;
@@ -150,4 +150,4 @@ public class JavaLightStubBuilder extends LightStubBuilder {
       return true;
     }
   }
-}
+}
\ No newline at end of file
index fccb8b1202addaf72cda483bbae80ad0bbc5ad0a..1682e574494e63798ed6f85efe958f9f45e090ff 100644 (file)
  */
 package com.intellij.psi.impl.source;
 
+import com.intellij.lang.ASTNode;
 import com.intellij.psi.JavaElementVisitor;
 import com.intellij.psi.PsiElementVisitor;
 import com.intellij.psi.PsiJavaModule;
 import com.intellij.psi.PsiJavaModuleReference;
-import com.intellij.psi.impl.source.tree.CompositePsiElement;
-import com.intellij.psi.impl.source.tree.JavaElementType;
+import com.intellij.psi.impl.java.stubs.JavaStubElementTypes;
+import com.intellij.psi.impl.java.stubs.PsiJavaModuleStub;
 import com.intellij.psi.util.PsiTreeUtil;
 import org.jetbrains.annotations.NotNull;
 
-public class PsiJavaModuleImpl extends CompositePsiElement implements PsiJavaModule {
-  public PsiJavaModuleImpl() {
-    super(JavaElementType.MODULE);
+public class PsiJavaModuleImpl extends JavaStubPsiElement<PsiJavaModuleStub> implements PsiJavaModule {
+  public PsiJavaModuleImpl(@NotNull PsiJavaModuleStub stub) {
+    super(stub, JavaStubElementTypes.MODULE);
+  }
+
+  public PsiJavaModuleImpl(@NotNull ASTNode node) {
+    super(node);
   }
 
   @NotNull
@@ -38,6 +43,11 @@ public class PsiJavaModuleImpl extends CompositePsiElement implements PsiJavaMod
   @NotNull
   @Override
   public String getModuleName() {
+    PsiJavaModuleStub stub = getStub();
+    if (stub != null) {
+      return stub.getName();
+    }
+
     return getNameElement().getReferenceText();
   }
 
index 08573ba91e15fcc2a9af450aa9dd1f434e1edef2..71856ad311dffca1b7fb7d643ccf68636fc77bda 100644 (file)
@@ -83,6 +83,7 @@ public interface JavaElementType {
   IElementType PARAMETER_LIST = JavaStubElementTypes.PARAMETER_LIST;
   IElementType EXTENDS_BOUND_LIST = JavaStubElementTypes.EXTENDS_BOUND_LIST;
   IElementType THROWS_LIST = JavaStubElementTypes.THROWS_LIST;
+  IElementType MODULE = JavaStubElementTypes.MODULE;
 
   IElementType IMPORT_STATIC_REFERENCE = new JavaCompositeElementType("IMPORT_STATIC_REFERENCE", PsiImportStaticReferenceElementImpl.class);
   IElementType TYPE = new JavaCompositeElementType("TYPE", PsiTypeElementImpl.class);
@@ -139,7 +140,6 @@ public interface JavaElementType {
   IElementType ANNOTATION_ARRAY_INITIALIZER = new JavaCompositeElementType("ANNOTATION_ARRAY_INITIALIZER", PsiArrayInitializerMemberValueImpl.class);
   IElementType RECEIVER_PARAMETER = new JavaCompositeElementType("RECEIVER", PsiReceiverParameterImpl.class);
 
-  IElementType MODULE = new JavaCompositeElementType("MODULE", PsiJavaModuleImpl.class);
   IElementType MODULE_REFERENCE = new JavaCompositeElementType("MODULE_NAME", PsiJavaModuleReferenceImpl.class);
   IElementType REQUIRES_STATEMENT = new JavaCompositeElementType("REQUIRES_STATEMENT", PsiRequiresStatementImpl.class);
   IElementType EXPORTS_STATEMENT = new JavaCompositeElementType("EXPORTS_STATEMENT", PsiExportsStatementImpl.class);
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advFixture/UsageOfProtectedAnnotationOutsideAPackage.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advFixture/UsageOfProtectedAnnotationOutsideAPackage.java
new file mode 100644 (file)
index 0000000..32f54d0
--- /dev/null
@@ -0,0 +1,7 @@
+import a.A;
+
+@A.<error descr="'a.A.Test' has protected access in 'a.A'">Test</error> ()
+class B extends A {}
+
+@A.<error descr="'a.A.Test' has protected access in 'a.A'">Test</error> ()
+class C {}
\ No newline at end of file
index f066058520d11f089087ea9fa1ac0f944999f17f..1ca5b71ae30dd5c37076964e1cf87c061a38a602 100644 (file)
@@ -8,6 +8,6 @@ interface A
 
 <error descr="Class 'B' must either be declared abstract or implement abstract method 'foo(S)' in 'A'">class B  implements A</error>
 {
-    public void foo(Collection<?> x) { }
+    <error descr="'foo(Collection<?>)' in 'B' clashes with 'foo(S)' in 'A'; both methods have same erasure, yet neither overrides the other">public void foo(Collection<?> x)</error> { }
     public <S extends List<?> & Collection<?>> void foo(S x) { }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/cls/mirror/module-info.txt b/java/java-tests/testData/psi/cls/mirror/module-info.txt
new file mode 100644 (file)
index 0000000..6a885b3
--- /dev/null
@@ -0,0 +1,5 @@
+
+  // IntelliJ API Decompiler stub source generated from a class file
+  // Implementation of methods is not available
+
+module M.N { /* compiled code */ }
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/cls/stubBuilder/module-info.class b/java/java-tests/testData/psi/cls/stubBuilder/module-info.class
new file mode 100644 (file)
index 0000000..e6b1506
Binary files /dev/null and b/java/java-tests/testData/psi/cls/stubBuilder/module-info.class differ
diff --git a/java/java-tests/testData/psi/cls/stubBuilder/module-info.txt b/java/java-tests/testData/psi/cls/stubBuilder/module-info.txt
new file mode 100644 (file)
index 0000000..fedac2f
--- /dev/null
@@ -0,0 +1,2 @@
+PsiJavaFileStub []
+  PsiJavaModuleStub:M.N
\ No newline at end of file
index bb2873e181a07bc9d2d4f019c2387e77e17c1ee4..e08e7e9f892327a3100fc3b3016c47555c68b35a 100644 (file)
@@ -77,6 +77,21 @@ public class LightAdvHighlightingFixtureTest extends LightCodeInsightFixtureTest
 
   }
 
+  public void testUsageOfProtectedAnnotationOutsideAPackage() throws Exception {
+    myFixture.addClass("package a;\n" +
+                       "import java.lang.annotation.ElementType;\n" +
+                       "import java.lang.annotation.Target;\n" +
+                       "\n" +
+                       "public class A {\n" +
+                       "    @Target( { ElementType.METHOD, ElementType.TYPE } )\n" +
+                       "    protected @interface Test{\n" +
+                       "    }\n" +
+                       "}");
+
+    myFixture.configureByFile(getTestName(false) + ".java");
+    myFixture.checkHighlighting();
+  }
+
   @Override
   protected String getBasePath() {
     return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/advFixture";
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ModuleHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ModuleHighlightingTest.java
deleted file mode 100644 (file)
index 87f3f93..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.
- * 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 com.intellij.codeInsight.daemon;
-
-import com.intellij.openapi.application.WriteAction;
-import com.intellij.openapi.vfs.VfsUtil;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.testFramework.LightPlatformTestCase;
-import com.intellij.testFramework.LightProjectDescriptor;
-import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.IOException;
-
-public class ModuleHighlightingTest extends LightCodeInsightFixtureTestCase {
-  @NotNull
-  @Override
-  protected LightProjectDescriptor getProjectDescriptor() {
-    return JAVA_9;
-  }
-
-  public void testWrongFileName() {
-    myFixture.configureByText("M.java", "/* ... */ <error descr=\"Module declaration should be in a file named 'module-info.java'\">module M</error> { }");
-    myFixture.checkHighlighting();
-  }
-
-  public void testFileDuplicate() throws IOException {
-    myFixture.configureFromExistingVirtualFile(WriteAction.compute(() -> {
-      VirtualFile file = LightPlatformTestCase.getSourceRoot().createChildDirectory(this, "pkg").createChildData(this, "module-info.java");
-      VfsUtil.saveText(file, "module M { }");
-      return file;
-    }));
-    myFixture.configureByText("module-info.java", "<error descr=\"Multiple module declarations\">module M</error> { }");
-    myFixture.checkHighlighting();
-  }
-
-  public void testWrongFileLocation() throws IOException {
-    myFixture.configureFromExistingVirtualFile(WriteAction.compute(() -> {
-      VirtualFile file = LightPlatformTestCase.getSourceRoot().createChildDirectory(this, "pkg").createChildData(this, "module-info.java");
-      VfsUtil.saveText(file, "<warning descr=\"Module declaration should be located in a module's source root\">module M</warning> { }");
-      return file;
-    }));
-    myFixture.checkHighlighting();
-  }
-}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ModuleHighlightingTest.kt b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ModuleHighlightingTest.kt
new file mode 100644 (file)
index 0000000..9f7135e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ * 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 com.intellij.codeInsight.daemon
+
+import com.intellij.openapi.application.runWriteAction
+import com.intellij.openapi.vfs.VfsUtil
+import com.intellij.testFramework.LightPlatformTestCase
+import com.intellij.testFramework.LightProjectDescriptor
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
+
+class ModuleHighlightingTest : LightCodeInsightFixtureTestCase() {
+  override fun getProjectDescriptor(): LightProjectDescriptor = JAVA_9
+
+  fun testWrongFileName() {
+    myFixture.configureByText("M.java", """/* ... */ <error descr="Module declaration should be in a file named 'module-info.java'">module M</error> { }""")
+    myFixture.checkHighlighting()
+  }
+
+  fun testFileDuplicate() {
+    myFixture.configureFromExistingVirtualFile(runWriteAction {
+      val file = LightPlatformTestCase.getSourceRoot().createChildDirectory(this, "pkg").createChildData(this, "module-info.java")
+      VfsUtil.saveText(file, "module M { }")
+      file
+    })
+    myFixture.configureByText("module-info.java", """<error descr="Multiple module declarations">module M</error> { }""")
+    myFixture.checkHighlighting()
+  }
+
+  fun testWrongFileLocation() {
+    myFixture.configureFromExistingVirtualFile(runWriteAction {
+      val file = LightPlatformTestCase.getSourceRoot().createChildDirectory(this, "pkg").createChildData(this, "module-info.java")
+      VfsUtil.saveText(file, """<warning descr="Module declaration should be located in a module's source root">module M</warning> { }""")
+      file
+    })
+    myFixture.checkHighlighting()
+  }
+}
\ No newline at end of file
index 7c578d4e5bd30928f130bac958a00f8b00b3d70b..e9f0b8b7543ddc9e05d6f3ee8005b036f318c193 100644 (file)
@@ -846,6 +846,22 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
     assertEmpty(highlightErrors());
   }
 
+  public void testOverrideMethodsHighlightingPersistWhenTypeInsideMethodBody() throws Throwable {
+    configureByText(JavaFileType.INSTANCE, "package x; \n" +
+                                           "class ClassA {\n" +
+                                           "    static <T> void sayHello(Class<? extends T> msg) {}\n" +
+                                           "}\n" +
+
+                                           "class ClassB extends ClassA {\n" +
+                                           "    static <T extends String> void sayHello(Class<? extends T> msg) {<caret>\n" +
+                                           "    }\n" +
+                                           "}\n");
+
+    assertSize(1, highlightErrors());
+    type("//my comment inside method body, so class modifier won't be visited");
+    assertSize(1, highlightErrors());
+  }
+
   public void testLineMarkersClearWhenTypingAtTheEndOfPsiComment() throws Throwable {
     configureByText(JavaFileType.INSTANCE, "class S {\n//ddd<caret>\n}");
     StringBuffer log = new StringBuffer();
index 9694b6625b35aa165dc399ffda9cb94a7725df60..58259fb6a96767e42e9d44caacd14b00085f47d1 100644 (file)
@@ -113,7 +113,7 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
         catch (IOException ignored) { }
       }
     };
-    PsiJavaFileStubImpl stub = new PsiJavaFileStubImpl("do.not.know.yet", true);
+    PsiJavaFileStubImpl stub = new PsiJavaFileStubImpl("java.lang", true);
     StubBuildingVisitor<VirtualFile> visitor = new StubBuildingVisitor<>(file, strategy, stub, 0, null);
     new ClassReader(file.contentsToByteArray()).accept(visitor, ClassReader.SKIP_FRAMES);
   }
@@ -175,6 +175,11 @@ public class ClsMirrorBuildingTest extends LightIdeaTestCase {
     assertFalse(isInner("weird/ToStringStyle"));
   }
 
+  public void testModuleInfo() {
+    String testDir = getTestDataDir();
+    doTest(testDir + "../stubBuilder/module-info.class", testDir + "module-info.txt");
+  }
+
   private static String getTestDataDir() {
     return JavaTestUtil.getJavaTestDataPath() + "/psi/cls/mirror/";
   }
index fa9c681b852408010e7821a0d9d32990221ee718..32b21fa4ad7b3ba1a1d793e4ab422c4f8e72c68c 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.io.IoTestUtil;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.impl.compiled.ClsFileImpl;
 import com.intellij.psi.impl.compiled.ClsParameterImpl;
 import com.intellij.psi.impl.java.stubs.PsiMethodStub;
@@ -87,6 +88,8 @@ public class ClsPsiTest extends LightIdeaTestCase {
     assertTrue(file.isValid());
     assertEquals("pack", file.getPackageName());
     assertEquals(1, file.getClasses().length);
+    file = getFile("MyEnum");
+    assertEquals(LanguageLevel.JDK_1_5, file.getLanguageLevel());
   }
 
   public void testClassBasics() {
@@ -409,6 +412,18 @@ public class ClsPsiTest extends LightIdeaTestCase {
     assertEquals("@pkg.TypeAnnotations.TA(\"parameter\") int", p1.getType().getCanonicalText(true));
   }
 
+  public void testModuleInfo() {
+    PsiJavaFile file = getFile("../../stubBuilder/module-info");
+    assertEquals(LanguageLevel.JDK_1_9, file.getLanguageLevel());
+
+    PsiJavaModule module = file.getModuleDeclaration();
+    assertNotNull(module);
+    assertEquals("M.N", module.getModuleName());
+
+    assertNull(file.getPackageStatement());
+    assertEquals(0, file.getClasses().length);
+  }
+
   private PsiJavaFile getFile() {
     return getFile(getTestName(false));
   }
index bab399188dc8205ff870f4b1a4142528c04d1d36..f71980131c1706275bb47420f08fdc53c52d9be4 100644 (file)
@@ -51,6 +51,13 @@ public class ClsStubBuilderTest extends LightIdeaTestCase {
     doTest(clsFile, getTestName(false) + ".txt");
   }
 
+  public void testModuleInfo() {
+    String clsFilePath = JavaTestUtil.getJavaTestDataPath() + "/psi/cls/stubBuilder/module-info.class";
+    VirtualFile clsFile = LocalFileSystem.getInstance().findFileByPath(clsFilePath);
+    assertNotNull(clsFile);
+    doTest(clsFile, "module-info.txt");
+  }
+
   private void doTest(String className) {
     VirtualFile clsFile = findFile(className);
     assertNotNull(clsFile);
@@ -79,7 +86,7 @@ public class ClsStubBuilderTest extends LightIdeaTestCase {
     try {
       PsiFileStub stub = ClsFileImpl.buildFileStub(clsFile, clsFile.contentsToByteArray());
       assertNotNull(stub);
-      String actual = ((StubBase)stub).printTree();
+      String actual = ((StubBase)stub).printTree().trim();
 
       File resultFile = new File(JavaTestUtil.getJavaTestDataPath() + "/psi/cls/stubBuilder/" + resultFileName);
       if (!resultFile.exists()) {
@@ -88,7 +95,7 @@ public class ClsStubBuilderTest extends LightIdeaTestCase {
         fail("No test data found. Created one");
       }
 
-      String expected = StringUtil.convertLineSeparators(FileUtil.loadFile(resultFile));
+      String expected = StringUtil.convertLineSeparators(FileUtil.loadFile(resultFile)).trim();
 
       assertEquals(expected, actual);
     }
index 98061cca29a517d3fc53e3e7c5c6b99e70cd1e86..937668d7789a8b7e0507e98b94d4e2b5ee96186f 100644 (file)
@@ -486,6 +486,15 @@ public class JavaStubBuilderTest extends LightIdeaTestCase {
            "        IMPLEMENTS_LIST:PsiRefListStub[IMPLEMENTS_LIST:]\n");
   }
 
+  public void testModuleInfo() {
+    doTest("module M. /*ignore me*/ N {\n" +
+           "  requires A.B;\n" +
+           "}",
+
+           "PsiJavaFileStub []\n" +
+           "  MODULE:PsiJavaModuleStub:M.N\n");
+  }
+
   public void testSOEProof() {
     StringBuilder sb = new StringBuilder();
     SecureRandom random = new SecureRandom();
index f8493f3fe4916b1d3beced41e9a5631fdbd346e5..06893700395ab1c8efb90723f4f18f5f582b1b0a 100644 (file)
@@ -389,7 +389,7 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
    * @return children of specified type, taken from stubs (if this element is currently stub-based) or AST (otherwise).
    */
   @NotNull
-  public <S extends StubElement, Psi extends PsiElement> Psi[] getStubOrPsiChildren(@NotNull IStubElementType<S, Psi> elementType, @NotNull Psi[] array) {
+  public <S extends StubElement, Psi extends PsiElement> Psi[] getStubOrPsiChildren(@NotNull IStubElementType<S, ? extends Psi> elementType, @NotNull Psi[] array) {
     T stub = getStub();
     if (stub != null) {
       //noinspection unchecked
@@ -411,7 +411,7 @@ public class StubBasedPsiElementBase<T extends StubElement> extends ASTDelegateP
    * @return children of specified type, taken from stubs (if this element is currently stub-based) or AST (otherwise).
    */
   @NotNull
-  public <S extends StubElement, Psi extends PsiElement> Psi[] getStubOrPsiChildren(@NotNull IStubElementType<S, Psi> elementType, @NotNull ArrayFactory<Psi> f) {
+  public <S extends StubElement, Psi extends PsiElement> Psi[] getStubOrPsiChildren(@NotNull IStubElementType<S, ? extends Psi> elementType, @NotNull ArrayFactory<Psi> f) {
     T stub = getStub();
     if (stub != null) {
       //noinspection unchecked
index dce444a9def7f6034c99d2219945bdde4c89d831..043bb30db4fc7efb72d8739c276f683d96f09df8 100644 (file)
@@ -53,7 +53,7 @@ public class ApplicationInfoImpl extends ApplicationInfoEx {
   private String myMinorVersion;
   private String myMicroVersion;
   private String myPatchVersion;
-  private String myFullVersion;
+  private String myFullVersionFormat;
   private String myBuildNumber;
   private String myApiVersion;
   private String myCompanyName = "JetBrains s.r.o.";
@@ -284,7 +284,7 @@ public class ApplicationInfoImpl extends ApplicationInfoEx {
   }
 
   private String doGetFullVersion() {
-    if (myFullVersion == null) {
+    if (myFullVersionFormat == null) {
       if (!StringUtil.isEmptyOrSpaces(myMajorVersion)) {
         if (!StringUtil.isEmptyOrSpaces(myMinorVersion)) {
           return myMajorVersion + "." + myMinorVersion;
@@ -297,7 +297,7 @@ public class ApplicationInfoImpl extends ApplicationInfoEx {
         return getVersionName();
       }
     } else {
-      return MessageFormat.format(myFullVersion, myMajorVersion, myMinorVersion, myMicroVersion, myPatchVersion);
+      return MessageFormat.format(myFullVersionFormat, myMajorVersion, myMinorVersion, myMicroVersion, myPatchVersion);
     }
   }
 
@@ -627,7 +627,7 @@ public class ApplicationInfoImpl extends ApplicationInfoEx {
       myMinorVersion = versionElement.getAttributeValue(ATTRIBUTE_MINOR);
       myMicroVersion = versionElement.getAttributeValue(ATTRIBUTE_MICRO);
       myPatchVersion = versionElement.getAttributeValue(ATTRIBUTE_PATCH);
-      myFullVersion = versionElement.getAttributeValue(ATTRIBUTE_FULL);
+      myFullVersionFormat = versionElement.getAttributeValue(ATTRIBUTE_FULL);
       myCodeName = versionElement.getAttributeValue(ATTRIBUTE_CODENAME);
       myEAP = Boolean.parseBoolean(versionElement.getAttributeValue(ATTRIBUTE_EAP));
     }
index ae3d89324fb41f7172fbe243c2af702f8806e526..0eb212d6360bfe713ec20ecaa7cb843fef9ed0aa 100644 (file)
@@ -18,11 +18,10 @@ package com.intellij.ui.components;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.registry.Registry;
 import com.intellij.ui.Gray;
+import com.intellij.ui.paint.RectanglePainter;
 import com.intellij.util.ui.RegionPainter;
 
 import java.awt.*;
-import java.awt.geom.Path2D;
-import java.awt.geom.RoundRectangle2D;
 import java.awt.image.*;
 
 /**
@@ -132,27 +131,14 @@ class ScrollPainter extends RegionPainter.Alpha {
       super(offset, base, delta, fill, draw);
     }
 
-    @Override
-    protected void paint(Graphics2D g, int x, int y, int width, int height) {
-      Object old = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
-      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-      super.paint(g, x, y, width, height);
-      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, old);
-    }
-
     @Override
     protected void fill(Graphics2D g, int x, int y, int width, int height, boolean border) {
-      int arc = Math.min(width, height);
-      g.fillRoundRect(x, y, width, height, arc, arc);
+      RectanglePainter.FILL.paint(g, x, y, width, height, Math.min(width, height));
     }
 
     @Override
     protected void draw(Graphics2D g, int x, int y, int width, int height) {
-      int arc = Math.min(width, height);
-      Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
-      path.append(new RoundRectangle2D.Double(x, y, width, height, arc, arc), false);
-      path.append(new RoundRectangle2D.Double(x + 1, y + 1, width - 2, height - 2, arc - 2, arc - 2), false);
-      g.fill(path);
+      RectanglePainter.DRAW.paint(g, x, y, width, height, Math.min(width, height));
     }
   }
 
diff --git a/platform/platform-api/src/com/intellij/ui/paint/RectanglePainter.java b/platform/platform-api/src/com/intellij/ui/paint/RectanglePainter.java
new file mode 100644 (file)
index 0000000..cc7b69a
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ * 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 com.intellij.ui.paint;
+
+import com.intellij.util.ui.RegionPainter;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Path2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+
+/**
+ * @author Sergey.Malenkov
+ */
+public enum RectanglePainter implements RegionPainter<Integer> {
+  DRAW {
+    @Override
+    public void paint(Graphics2D g, int x, int y, int width, int height, Integer round) {
+      int sw = 1; // stroke width
+      int dw = sw + sw;
+      if (width > dw && height > dw) {
+        int arc = round == null ? 0 : round;
+        if (arc > 0) {
+          Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
+          path.append(new RoundRectangle2D.Double(x, y, width, height, arc, arc), false);
+          path.append(new RoundRectangle2D.Double(x + sw, y + sw, width - dw, height - dw, arc - dw, arc - dw), false);
+          Object old = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+          g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+          g.fill(path);
+          g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, old);
+        }
+        else {
+          Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
+          path.append(new Rectangle2D.Double(x, y, width, height), false);
+          path.append(new Rectangle2D.Double(x + sw, y + sw, width - dw, height - dw), false);
+          g.fill(path);
+        }
+      }
+      else {
+        FILL.paint(g, x, y, width, height, round);
+      }
+    }
+  },
+  FILL {
+    @Override
+    public void paint(Graphics2D g, int x, int y, int width, int height, Integer round) {
+      if (width > 0 && height > 0) {
+        int arc = round == null ? 0 : round;
+        if (arc > 0) {
+          Object old = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+          g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+          g.fillRoundRect(x, y, width, height, arc, arc);
+          g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, old);
+        }
+        else {
+          g.fillRect(x, y, width, height);
+        }
+      }
+    }
+  };
+
+  public static void paint(Graphics2D g, int x, int y, int width, int height, int arc, Color fill, Color draw) {
+    if (fill != null) {
+      g.setColor(fill);
+      if (draw != null) {
+        int sw = 1; // stroke width
+        int dw = sw + sw;
+        FILL.paint(g, x + sw, y + sw, width - dw, height - dw, arc - dw);
+      }
+      else {
+        FILL.paint(g, x, y, width, height, arc);
+      }
+    }
+    if (draw != null) {
+      g.setColor(draw);
+      DRAW.paint(g, x, y, width, height, arc);
+    }
+  }
+}
index 1e98bf863dbea6acba52991b79761de54a5c7fec..f745f83d5ee8cb1548bb67cd35d5f4376e1a853b 100644 (file)
@@ -344,8 +344,9 @@ public class SoftWrapApplianceManager implements Dumpable {
     String placeholder = foldRegion.getPlaceholderText();
     int placeholderWidthInPixels = 0;
     for (int i = 0; i < placeholder.length(); i++) {
-      placeholderWidthInPixels += SoftWrapModelImpl.getEditorTextRepresentationHelper(myEditor)
-        .charWidth(placeholder.charAt(i), myContext.fontType);
+      char c = placeholder.charAt(i);
+      if (myEditor.myUseNewRendering && c == '\n') c = ' '; // we display \n as space (see com.intellij.openapi.editor.impl.view.EditorView.getFoldRegionLayout)
+      placeholderWidthInPixels += SoftWrapModelImpl.getEditorTextRepresentationHelper(myEditor).charWidth(c, myContext.fontType);
     }
 
     if (myContext.delayedSoftWrap == null) {
index 88a620ca5ac9e577c420baff9b082791c911c151..eb1740cdfed8b78bd1ff64a2016c88981b0d5f82 100644 (file)
@@ -30,6 +30,7 @@ import com.intellij.openapi.editor.impl.TextDrawingCallback;
 import com.intellij.openapi.editor.markup.TextAttributes;
 import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.util.Key;
+import com.intellij.openapi.util.text.StringUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.TestOnly;
 
@@ -472,7 +473,7 @@ public class EditorView implements TextDrawingCallback, Disposable, Dumpable {
     LineLayout layout = foldRegion.getUserData(FOLD_REGION_TEXT_LAYOUT);
     if (layout == null) {
       TextAttributes placeholderAttributes = myEditor.getFoldingModel().getPlaceholderAttributes();
-      layout = LineLayout.create(this, foldRegion.getPlaceholderText(), 
+      layout = LineLayout.create(this, StringUtil.replace(foldRegion.getPlaceholderText(), "\n", " "),
                               placeholderAttributes == null ? Font.PLAIN : placeholderAttributes.getFontType());
       foldRegion.putUserData(FOLD_REGION_TEXT_LAYOUT, layout);
     }
index 462bb4acf210b3b37ca8bee08cab675e77b59024..c99e04ce2c841622f109aed151b3c92c9e5c2f03 100644 (file)
@@ -32,6 +32,7 @@ import com.intellij.ui.LicensingFacade;
 import com.intellij.ui.components.JBLabel;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.text.DateFormatUtil;
+import org.apache.http.client.utils.URIBuilder;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -39,6 +40,7 @@ import javax.swing.*;
 import java.awt.event.ActionEvent;
 import java.io.File;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
@@ -182,7 +184,7 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
   private void openDownloadPage() {
     String url = myUpdatedChannel.getHomePageUrl();
     assert url != null : "channel: " + myUpdatedChannel.getId();
-    BrowserUtil.browse(url);
+    BrowserUtil.browse(augmentUrl(url));
   }
 
   private static class ButtonAction extends AbstractAction {
@@ -195,7 +197,7 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
 
     @Override
     public void actionPerformed(ActionEvent e) {
-      BrowserUtil.browse(myUrl);
+      BrowserUtil.browse(augmentUrl(myUrl));
     }
   }
 
@@ -223,7 +225,7 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
         final int idx = message.indexOf(fullProductName);
         if (idx >= 0) {
           message = message.substring(0, idx) +
-                    "<a href=\'" + homePageUrl + "\'>" + fullProductName + "</a>" + message.substring(idx + fullProductName.length());
+                    "<a href=\'" + augmentUrl(homePageUrl) + "\'>" + fullProductName + "</a>" + message.substring(idx + fullProductName.length());
         }
       }
       configureMessageArea(myUpdateMessage, message, null, BrowserHyperlinkListener.INSTANCE);
@@ -261,4 +263,14 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
   protected static String formatVersion(String versionString, String build) {
     return IdeBundle.message("updates.version.info", versionString, build);
   }
+
+  private static String augmentUrl(String url) {
+    try {
+      return new URIBuilder(url).addParameter("fromIDE", "").build().toString();
+    }
+    catch (URISyntaxException e) {
+      Logger.getInstance(UpdateInfoDialog.class).warn(url, e);
+      return url;
+    }
+  }
 }
\ No newline at end of file
index c164c115e011bc8e39b8107f24b92a211aff79df..316ae8a9c959dbe86132673f9e2c04aa5d03179c 100644 (file)
@@ -56,5 +56,6 @@ com.phpuaca 1.3.1 1.2.1
 coffeescript-idea 0.1-1-gae5a
 RESTClient 1.2
 krasa.nonProjectFilesUnlocker 1.0 1.1
-com.chrisrm.idea.MaterialThemeUI 0.1.9
+com.chrisrm.idea.MaterialThemeUI 0.2.0 0.1.9
 com.hasintech.intellij.angularTemplates 1.0.2 1.1.2
+com.jetbrains.plugins.jade 144.2931 142.4651 141.506 140.2144 140.1212 140.216 138.1744 133.74 130.1520 121.390 122.668 121.185
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionJdk6Test.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionJdk6Test.java
new file mode 100644 (file)
index 0000000..4e99124
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ * 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 com.siyeh.ig.fixes.equality;
+
+import com.intellij.pom.java.LanguageLevel;
+import com.intellij.testFramework.IdeaTestUtil;
+import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
+
+/**
+ * @author Pavel.Dolgov
+ */
+public class ReplaceEqualityWithEqualsInspectionJdk6Test extends ReplaceEqualityWithEqualsInspectionTestBase {
+
+  public void testSimpleObjectOldSafeComparison() { doTest(true, true); }
+  public void testNegatedObjectOldSafeComparison() { doTest(false, true); }
+
+  @Override
+  protected void tuneFixture(JavaModuleFixtureBuilder builder) throws Exception {
+    builder.addJdk(IdeaTestUtil.getMockJdk17Path().getPath())
+      .setLanguageLevel(LanguageLevel.JDK_1_6);
+  }
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionJdk7Test.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionJdk7Test.java
new file mode 100644 (file)
index 0000000..b0dae8c
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ * 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 com.siyeh.ig.fixes.equality;
+
+import com.intellij.pom.java.LanguageLevel;
+import com.intellij.testFramework.IdeaTestUtil;
+import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
+
+/**
+ * @author Pavel.Dolgov
+ */
+public class ReplaceEqualityWithEqualsInspectionJdk7Test extends ReplaceEqualityWithEqualsInspectionTestBase {
+
+  public void testSimpleObjectSafeComparison() { doTest(true, true); }
+  public void testNegatedObjectSafeComparison() { doTest(false, true); }
+
+  @Override
+  protected void tuneFixture(JavaModuleFixtureBuilder builder) throws Exception {
+    builder.addJdk(IdeaTestUtil.getMockJdk18Path().getPath())
+      .setLanguageLevel(LanguageLevel.JDK_1_7);
+  }
+}
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionTest.java
deleted file mode 100644 (file)
index 58bc297..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.
- * 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 com.siyeh.ig.fixes.equality;
-
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.testFramework.IdeaTestUtil;
-import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
-import com.siyeh.InspectionGadgetsBundle;
-import com.siyeh.ig.IGQuickFixesTestCase;
-import com.siyeh.ig.equality.ReplaceEqualityWithEqualsInspection;
-
-/**
- * @see ReplaceEqualityWithEqualsInspection
- * @author Bas Leijdekkers
- */
-public class ReplaceEqualityWithEqualsInspectionTest extends IGQuickFixesTestCase {
-
-  public void testEnumComparison() { assertQuickfixNotAvailable(); }
-  public void testNullComparison() { assertQuickfixNotAvailable(); }
-  public void testPrimitiveComparison() { assertQuickfixNotAvailable(); }
-  public void testSimpleObjectComparison() { doTest(InspectionGadgetsBundle.message("replace.equality.with.equals.descriptor", "==", "")); }
-  public void testNegatedObjectComparison() { doTest(InspectionGadgetsBundle.message("replace.equality.with.equals.descriptor", "!=", "!")); }
-
-  public void testSimpleObjectSafeComparison() { doTest(InspectionGadgetsBundle.message("replace.equality.with.safe.equals.descriptor", "==", "")); }
-  public void testNegatedObjectSafeComparison() { doTest(InspectionGadgetsBundle.message("replace.equality.with.safe.equals.descriptor", "!=", "!")); }
-  public void testSimpleObjectOldSafeComparison() { doTest(InspectionGadgetsBundle.message("replace.equality.with.safe.equals.descriptor", "==", "")); }
-  public void testNegatedObjectOldSafeComparison() { doTest(InspectionGadgetsBundle.message("replace.equality.with.safe.equals.descriptor", "!=", "!")); }
-
-    @Override
-    protected void tuneFixture(JavaModuleFixtureBuilder builder) throws Exception {
-      super.tuneFixture(builder);
-      if (getTestName(false).contains("Old")) {
-        builder.setLanguageLevel(LanguageLevel.JDK_1_6);
-      }
-      else if (getTestName(false).contains("Safe")) {
-        builder.addJdk(IdeaTestUtil.getMockJdk18Path().getPath()); // MockJdk17 would work if it contained java.util.Objects
-        builder.setLanguageLevel(LanguageLevel.JDK_1_7);
-      }
-    }
-
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-    myFixture.enableInspections(new ReplaceEqualityWithEqualsInspection());
-    myDefaultHint = "Replace";
-    myRelativePath = "equality/replace_equality_with_equals";
-  }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionTestBase.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionTestBase.java
new file mode 100644 (file)
index 0000000..2e216ac
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ * 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 com.siyeh.ig.fixes.equality;
+
+import com.siyeh.InspectionGadgetsBundle;
+import com.siyeh.ig.IGQuickFixesTestCase;
+import com.siyeh.ig.equality.ReplaceEqualityWithEqualsInspection;
+
+/**
+ * @see ReplaceEqualityWithEqualsInspection
+ * @author Bas Leijdekkers
+ */
+public abstract class ReplaceEqualityWithEqualsInspectionTestBase extends IGQuickFixesTestCase {
+
+  public void testEnumComparison() { assertQuickfixNotAvailable(); }
+  public void testNullComparison() { assertQuickfixNotAvailable(); }
+  public void testPrimitiveComparison() { assertQuickfixNotAvailable(); }
+  public void testSimpleObjectComparison() { doTest(true, false); }
+  public void testNegatedObjectComparison() { doTest(false, false); }
+
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    myFixture.enableInspections(new ReplaceEqualityWithEqualsInspection());
+    myDefaultHint = "Replace";
+    myRelativePath = "equality/replace_equality_with_equals";
+  }
+
+  protected void doTest(boolean isEqual, boolean isSafe) {
+    doTest(InspectionGadgetsBundle.message(
+      isSafe ? "replace.equality.with.safe.equals.descriptor" : "replace.equality.with.equals.descriptor",
+      isEqual ? "==" : "!=",
+      isEqual ? "" : "!"));
+  }
+}
index 5a5063d448270def2d6006fc643b90d1e2222a0f..5f715c9f2b7f8aee44223657cc31e64e4c06b170 100644 (file)
@@ -133,7 +133,7 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
       else ClsFileImpl.decompile(file)
 
   private fun decompile(file: VirtualFile): CharSequence {
-    if ("package-info.class" == file.name) {
+    if ("package-info.class" == file.name || "module-info.class" == file.name) {
       return ClsFileImpl.decompile(file)
     }
 
index f238c769b01b4ce57044ae6b10fb0845d9b9e7f2..c4f2b3df6af14cd0cd800b264f787d8417fb32b4 100644 (file)
@@ -171,7 +171,6 @@ class PyDevTerminalInteractiveShell(TerminalInteractiveShell):
                              use_readline=self.has_readline,
                              config=self.config,
                              )
-        self.configurables.append(completer)
         return completer
 
 
@@ -183,7 +182,6 @@ class PyDevTerminalInteractiveShell(TerminalInteractiveShell):
                              use_readline=self.has_readline,
                              parent=self,
                              )
-        self.configurables.append(completer)
         return completer
 
     def _new_completer_234(self):
@@ -203,7 +201,6 @@ class PyDevTerminalInteractiveShell(TerminalInteractiveShell):
                                      use_readline=False,
                                      parent=self
                                      )
-        self.configurables.append(completer)
         return completer
 
     def add_completer_hooks(self):
@@ -239,7 +236,7 @@ class PyDevTerminalInteractiveShell(TerminalInteractiveShell):
         # extra information.
         # See getCompletions for where the two sets of results are merged
 
-        if IPythonRelease._version_major == 5:
+        if IPythonRelease._version_major >= 5:
             self.Completer = self._new_completer_500()
         elif IPythonRelease._version_major >= 2:
             self.Completer = self._new_completer_234()
index 1bb6363e5ba2ed5ed99a9b35aca2769fca3087bf..9615eaeed6d481535bef55c934aafd39da123498 100644 (file)
@@ -62,7 +62,7 @@
       <interface-class>com.intellij.psi.RefResolveService</interface-class>
       <implementation-class>com.intellij.psi.refResolve.RefResolveServiceImpl</implementation-class>
     </component>
-    
+
     <component>
       <implementation-class>com.intellij.execution.testDiscovery.TestDiscoveryIndex</implementation-class>
     </component>
 
     <definitionsScopedSearch implementation="com.intellij.codeInsight.navigation.MethodImplementationsSearch"/>
     <definitionsScopedSearch implementation="com.intellij.codeInsight.navigation.ClassImplementationsSearch"/>
-    
+
     <functionalExpressionSearch implementation="com.intellij.psi.impl.search.JavaFunctionalExpressionSearcher"/>
     <fileBasedIndex implementation="com.intellij.psi.impl.search.JavaFunctionalExpressionIndex"/>
 
     <stacktrace.fold substring="at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege("/>
     <stacktrace.fold substring="at com.jgoodies.binding.beans.ExtendedPropertyChangeSupport.firePropertyChange0("/>
     <stacktrace.fold substring="at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased("/>
-    
+
     <stacktrace.fold substring="at java.util.stream.ReferencePipeline$"/>
     <stacktrace.fold substring="at java.util.Spliterators$"/>
     <stacktrace.fold substring="at java.util.stream.AbstractPipeline.evaluate("/>
     <quoteHandler fileType="JAVA" className="com.intellij.codeInsight.editorActions.JavaQuoteHandler"/>
     <typedHandler implementation="com.intellij.codeInsight.editorActions.JavaTypedHandler" id="java"/>
     <typedHandler implementation="com.intellij.codeInsight.editorActions.JavadocTypedHandler" id="javadoc"/>
-    
+
     <editorTypedHandler implementationClass="com.intellij.codeInsight.editorActions.AutoFormatTypedHandler"/>
-    
+
     <editorSmartKeysConfigurable instance="com.intellij.application.options.JavadocOptionsProvider"
                                  id="editor.preferences.javadocOptions"
                                  key="javadoc.generate.message.title"
     <stubIndex implementation="com.intellij.psi.impl.java.stubs.index.JavaShortClassNameIndex"/>
     <stubIndex implementation="com.intellij.psi.impl.java.stubs.index.JavaSuperClassNameOccurenceIndex"/>
     <stubIndex implementation="com.intellij.psi.impl.java.stubs.index.JavaMethodParameterTypesIndex"/>
+    <stubIndex implementation="com.intellij.psi.impl.java.stubs.index.JavaModuleNameIndex"/>
 
     <fileBasedIndex implementation="com.intellij.codeInspection.bytecodeAnalysis.BytecodeAnalysisIndex"/>
     <fileBasedIndex implementation="com.intellij.psi.RefQueueIndex"/>
index 00804932fc5f8f8037164a9114cce63a987031e8..730ac79def2713ea32618aa5160eb1df040cb34f 100644 (file)
@@ -22,15 +22,14 @@ import com.intellij.openapi.util.Weighted;
 import com.intellij.ui.ColorUtil;
 import com.intellij.ui.Gray;
 import com.intellij.ui.JBColor;
+import com.intellij.ui.paint.RectanglePainter;
 import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.ui.JBUI;
-import com.intellij.util.ui.UIUtil;
+import com.intellij.util.ui.JBInsets;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
-import javax.swing.border.Border;
 import java.awt.*;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
@@ -340,11 +339,9 @@ public class BreadcrumbsComponent<T extends BreadcrumbsItem> extends JComponent
 
   @Override
   public Dimension getPreferredSize() {
-    Border border = getBorder();
     Graphics2D g2 = (Graphics2D)getGraphics();
     Dimension dim = new Dimension(Integer.MAX_VALUE, g2 != null ? DEFAULT_PAINTER.getSize("DUMMY", g2.getFontMetrics(), Integer.MAX_VALUE).height + 1 : 1);
-    Insets insets = border != null ? border.getBorderInsets(this) : JBUI.emptyInsets();
-    dim.height += insets.top + insets.bottom;
+    JBInsets.addTo(dim, getInsets());
     return dim;
   }
 
@@ -603,7 +600,7 @@ public class BreadcrumbsComponent<T extends BreadcrumbsItem> extends JComponent
   }
 
   abstract static class PainterSettings {
-    private static final Color DEFAULT_FOREGROUND_COLOR = new JBColor(Gray._50, UIUtil.getListForeground());
+    private static final Color DEFAULT_FOREGROUND_COLOR = new JBColor(Gray._50, Gray.xBB);
 
     @Nullable
     Color getBackgroundColor(@NotNull final Crumb c) {
@@ -632,7 +629,7 @@ public class BreadcrumbsComponent<T extends BreadcrumbsItem> extends JComponent
     private static final Color CURRENT_BG_COLOR = new JBColor(new Color(250, 250, 220), new Color(97, 97, 75));
     private static final Color HOVERED_BG_COLOR = new JBColor(Gray._220, ColorUtil.shift(DEFAULT_BG_COLOR, 1.2));
 
-    private static final Color LIGHT_TEXT_COLOR = new JBColor(Gray._170, UIUtil.getListForeground());
+    private static final Color LIGHT_TEXT_COLOR = new JBColor(Gray._170, Gray.xBB);
 
     private static final Color DEFAULT_BORDER_COLOR = new JBColor(Gray._170, Gray._50);
     private static final Color LIGHT_BORDER_COLOR = new JBColor(Gray._200, Gray._70);
@@ -717,18 +714,8 @@ public class BreadcrumbsComponent<T extends BreadcrumbsItem> extends JComponent
       final Font oldFont = g2.getFont();
       final int offset = c.getOffset() - pageOffset;
 
-      final Color bg = s.getBackgroundColor(c);
       final int width = c.getWidth();
-      if (bg != null) {
-        g2.setColor(bg);
-        g2.fillRoundRect(offset + 2, 2, width - 4, height - 3, ROUND_VALUE, ROUND_VALUE);
-      }
-
-      final Color borderColor = s.getBorderColor(c);
-      if (borderColor != null) {
-        g2.setColor(borderColor);
-        g2.drawRoundRect(offset + 2, 2, width - 4, height - 3, ROUND_VALUE, ROUND_VALUE);
-      }
+      RectanglePainter.paint(g2, offset + 2, 2, width - 4, height - 4, ROUND_VALUE + 2, s.getBackgroundColor(c), s.getBorderColor(c));
 
       final Color textColor = s.getForegroundColor(c);
       if (textColor != null) {