highlight unresolved references in KDoc

This commit is contained in:
Dmitry Jemerov
2015-02-04 18:17:07 +01:00
parent 56d85c2033
commit 66887db42e
3 changed files with 48 additions and 1 deletions
@@ -70,6 +70,8 @@ public class KDocReference(element: KDocName): JetMultiReference<KDocName>(eleme
val newLink = KDocElementFactory(getElement().getProject()).createNameFromText(newText)
return getElement().replace(newLink)
}
override fun getCanonicalText(): String = getElement().getNameText()
}
public fun resolveKDocLink(session: KotlinCodeAnalyzer,
@@ -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)
}
}
}
}
}
+7 -1
View File
@@ -832,7 +832,13 @@
enabledByDefault="true"
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"/>
</extensions>