highlight links in KDoc; correctly highlight first word following tag name
This commit is contained in:
@@ -66,6 +66,6 @@ public interface KDocTokens {
|
|||||||
|
|
||||||
KDocToken MARKDOWN_ESCAPED_CHAR = new KDocToken("KDOC_MARKDOWN_ESCAPED_CHAR");
|
KDocToken MARKDOWN_ESCAPED_CHAR = new KDocToken("KDOC_MARKDOWN_ESCAPED_CHAR");
|
||||||
|
|
||||||
TokenSet KDOC_HIGHLIGHT_TOKENS = TokenSet.create(START, END, LEADING_ASTERISK, TEXT, MARKDOWN_LINK, MARKDOWN_ESCAPED_CHAR);
|
TokenSet KDOC_HIGHLIGHT_TOKENS = TokenSet.create(START, END, LEADING_ASTERISK, TEXT, MARKDOWN_LINK, MARKDOWN_ESCAPED_CHAR, TEXT_OR_LINK);
|
||||||
TokenSet CONTENT_TOKENS = TokenSet.create(TEXT, TAG_NAME, MARKDOWN_LINK, MARKDOWN_ESCAPED_CHAR, TEXT_OR_LINK);
|
TokenSet CONTENT_TOKENS = TokenSet.create(TEXT, TAG_NAME, MARKDOWN_LINK, MARKDOWN_ESCAPED_CHAR, TEXT_OR_LINK);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.highlighter;
|
|||||||
import com.intellij.lang.annotation.AnnotationHolder;
|
import com.intellij.lang.annotation.AnnotationHolder;
|
||||||
import org.jetbrains.kotlin.psi.JetVisitorVoid;
|
import org.jetbrains.kotlin.psi.JetVisitorVoid;
|
||||||
|
|
||||||
abstract class HighlightingVisitor extends JetVisitorVoid {
|
public abstract class HighlightingVisitor extends JetVisitorVoid {
|
||||||
protected AnnotationHolder holder;
|
protected AnnotationHolder holder;
|
||||||
|
|
||||||
protected HighlightingVisitor(AnnotationHolder holder) {
|
protected HighlightingVisitor(AnnotationHolder holder) {
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
|||||||
import org.jetbrains.kotlin.idea.caches.resolve.*
|
import org.jetbrains.kotlin.idea.caches.resolve.*
|
||||||
import org.jetbrains.kotlin.idea.quickfix.QuickFixes
|
import org.jetbrains.kotlin.idea.quickfix.QuickFixes
|
||||||
import kotlin.platform.platformStatic
|
import kotlin.platform.platformStatic
|
||||||
|
import org.jetbrains.kotlin.idea.kdoc.KDocHighlightingVisitor
|
||||||
|
|
||||||
public open class JetPsiChecker : Annotator, HighlightRangeExtension {
|
public open class JetPsiChecker : Annotator, HighlightRangeExtension {
|
||||||
|
|
||||||
@@ -214,7 +215,8 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension {
|
|||||||
|
|
||||||
private fun getBeforeAnalysisVisitors(holder: AnnotationHolder) = array(
|
private fun getBeforeAnalysisVisitors(holder: AnnotationHolder) = array(
|
||||||
SoftKeywordsHighlightingVisitor(holder),
|
SoftKeywordsHighlightingVisitor(holder),
|
||||||
LabelsHighlightingVisitor(holder)
|
LabelsHighlightingVisitor(holder),
|
||||||
|
KDocHighlightingVisitor(holder)
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun getAfterAnalysisVisitor(holder: AnnotationHolder, bindingContext: BindingContext) = array(
|
private fun getAfterAnalysisVisitor(holder: AnnotationHolder, bindingContext: BindingContext) = array(
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.highlighter.HighlightingVisitor
|
||||||
|
import com.intellij.lang.annotation.AnnotationHolder
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.kdoc.psi.impl.KDocLink
|
||||||
|
import org.jetbrains.kotlin.idea.highlighter.JetHighlightingColors
|
||||||
|
|
||||||
|
class KDocHighlightingVisitor(holder: AnnotationHolder): HighlightingVisitor(holder) {
|
||||||
|
override fun visitElement(element: PsiElement) {
|
||||||
|
if (element is KDocLink) {
|
||||||
|
holder.createInfoAnnotation(element, null).setTextAttributes(JetHighlightingColors.KDOC_TAG_VALUE)
|
||||||
|
}
|
||||||
|
super.visitElement(element)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* @param <info descr="null" textAttributesKey="KDOC_TAG_VALUE">x</info> foo and <info descr="null" textAttributesKey="KDOC_TAG_VALUE">[baz]</info>
|
||||||
|
* @param <info descr="null" textAttributesKey="KDOC_TAG_VALUE">y</info> bar
|
||||||
|
* @return notALink here
|
||||||
|
*/
|
||||||
|
fun <info descr="null">f</info>(<info descr="null">x</info>: <info descr="null">Int</info>, <info descr="null">y</info>: <info descr="null">Int</info>): <info descr="null">Int</info> {
|
||||||
|
return <info descr="null">x</info> + <info descr="null">y</info>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <info descr="null">baz</info>() {}
|
||||||
@@ -61,6 +61,12 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("KDoc.kt")
|
||||||
|
public void testKDoc() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/highlighter/KDoc.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("Object.kt")
|
@TestMetadata("Object.kt")
|
||||||
public void testObject() throws Exception {
|
public void testObject() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/highlighter/Object.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/highlighter/Object.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user