mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
PY-24685 Code Inspect for rst files does not recognize Multi character foot note references when target is under a rubric directive ..
This commit is contained in:
@@ -33,6 +33,10 @@ public class RestParsingTest extends ParsingTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testDirectiveWithNewLine() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
protected String getTestDataPath() {
|
||||
return PythonHelpersLocator.getPythonCommunityPath() + "/python-rest/testData/psi";
|
||||
}
|
||||
|
||||
6
python/python-rest/testData/psi/DirectiveWithNewLine.rst
Normal file
6
python/python-rest/testData/psi/DirectiveWithNewLine.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer rutrum ex non sapien consequat, sit amet viverra nisl semper. Duis vestibulum vestibulum lacus eget dictum.
|
||||
[#Footnote]_
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
||||
.. [#Footnote]
|
||||
16
python/python-rest/testData/psi/DirectiveWithNewLine.txt
Normal file
16
python/python-rest/testData/psi/DirectiveWithNewLine.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
rest file
|
||||
RestLine:LINE_TEXT
|
||||
PsiElement(LINE)('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer rutrum ex non sapien consequat, sit amet viverra nisl semper. Duis vestibulum vestibulum lacus eget dictum.')
|
||||
PsiElement(WHITESPACE)('\n')
|
||||
PsiElement(LINE)(' ')
|
||||
RestReference:REFERENCE_NAME
|
||||
PsiElement(REFERENCE_NAME)('[#Footnote]_')
|
||||
PsiElement(WHITESPACE)('\n\n')
|
||||
PsiElement(EXPLISIT_MARKUP_START)('.. ')
|
||||
RestDirective:DIRECTIVE_BLOCK
|
||||
PsiElement(DIRECTIVE)('rubric::')
|
||||
PsiElement(LINE)(' Footnotes')
|
||||
PsiElement(WHITESPACE)('\n\n')
|
||||
PsiElement(EXPLISIT_MARKUP_START)('.. ')
|
||||
RestReferenceTarget:REFERENCE
|
||||
PsiElement(FOOTNOTE)('[#Footnote]')
|
||||
@@ -18,6 +18,7 @@ package com.jetbrains.rest.parsing;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.PsiParser;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.jetbrains.rest.RestElementTypes;
|
||||
import com.jetbrains.rest.RestTokenTypes;
|
||||
@@ -62,8 +63,9 @@ public class RestParser implements PsiParser {
|
||||
else if (type == RestTokenTypes.LINE) {
|
||||
parseLineText(builder, type);
|
||||
}
|
||||
else
|
||||
else {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
}
|
||||
rootMarker.done(root);
|
||||
return builder.getTreeBuilt();
|
||||
@@ -77,10 +79,12 @@ public class RestParser implements PsiParser {
|
||||
type = builder.getTokenType();
|
||||
gotLine = true;
|
||||
}
|
||||
if (gotLine)
|
||||
if (gotLine) {
|
||||
marker.done(RestElementTypes.LINE_TEXT);
|
||||
else
|
||||
}
|
||||
else {
|
||||
marker.drop();
|
||||
}
|
||||
return gotLine;
|
||||
}
|
||||
|
||||
@@ -89,10 +93,12 @@ public class RestParser implements PsiParser {
|
||||
PsiBuilder.Marker marker = builder.mark();
|
||||
builder.advanceLexer();
|
||||
marker.done(RestTokenTypes.FIELD);
|
||||
if (parseLineText(builder, builder.getTokenType()))
|
||||
if (parseLineText(builder, builder.getTokenType())) {
|
||||
listMarker.done(RestElementTypes.FIELD_LIST);
|
||||
else
|
||||
}
|
||||
else {
|
||||
listMarker.drop();
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseMarkup(PsiBuilder builder) {
|
||||
@@ -113,7 +119,9 @@ public class RestParser implements PsiParser {
|
||||
return;
|
||||
}
|
||||
skipBlankLines(builder);
|
||||
if (builder.getTokenType() != RestTokenTypes.WHITESPACE || "\n".equals(builder.getTokenText())) {
|
||||
final String tokenText = builder.getTokenText();
|
||||
if (builder.getTokenType() != RestTokenTypes.WHITESPACE ||
|
||||
(tokenText != null && StringUtil.getLineBreakCount(tokenText) == tokenText.length())) {
|
||||
marker.done(RestElementTypes.DIRECTIVE_BLOCK);
|
||||
return;
|
||||
}
|
||||
@@ -132,14 +140,14 @@ public class RestParser implements PsiParser {
|
||||
}
|
||||
|
||||
private static void gotoNextWhiteSpaces(PsiBuilder builder) {
|
||||
while(!"\n".equals(builder.getTokenText()) && !(builder.getTokenType() == RestTokenTypes.TITLE) && !builder.eof() && (builder.getTokenType() != null)) {
|
||||
builder.advanceLexer();
|
||||
while (!StringUtil.isEmptyOrSpaces(builder.getTokenText()) && !builder.eof() && (builder.getTokenType() != null)) {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
}
|
||||
|
||||
private static void skipBlankLines(PsiBuilder builder) {
|
||||
while("\n".equals(builder.getTokenText()) && !builder.eof() && (builder.getTokenType() != null)) {
|
||||
builder.advanceLexer();
|
||||
while ("\n".equals(builder.getTokenText()) && !builder.eof() && (builder.getTokenType() != null)) {
|
||||
builder.advanceLexer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user