@@ -2569,4 +2569,232 @@ class ExprParserTest extends SimpleScala3ParserTestBase {
25692569 | PsiWhiteSpace('\n')
25702570 |""" .stripMargin
25712571 )
2572+
2573+ def test_missing_expr (): Unit = checkTree(
2574+ """
2575+ |class A {
2576+ | def foo1 =
2577+ | def foo2: String =
2578+ |
2579+ | val value1 =
2580+ | val value2: String =
2581+ |
2582+ | var variable1 =
2583+ | var variable2: String =
2584+ |
2585+ | def test(param: Int = ) = ()
2586+ |
2587+ | for { x <- } ()
2588+ | for { y <- } ()
2589+ |}
2590+ |
2591+ |""" .stripMargin,
2592+ """
2593+ |ScalaFile
2594+ | PsiWhiteSpace('\n')
2595+ | ScClass: A
2596+ | AnnotationsList
2597+ | <empty list>
2598+ | Modifiers
2599+ | <empty list>
2600+ | PsiElement(class)('class')
2601+ | PsiWhiteSpace(' ')
2602+ | PsiElement(identifier)('A')
2603+ | PrimaryConstructor
2604+ | AnnotationsList
2605+ | <empty list>
2606+ | Modifiers
2607+ | <empty list>
2608+ | Parameters
2609+ | <empty list>
2610+ | PsiWhiteSpace(' ')
2611+ | ExtendsBlock
2612+ | ScTemplateBody
2613+ | PsiElement({)('{')
2614+ | PsiWhiteSpace('\n ')
2615+ | ScFunctionDefinition: foo1
2616+ | AnnotationsList
2617+ | <empty list>
2618+ | Modifiers
2619+ | <empty list>
2620+ | PsiElement(def)('def')
2621+ | PsiWhiteSpace(' ')
2622+ | PsiElement(identifier)('foo1')
2623+ | Parameters
2624+ | <empty list>
2625+ | PsiWhiteSpace(' ')
2626+ | PsiElement(=)('=')
2627+ | PsiErrorElement:Expression expected
2628+ | <empty list>
2629+ | PsiWhiteSpace('\n ')
2630+ | ScFunctionDefinition: foo2
2631+ | AnnotationsList
2632+ | <empty list>
2633+ | Modifiers
2634+ | <empty list>
2635+ | PsiElement(def)('def')
2636+ | PsiWhiteSpace(' ')
2637+ | PsiElement(identifier)('foo2')
2638+ | Parameters
2639+ | <empty list>
2640+ | PsiElement(:)(':')
2641+ | PsiWhiteSpace(' ')
2642+ | SimpleType: String
2643+ | CodeReferenceElement: String
2644+ | PsiElement(identifier)('String')
2645+ | PsiWhiteSpace(' ')
2646+ | PsiElement(=)('=')
2647+ | PsiErrorElement:Wrong expression
2648+ | <empty list>
2649+ | PsiWhiteSpace('\n\n ')
2650+ | ScPatternDefinition: value1
2651+ | AnnotationsList
2652+ | <empty list>
2653+ | Modifiers
2654+ | <empty list>
2655+ | PsiElement(val)('val')
2656+ | PsiWhiteSpace(' ')
2657+ | ListOfPatterns
2658+ | ReferencePattern: value1
2659+ | PsiElement(identifier)('value1')
2660+ | PsiWhiteSpace(' ')
2661+ | PsiElement(=)('=')
2662+ | PsiErrorElement:Expression expected
2663+ | <empty list>
2664+ | PsiWhiteSpace('\n ')
2665+ | ScPatternDefinition: value2
2666+ | AnnotationsList
2667+ | <empty list>
2668+ | Modifiers
2669+ | <empty list>
2670+ | PsiElement(val)('val')
2671+ | PsiWhiteSpace(' ')
2672+ | ListOfPatterns
2673+ | ReferencePattern: value2
2674+ | PsiElement(identifier)('value2')
2675+ | PsiElement(:)(':')
2676+ | PsiWhiteSpace(' ')
2677+ | SimpleType: String
2678+ | CodeReferenceElement: String
2679+ | PsiElement(identifier)('String')
2680+ | PsiWhiteSpace(' ')
2681+ | PsiElement(=)('=')
2682+ | PsiErrorElement:Expression expected
2683+ | <empty list>
2684+ | PsiWhiteSpace('\n\n ')
2685+ | ScVariableDefinition: variable1
2686+ | AnnotationsList
2687+ | <empty list>
2688+ | Modifiers
2689+ | <empty list>
2690+ | PsiElement(var)('var')
2691+ | PsiWhiteSpace(' ')
2692+ | ListOfPatterns
2693+ | ReferencePattern: variable1
2694+ | PsiElement(identifier)('variable1')
2695+ | PsiWhiteSpace(' ')
2696+ | PsiElement(=)('=')
2697+ | PsiErrorElement:Expression expected
2698+ | <empty list>
2699+ | PsiWhiteSpace('\n ')
2700+ | ScVariableDefinition: variable2
2701+ | AnnotationsList
2702+ | <empty list>
2703+ | Modifiers
2704+ | <empty list>
2705+ | PsiElement(var)('var')
2706+ | PsiWhiteSpace(' ')
2707+ | ListOfPatterns
2708+ | ReferencePattern: variable2
2709+ | PsiElement(identifier)('variable2')
2710+ | PsiElement(:)(':')
2711+ | PsiWhiteSpace(' ')
2712+ | SimpleType: String
2713+ | CodeReferenceElement: String
2714+ | PsiElement(identifier)('String')
2715+ | PsiWhiteSpace(' ')
2716+ | PsiElement(=)('=')
2717+ | PsiErrorElement:Expression expected
2718+ | <empty list>
2719+ | PsiWhiteSpace('\n\n ')
2720+ | ScFunctionDefinition: test
2721+ | AnnotationsList
2722+ | <empty list>
2723+ | Modifiers
2724+ | <empty list>
2725+ | PsiElement(def)('def')
2726+ | PsiWhiteSpace(' ')
2727+ | PsiElement(identifier)('test')
2728+ | Parameters
2729+ | ParametersClause
2730+ | PsiElement(()('(')
2731+ | Parameter: param
2732+ | AnnotationsList
2733+ | <empty list>
2734+ | Modifiers
2735+ | <empty list>
2736+ | PsiElement(identifier)('param')
2737+ | PsiElement(:)(':')
2738+ | PsiWhiteSpace(' ')
2739+ | ParameterType
2740+ | SimpleType: Int
2741+ | CodeReferenceElement: Int
2742+ | PsiElement(identifier)('Int')
2743+ | PsiWhiteSpace(' ')
2744+ | PsiElement(=)('=')
2745+ | PsiErrorElement:Expression expected
2746+ | <empty list>
2747+ | PsiWhiteSpace(' ')
2748+ | PsiElement())(')')
2749+ | PsiWhiteSpace(' ')
2750+ | PsiElement(=)('=')
2751+ | PsiWhiteSpace(' ')
2752+ | UnitExpression
2753+ | PsiElement(()('(')
2754+ | PsiElement())(')')
2755+ | PsiWhiteSpace('\n\n ')
2756+ | ForStatement
2757+ | PsiElement(for)('for')
2758+ | PsiWhiteSpace(' ')
2759+ | PsiElement({)('{')
2760+ | PsiWhiteSpace(' ')
2761+ | Enumerators
2762+ | Generator
2763+ | ReferencePattern: x
2764+ | PsiElement(identifier)('x')
2765+ | PsiWhiteSpace(' ')
2766+ | PsiElement(<-)('<-')
2767+ | PsiErrorElement:Wrong expression
2768+ | <empty list>
2769+ | PsiWhiteSpace(' ')
2770+ | PsiElement(})('}')
2771+ | PsiWhiteSpace(' ')
2772+ | UnitExpression
2773+ | PsiElement(()('(')
2774+ | PsiElement())(')')
2775+ | PsiWhiteSpace('\n ')
2776+ | ForStatement
2777+ | PsiElement(for)('for')
2778+ | PsiWhiteSpace(' ')
2779+ | PsiElement({)('{')
2780+ | PsiWhiteSpace(' ')
2781+ | Enumerators
2782+ | Generator
2783+ | ReferencePattern: y
2784+ | PsiElement(identifier)('y')
2785+ | PsiWhiteSpace(' ')
2786+ | PsiElement(<-)('<-')
2787+ | PsiErrorElement:Wrong expression
2788+ | <empty list>
2789+ | PsiWhiteSpace(' ')
2790+ | PsiElement(})('}')
2791+ | PsiWhiteSpace(' ')
2792+ | UnitExpression
2793+ | PsiElement(()('(')
2794+ | PsiElement())(')')
2795+ | PsiWhiteSpace('\n')
2796+ | PsiElement(})('}')
2797+ | PsiWhiteSpace('\n\n')
2798+ |""" .stripMargin
2799+ )
25722800}
0 commit comments