merge known annotations plugin into java plugin IDEA-CR-45224

This commit is contained in:
Nikita Skvortsov
2019-03-28 13:31:08 +03:00
parent 4a679c2879
commit 8461523805
8 changed files with 9 additions and 55 deletions
-1
View File
@@ -498,7 +498,6 @@
<module fileurl="file://$PROJECT_DIR$/jps/javac-ref-scanner-8/intellij.java.jps.javacRefScanner8.iml" filepath="$PROJECT_DIR$/jps/javac-ref-scanner-8/intellij.java.jps.javacRefScanner8.iml" />
<module fileurl="file://$PROJECT_DIR$/java/execution/jshell-frontend/intellij.java.jshell.frontend.iml" filepath="$PROJECT_DIR$/java/execution/jshell-frontend/intellij.java.jshell.frontend.iml" />
<module fileurl="file://$PROJECT_DIR$/java/execution/jshell-protocol/intellij.java.jshell.protocol.iml" filepath="$PROJECT_DIR$/java/execution/jshell-protocol/intellij.java.jshell.protocol.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/java-knownAnnotations/intellij.java.knownAnnotations.iml" filepath="$PROJECT_DIR$/plugins/java-knownAnnotations/intellij.java.knownAnnotations.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/IntelliLang/intellij.java.langInjection.iml" filepath="$PROJECT_DIR$/plugins/IntelliLang/intellij.java.langInjection.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/IntelliLang/intellilang-jps-plugin/intellij.java.langInjection.jps.iml" filepath="$PROJECT_DIR$/plugins/IntelliLang/intellilang-jps-plugin/intellij.java.langInjection.jps.iml" />
<module fileurl="file://$PROJECT_DIR$/java/manifest/intellij.java.manifest.iml" filepath="$PROJECT_DIR$/java/manifest/intellij.java.manifest.iml" />
@@ -93,8 +93,7 @@ abstract class BaseIdeaProperties extends ProductProperties {
"intellij.java.debugger.streams",
"intellij.android.smali",
"intellij.statsCollector",
"intellij.vcs.changeReminder",
"intellij.java.knownAnnotations"
"intellij.vcs.changeReminder"
]
protected static final Map<String, String> CE_CLASS_VERSIONS = [
"": "1.8",
@@ -1927,6 +1927,8 @@
<searchEverywhereResultsEqualityProvider implementation="com.intellij.ide.JavaClassAndFileEqualityProvider"/>
<applicationInitializedListener implementation="com.intellij.util.xml.impl.JavaDomApplicationComponent$Initializer"/>
<java.externalAnnotation.locationProvider
implementation="com.intellij.codeInsight.externalAnnotation.location.JBBundledAnnotationsProvider"/>
</extensions>
<extensions defaultExtensionNs="org.jetbrains">
@@ -1,13 +1,13 @@
package org.jetbrains.java.knownAnnotations
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.externalAnnotation.location
import com.google.gson.GsonBuilder
import com.google.gson.TypeAdapter
import com.google.gson.stream.JsonReader
import com.google.gson.stream.JsonToken
import com.google.gson.stream.JsonWriter
import com.intellij.codeInsight.externalAnnotation.location.AnnotationsLocation
import com.intellij.codeInsight.externalAnnotation.location.AnnotationsLocationProvider
import com.intellij.ide.extensionResources.ExtensionsRootType
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.util.io.FileUtil
@@ -15,7 +15,7 @@ import com.intellij.util.text.VersionComparatorUtil
class JBBundledAnnotationsProvider : AnnotationsLocationProvider {
private val myPluginId = PluginId.getId("org.jetbrains.java.knownAnnotations")
private val myPluginId = PluginId.getId(PluginManagerCore.CORE_PLUGIN_ID)
private val knownAnnotations: Map<String, Map<VersionRange, AnnotationsLocation>> by lazy { buildAnnotations() }
override fun getLocations(library: Library,
@@ -32,17 +32,6 @@ class JBBundledAnnotationsProvider : AnnotationsLocationProvider {
return listOf(matchers.entries.find { it.key.matches(version) }?.value ?: return emptyList())
}
private fun versionMatches(available: String, requested: String): Boolean {
val majorRequested = extractMajor(requested)
val availableWithoutAnSuffix = dropAnSuffix(available)
return VersionComparatorUtil.compare(majorRequested, available) <= 0
&& VersionComparatorUtil.compare(availableWithoutAnSuffix, requested) <= 0
}
private fun extractMajor(versionStr: String): String = versionStr.split('(', ')', '.', '_', '-', ';', ':', '/', ',', ' ', '+', '~')[0]
private fun dropAnSuffix(versionStr: String): String = versionStr.split(Regex("-an[\\d]+$"))[0]
private fun buildAnnotations(): Map<String, Map<VersionRange, AnnotationsLocation>> {
val extensionsRootType = ExtensionsRootType.getInstance()
val annotationsFile = extensionsRootType.findResource(myPluginId, "predefinedExternalAnnotations.json")
@@ -1,16 +1,13 @@
package org.jetbrains.java.knowAnnotatinos
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.externalAnnotation.location
import com.intellij.codeInsight.externalAnnotation.location.AnnotationsLocation
import com.intellij.openapi.application.WriteAction
import com.intellij.openapi.roots.libraries.Library
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar
import com.intellij.testFramework.LightPlatformTestCase
import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.java.knownAnnotations.JBBundledAnnotationsProvider
import org.junit.Test
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
class JBBundledAnnotationsProviderTest : LightPlatformTestCase() {
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="intellij.java.impl" />
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
<orderEntry type="library" name="gson" level="project" />
<orderEntry type="module" module-name="intellij.java.testFramework" scope="TEST" />
</component>
</module>
@@ -1,16 +0,0 @@
<idea-plugin>
<id>org.jetbrains.java.knownAnnotations</id>
<name>Known annotations provider</name>
<description>
Attaches external annotations artifacts from pre-defined list to libraries imported from Gradle/Maven projects.
</description>
<vendor email="support@jetbrains.com" url="https://www.jetbrains.com">JetBrains</vendor>
<depends>com.intellij.modules.java</depends>
<extensions defaultExtensionNs="com.intellij">
<java.externalAnnotation.locationProvider
implementation="org.jetbrains.java.knownAnnotations.JBBundledAnnotationsProvider"/>
</extensions>
</idea-plugin>