highlight unresolved references in KDoc
This commit is contained in:
@@ -70,6 +70,8 @@ public class KDocReference(element: KDocName): JetMultiReference<KDocName>(eleme
|
|||||||
val newLink = KDocElementFactory(getElement().getProject()).createNameFromText(newText)
|
val newLink = KDocElementFactory(getElement().getProject()).createNameFromText(newText)
|
||||||
return getElement().replace(newLink)
|
return getElement().replace(newLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getCanonicalText(): String = getElement().getNameText()
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun resolveKDocLink(session: KotlinCodeAnalyzer,
|
public fun resolveKDocLink(session: KotlinCodeAnalyzer,
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* 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 org.jetbrains.kotlin.idea.kdoc
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection
|
||||||
|
import com.intellij.codeInspection.ProblemsHolder
|
||||||
|
import com.intellij.psi.PsiElementVisitor
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.kdoc.psi.impl.KDocName
|
||||||
|
|
||||||
|
public class KDocUnresolvedReferenceInspection(): AbstractKotlinInspection() {
|
||||||
|
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor =
|
||||||
|
KDocUnresolvedReferenceVisitor(holder)
|
||||||
|
|
||||||
|
private class KDocUnresolvedReferenceVisitor(private val holder: ProblemsHolder): PsiElementVisitor() {
|
||||||
|
override fun visitElement(element: PsiElement) {
|
||||||
|
if (element is KDocName) {
|
||||||
|
val ref = element.getReference()
|
||||||
|
if (ref != null && ref.resolve() == null) {
|
||||||
|
holder.registerProblem(ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -832,7 +832,13 @@
|
|||||||
enabledByDefault="true"
|
enabledByDefault="true"
|
||||||
level="WARNING"
|
level="WARNING"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<localInspection implementationClass="org.jetbrains.kotlin.idea.kdoc.KDocUnresolvedReferenceInspection"
|
||||||
|
displayName="Unresolved reference in KDoc"
|
||||||
|
groupName="Kotlin"
|
||||||
|
enabledByDefault="true"
|
||||||
|
level="WARNING"
|
||||||
|
/>
|
||||||
<project.converterProvider implementation="org.jetbrains.kotlin.idea.converters.JetRunConfigurationSettingsFormatConverterProvider"/>
|
<project.converterProvider implementation="org.jetbrains.kotlin.idea.converters.JetRunConfigurationSettingsFormatConverterProvider"/>
|
||||||
|
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|||||||
Reference in New Issue
Block a user