[Parser] Support of parsing until operator
^KT-52419 Fixed
This commit is contained in:
committed by
teamcity
parent
7360dff0da
commit
19136019e4
@@ -6,13 +6,14 @@ import com.intellij.lexer.FlexLexer;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import java.lang.Character;
|
||||
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag;
|
||||
|
||||
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.7.0
|
||||
* from the specification file <tt>/Users/jetbrains/projects/dup_kotlin/kotlin/compiler/psi/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex</tt>
|
||||
* from the specification file <tt>/Users/victor.petukhov/IdeaProjects/kotlin-jps/compiler/psi/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex</tt>
|
||||
*/
|
||||
class _KDocLexer implements FlexLexer {
|
||||
|
||||
@@ -417,7 +418,7 @@ class _KDocLexer implements FlexLexer {
|
||||
/**
|
||||
* Refills the input buffer.
|
||||
*
|
||||
* @return <code>false</code>, iff there was new input.
|
||||
* @return {@code false}, iff there was new input.
|
||||
*
|
||||
* @exception java.io.IOException if any I/O-Error occurs
|
||||
*/
|
||||
@@ -453,7 +454,7 @@ class _KDocLexer implements FlexLexer {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the character at position <tt>pos</tt> from the
|
||||
* Returns the character at position {@code pos} from the
|
||||
* matched text.
|
||||
*
|
||||
* It is equivalent to yytext().charAt(pos), but faster
|
||||
|
||||
@@ -296,6 +296,7 @@ LONELY_BACKTICK=`
|
||||
"->" { return KtTokens.ARROW ; }
|
||||
"=>" { return KtTokens.DOUBLE_ARROW; }
|
||||
".." { return KtTokens.RANGE ; }
|
||||
"..<" { return KtTokens.RANGE_UNTIL; }
|
||||
"::" { return KtTokens.COLONCOLON; }
|
||||
"[" { return KtTokens.LBRACKET ; }
|
||||
"]" { return KtTokens.RBRACKET ; }
|
||||
|
||||
@@ -125,6 +125,7 @@ public interface KtTokens {
|
||||
KtSingleValueToken SEMICOLON = new KtSingleValueToken("SEMICOLON", ";");
|
||||
KtSingleValueToken DOUBLE_SEMICOLON = new KtSingleValueToken("DOUBLE_SEMICOLON", ";;");
|
||||
KtSingleValueToken RANGE = new KtSingleValueToken("RANGE", "..");
|
||||
KtSingleValueToken RANGE_UNTIL = new KtSingleValueToken("RANGE_UNTIL", "..<");
|
||||
KtSingleValueToken EQ = new KtSingleValueToken("EQ", "=");
|
||||
KtSingleValueToken MULTEQ = new KtSingleValueToken("MULTEQ", "*=");
|
||||
KtSingleValueToken DIVEQ = new KtSingleValueToken("DIVEQ", "/=");
|
||||
@@ -264,7 +265,7 @@ public interface KtTokens {
|
||||
TokenSet OPERATIONS = TokenSet.create(AS_KEYWORD, AS_SAFE, IS_KEYWORD, IN_KEYWORD, DOT, PLUSPLUS, MINUSMINUS, EXCLEXCL, MUL, PLUS,
|
||||
MINUS, EXCL, DIV, PERC, LT, GT, LTEQ, GTEQ, EQEQEQ, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR,
|
||||
SAFE_ACCESS, ELVIS,
|
||||
RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ,
|
||||
RANGE, RANGE_UNTIL, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ,
|
||||
NOT_IN, NOT_IS,
|
||||
IDENTIFIER);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -70,7 +70,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
|
||||
PLUS, MINUS, EXCL, DIV, PERC, LTEQ,
|
||||
// TODO GTEQ, foo<bar, baz>=x
|
||||
EQEQEQ, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR, SAFE_ACCESS, ELVIS,
|
||||
SEMICOLON, RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ, NOT_IN, NOT_IS,
|
||||
SEMICOLON, RANGE, RANGE_UNTIL, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ, NOT_IN, NOT_IS,
|
||||
COLONCOLON,
|
||||
COLON
|
||||
);
|
||||
@@ -170,7 +170,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
|
||||
|
||||
MULTIPLICATIVE(MUL, DIV, PERC),
|
||||
ADDITIVE(PLUS, MINUS),
|
||||
RANGE(KtTokens.RANGE),
|
||||
RANGE(KtTokens.RANGE, RANGE_UNTIL),
|
||||
SIMPLE_NAME(IDENTIFIER),
|
||||
ELVIS(KtTokens.ELVIS),
|
||||
IN_OR_IS(IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fun main() {
|
||||
for (i in 0..<n) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
KtFile: untilOperator.kt
|
||||
PACKAGE_DIRECTIVE
|
||||
<empty list>
|
||||
IMPORT_LIST
|
||||
<empty list>
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('main')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('i')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(in)('in')
|
||||
PsiWhiteSpace(' ')
|
||||
LOOP_RANGE
|
||||
BINARY_EXPRESSION
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('0')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(RANGE_UNTIL)('..<')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('n')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
@@ -1839,6 +1839,24 @@ public class ParsingTestGenerated extends AbstractParsingTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/psi/operators")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Operators extends AbstractParsingTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doParsingTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInOperators() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/psi/operators"), Pattern.compile("^(.*)\\.kts?$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("untilOperator.kt")
|
||||
public void testUntilOperator() throws Exception {
|
||||
runTest("compiler/testData/psi/operators/untilOperator.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/psi/packages")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user