don't parse links which aren't Kotlin identifiers and have an explicitly specified destination

This commit is contained in:
Dmitry Jemerov
2015-02-04 19:17:22 +01:00
parent 1ab51a08aa
commit 56d85c2033
5 changed files with 132 additions and 97 deletions
@@ -114,8 +114,10 @@ CODE_LINK=\[{CODE_LINK_START}{CODE_LINK_CHAR}*\]
/* We're only interested in parsing links that can become code references,
meaning they contain only identifier characters and characters that can be
used in type declarations. No brackets, backticks, asterisks or anything like that. */
{CODE_LINK} { yybegin(CONTENTS);
used in type declarations. No brackets, backticks, asterisks or anything like that.
Also if a link is followed by [ or (, then its destination is a regular HTTP
link and not a Kotlin identifier, so we don't need to do our parsing and resolution. */
{CODE_LINK} / [^\(\[] { yybegin(CONTENTS);
return KDocTokens.MARKDOWN_LINK; }
. { yybegin(CONTENTS);
@@ -14,7 +14,7 @@
* limitations under the License.
*/
/* The following code was generated by JFlex 1.4.3 on 2/3/15 2:37 PM */
/* The following code was generated by JFlex 1.4.3 on 2/4/15 7:15 PM */
package org.jetbrains.kotlin.kdoc.lexer;
@@ -28,7 +28,7 @@ import java.lang.Character;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
* on 2/3/15 2:37 PM from the specification file
* on 2/4/15 7:15 PM from the specification file
* <tt>/Users/yole/jetbrains/kotlin/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex</tt>
*/
class _KDocLexer implements FlexLexer {
@@ -56,67 +56,67 @@ class _KDocLexer implements FlexLexer {
* Translates characters to character classes
*/
private static final String ZZ_CMAP_PACKED =
"\11\0\1\1\1\12\1\0\2\1\22\0\1\1\3\0\1\3\5\0"+
"\1\10\3\0\1\4\1\7\12\2\6\0\1\11\32\3\1\5\1\13"+
"\1\6\1\0\1\3\1\0\32\3\47\0\4\3\4\0\1\3\12\0"+
"\1\3\4\0\1\3\5\0\27\3\1\0\37\3\1\0\u013f\3\31\0"+
"\162\3\4\0\14\3\16\0\5\3\11\0\1\3\213\0\1\3\13\0"+
"\1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5\3\2\0\5\3\4\0\126\3\6\0"+
"\3\3\1\0\137\3\5\0\50\3\4\0\136\3\21\0\30\3\70\0"+
"\20\3\u0200\0\u19b6\3\112\0\u51a6\3\132\0\u048d\3\u0773\0\u2ba4\3\u215c\0"+
"\u012e\3\2\0\73\3\225\0\7\3\14\0\5\3\5\0\1\3\1\0"+
"\12\3\1\0\15\3\1\0\5\3\1\0\1\3\1\0\2\3\1\0"+
"\2\3\1\0\154\3\41\0\u016b\3\22\0\100\3\2\0\66\3\50\0"+
"\15\3\66\0\2\3\30\0\3\3\31\0\1\3\6\0\5\3\1\0"+
"\207\3\7\0\1\3\34\0\32\3\4\0\1\3\1\0\32\3\12\0"+
"\132\3\3\0\6\3\2\0\6\3\2\0\6\3\2\0\3\3\3\0"+
"\2\3\3\0\2\3\31\0";
"\11\0\1\1\1\12\1\0\2\1\22\0\1\1\3\0\1\3\3\0"+
"\1\14\1\0\1\10\3\0\1\4\1\7\12\2\6\0\1\11\32\3"+
"\1\5\1\13\1\6\1\0\1\3\1\0\32\3\47\0\4\3\4\0"+
"\1\3\12\0\1\3\4\0\1\3\5\0\27\3\1\0\37\3\1\0"+
"\u013f\3\31\0\162\3\4\0\14\3\16\0\5\3\11\0\1\3\213\0"+
"\1\3\13\0\1\3\1\0\3\3\1\0\1\3\1\0\24\3\1\0"+
"\54\3\1\0\46\3\1\0\5\3\4\0\202\3\10\0\105\3\1\0"+
"\46\3\2\0\2\3\6\0\20\3\41\0\46\3\2\0\1\3\7\0"+
"\47\3\110\0\33\3\5\0\3\3\56\0\32\3\5\0\13\3\43\0"+
"\2\3\1\0\143\3\1\0\1\3\17\0\2\3\7\0\2\3\12\0"+
"\3\3\2\0\1\3\20\0\1\3\1\0\36\3\35\0\3\3\60\0"+
"\46\3\13\0\1\3\u0152\0\66\3\3\0\1\3\22\0\1\3\7\0"+
"\12\3\43\0\10\3\2\0\2\3\2\0\26\3\1\0\7\3\1\0"+
"\1\3\3\0\4\3\3\0\1\3\36\0\2\3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"+
"\4\3\2\0\7\3\1\0\7\3\1\0\27\3\1\0\37\3\1\0"+
"\1\3\1\0\4\3\2\0\7\3\1\0\47\3\1\0\23\3\105\0"+
"\125\3\14\0\u026c\3\2\0\10\3\12\0\32\3\5\0\113\3\3\0"+
"\3\3\17\0\15\3\1\0\4\3\16\0\22\3\16\0\22\3\16\0"+
"\15\3\1\0\3\3\17\0\64\3\43\0\1\3\3\0\2\3\103\0"+
"\130\3\10\0\51\3\127\0\35\3\63\0\36\3\2\0\5\3\u038b\0"+
"\154\3\224\0\234\3\4\0\132\3\6\0\26\3\2\0\6\3\2\0"+
"\46\3\2\0\6\3\2\0\10\3\1\0\1\3\1\0\1\3\1\0"+
"\1\3\1\0\37\3\2\0\65\3\1\0\7\3\1\0\1\3\3\0"+
"\3\3\1\0\7\3\3\0\4\3\2\0\6\3\4\0\15\3\5\0"+
"\3\3\1\0\7\3\102\0\2\3\23\0\1\3\34\0\1\3\15\0"+
"\1\3\40\0\22\3\120\0\1\3\4\0\1\3\2\0\12\3\1\0"+
"\1\3\3\0\5\3\6\0\1\3\1\0\1\3\1\0\1\3\1\0"+
"\4\3\1\0\3\3\1\0\7\3\3\0\3\3\5\0\5\3\26\0"+
"\44\3\u0e81\0\3\3\31\0\11\3\7\0\5\3\2\0\5\3\4\0"+
"\126\3\6\0\3\3\1\0\137\3\5\0\50\3\4\0\136\3\21\0"+
"\30\3\70\0\20\3\u0200\0\u19b6\3\112\0\u51a6\3\132\0\u048d\3\u0773\0"+
"\u2ba4\3\u215c\0\u012e\3\2\0\73\3\225\0\7\3\14\0\5\3\5\0"+
"\1\3\1\0\12\3\1\0\15\3\1\0\5\3\1\0\1\3\1\0"+
"\2\3\1\0\2\3\1\0\154\3\41\0\u016b\3\22\0\100\3\2\0"+
"\66\3\50\0\15\3\66\0\2\3\30\0\3\3\31\0\1\3\6\0"+
"\5\3\1\0\207\3\7\0\1\3\34\0\32\3\4\0\1\3\1\0"+
"\32\3\12\0\132\3\3\0\6\3\2\0\6\3\2\0\6\3\2\0"+
"\3\3\3\0\2\3\3\0\2\3\31\0";
/**
* Translates characters to character classes
@@ -131,10 +131,10 @@ class _KDocLexer implements FlexLexer {
private static final String ZZ_ACTION_PACKED_0 =
"\5\0\3\1\1\2\1\3\1\2\1\4\3\2\1\5"+
"\1\6\1\7\2\5\1\0\1\10\2\0\1\11\1\12"+
"\1\13\1\14";
"\1\0\1\13\1\0\1\14\1\15";
private static int [] zzUnpackAction() {
int [] result = new int[28];
int [] result = new int[31];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -159,13 +159,13 @@ class _KDocLexer implements FlexLexer {
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
"\0\0\0\14\0\30\0\44\0\60\0\74\0\110\0\124"+
"\0\74\0\140\0\154\0\170\0\204\0\124\0\220\0\74"+
"\0\234\0\250\0\154\0\124\0\264\0\74\0\124\0\300"+
"\0\74\0\314\0\74\0\74";
"\0\0\0\15\0\32\0\47\0\64\0\101\0\116\0\133"+
"\0\101\0\150\0\165\0\202\0\217\0\133\0\234\0\101"+
"\0\251\0\266\0\303\0\133\0\320\0\101\0\133\0\335"+
"\0\101\0\352\0\367\0\101\0\u0104\0\101\0\101";
private static int [] zzUnpackRowMap() {
int [] result = new int[28];
int [] result = new int[31];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -188,19 +188,21 @@ class _KDocLexer implements FlexLexer {
private static final int [] ZZ_TRANS = zzUnpackTrans();
private static final String ZZ_TRANS_PACKED_0 =
"\7\6\1\7\1\10\1\6\1\0\1\6\1\11\1\12"+
"\3\11\1\13\2\11\1\14\1\11\1\12\1\15\1\11"+
"\7\6\1\7\1\10\1\6\1\0\2\6\1\11\1\12"+
"\3\11\1\13\2\11\1\14\1\11\1\12\1\15\2\11"+
"\1\12\3\11\1\13\2\11\1\16\1\17\1\12\1\15"+
"\1\20\1\21\1\20\1\22\1\20\1\23\2\20\1\24"+
"\1\20\1\21\1\20\1\11\1\12\3\11\1\13\2\11"+
"\1\16\1\11\1\12\1\15\24\0\1\25\12\0\1\26"+
"\1\27\4\0\1\12\10\0\1\12\4\0\1\30\17\0"+
"\1\26\1\14\10\0\2\31\10\0\1\32\11\0\1\21"+
"\10\0\1\21\3\0\3\22\17\0\1\33\5\0\3\30"+
"\1\0\1\34\7\0\2\32\10\0";
"\1\11\1\20\1\21\1\20\1\22\1\20\1\23\2\20"+
"\1\24\1\20\1\21\2\20\1\11\1\12\3\11\1\13"+
"\2\11\1\16\1\11\1\12\1\15\1\11\25\0\1\25"+
"\13\0\1\26\1\27\5\0\1\12\10\0\1\12\5\0"+
"\1\30\20\0\1\26\1\14\11\0\2\31\11\0\1\32"+
"\12\0\1\21\10\0\1\21\4\0\3\22\13\0\1\33"+
"\21\0\1\34\6\0\3\30\1\0\1\35\10\0\2\32"+
"\13\0\3\33\1\0\1\36\6\0\5\37\1\0\6\37"+
"\1\0";
private static int [] zzUnpackTrans() {
int [] result = new int[216];
int [] result = new int[273];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
@@ -242,10 +244,10 @@ class _KDocLexer implements FlexLexer {
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\5\0\1\11\2\1\1\11\6\1\1\11\4\1\1\0"+
"\1\11\2\0\1\11\1\1\2\11";
"\1\11\2\0\1\11\1\1\1\0\1\11\1\0\2\11";
private static int [] zzUnpackAttribute() {
int [] result = new int[28];
int [] result = new int[31];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
@@ -349,7 +351,7 @@ class _KDocLexer implements FlexLexer {
char [] map = new char[0x10000];
int i = 0; /* index in packed string */
int j = 0; /* index in unpacked array */
while (i < 1208) {
while (i < 1212) {
int count = packed.charAt(i++);
char value = packed.charAt(i++);
do map[j++] = value; while (--count > 0);
@@ -581,63 +583,70 @@ class _KDocLexer implements FlexLexer {
return KDocTokens.TEXT; // internal white space
}
}
case 13: break;
case 14: break;
case 11:
{ yybegin(CONTENTS_BEGINNING);
return KDocTokens.START;
}
case 14: break;
case 15: break;
case 7:
{ yybegin(CONTENTS);
return KDocTokens.TEXT_OR_LINK;
}
case 15: break;
case 16: break;
case 8:
{ if (isLastToken()) return KDocTokens.END;
else return KDocTokens.TEXT;
}
case 16: break;
case 17: break;
case 5:
{ yybegin(CONTENTS);
return KDocTokens.TEXT;
}
case 17: break;
case 18: break;
case 6:
{ if (yytextContainLineBreaks()) {
yybegin(LINE_BEGINNING);
}
return TokenType.WHITE_SPACE;
}
case 18: break;
case 19: break;
case 13:
// lookahead expression with fixed lookahead length
yypushback(1);
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_LINK;
}
case 20: break;
case 12:
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_LINK;
}
case 19: break;
case 21: break;
case 10:
{ yybegin(TAG_BEGINNING);
return KDocTokens.TAG_NAME;
}
case 20: break;
case 22: break;
case 1:
{ return TokenType.BAD_CHARACTER;
}
case 21: break;
case 23: break;
case 9:
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
}
case 22: break;
case 24: break;
case 2:
{ yybegin(CONTENTS);
return KDocTokens.TEXT;
}
case 23: break;
case 25: break;
case 4:
{ yybegin(CONTENTS_BEGINNING);
return KDocTokens.LEADING_ASTERISK;
}
case 24: break;
case 26: break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
zzAtEOF = true;
+4
View File
@@ -0,0 +1,4 @@
/**
* [Kotlin](http://kotlinlang.org) is made by [JetBrains][1]
* [1]: http://www.jetbrains.com/
*/
+14
View File
@@ -0,0 +1,14 @@
JetFile: HttpLink.kt
PACKAGE_DIRECTIVE
<empty list>
KDoc
PsiElement(KDOC_START)('/**')
PsiWhiteSpace('\n ')
KDOC_SECTION
PsiElement(KDOC_LEADING_ASTERISK)('*')
PsiElement(KDOC_TEXT)(' [Kotlin](http://kotlinlang.org) is made by [JetBrains][1]')
PsiWhiteSpace('\n ')
PsiElement(KDOC_LEADING_ASTERISK)('*')
PsiElement(KDOC_TEXT)(' [1]: http://www.jetbrains.com/')
PsiWhiteSpace('\n ')
PsiElement(KDOC_END)('*/')
@@ -1073,6 +1073,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
doParsingTest(fileName);
}
@TestMetadata("HttpLink.kt")
public void testHttpLink() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/kdoc/HttpLink.kt");
doParsingTest(fileName);
}
@TestMetadata("Incomplete.kt")
public void testIncomplete() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/kdoc/Incomplete.kt");