mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] KTIJ-18022 Don't report usages of internal Kotlin declarations from JavaDoc of classes in other modules
GitOrigin-RevId: 6b9f79f1a5fe57677b3f0ed82191b60c89acb908
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1870315023
commit
577923605c
+5
-1
@@ -5,13 +5,14 @@ package org.jetbrains.kotlin.idea.inspections
|
||||
import com.intellij.codeInspection.LocalInspectionTool
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.javadoc.PsiInlineDocTag
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightElement
|
||||
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.base.util.module
|
||||
import org.jetbrains.kotlin.lexer.KtTokens.INTERNAL_KEYWORD
|
||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||
|
||||
|
||||
class KotlinInternalInJavaInspection : LocalInspectionTool() {
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
|
||||
return object : JavaElementVisitor() {
|
||||
@@ -33,6 +34,9 @@ class KotlinInternalInJavaInspection : LocalInspectionTool() {
|
||||
}
|
||||
|
||||
if (modifierListOwner.hasModifier(INTERNAL_KEYWORD)) {
|
||||
// ignore JavaDoc @link references
|
||||
if (PsiTreeUtil.getParentOfType(this, PsiInlineDocTag::class.java) != null) return
|
||||
|
||||
holder.registerProblem(this, KotlinBundle.message("usage.of.kotlin.internal.declaration.from.different.module"))
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -3,7 +3,9 @@ import kotlin.collections.MapsKt;
|
||||
import kotlin.internal.PlatformImplementations; // Internal in stdlib, error
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
/**
|
||||
* {@link SomeInternalClassInOtherModule}
|
||||
*/
|
||||
public class SomeClass extends PlatformImplementations { // Internal in stdlib, error
|
||||
public static void doSomething() {
|
||||
PlatformImplementations a; // Internal in stdlib, error
|
||||
|
||||
+13
-13
@@ -9,16 +9,6 @@
|
||||
<description>Usage of Kotlin internal declaration from different module</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.java</file>
|
||||
<line>7</line>
|
||||
<module>A</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="file" FQNAME="test.java" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Usage of Kotlin internal declarations from Java</problem_class>
|
||||
<description>Usage of Kotlin internal declaration from different module</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.java</file>
|
||||
<line>9</line>
|
||||
@@ -41,7 +31,7 @@
|
||||
|
||||
<problem>
|
||||
<file>test.java</file>
|
||||
<line>12</line>
|
||||
<line>13</line>
|
||||
<module>A</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="file" FQNAME="test.java" />
|
||||
@@ -51,7 +41,7 @@
|
||||
|
||||
<problem>
|
||||
<file>test.java</file>
|
||||
<line>15</line>
|
||||
<line>14</line>
|
||||
<module>A</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="file" FQNAME="test.java" />
|
||||
@@ -61,7 +51,17 @@
|
||||
|
||||
<problem>
|
||||
<file>test.java</file>
|
||||
<line>15</line>
|
||||
<line>17</line>
|
||||
<module>A</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="file" FQNAME="test.java" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Usage of Kotlin internal declarations from Java</problem_class>
|
||||
<description>Usage of Kotlin internal declaration from different module</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>test.java</file>
|
||||
<line>17</line>
|
||||
<module>A</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="file" FQNAME="test.java" />
|
||||
|
||||
Reference in New Issue
Block a user