Tutorial - Generated parser code error

Hello,

I'm following the tutorial here and I'm getting an error on the generated code:

// This is a generated file. Not intended for manual editing.
package org.tutorial.psi;

import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;

public interface MyPlaceHolder extends PsiElement {

@NotNull
PsiElement getText();

}

The compiler throws the following error:

    Error:(11, 14) java: getText() in org.tutorial.psi.MyPlaceHolder clashes with getText() in com.intellij.psi.PsiElement
    return type com.intellij.psi.PsiElement is not compatible with java.lang.String

My platform SDF is configured with "IntelliJ IDEA Community Edition IC-181.4203.550".

If I change the element in my BNF from

placeHolder ::= '[' text ']'

to

placeHolder ::= ( '[' text ']' ) *

it generates valid code, but then my definition fails.

My guess is that the version used by the parser generation is different from the one used by the IDE to compile. Where should I look?

0

Okay, found the problem - one shouldn't use `text` as a Token name. I guess this applies to any token name that may cause a clash with existing methods.

0

请先登录再写评论。