2017-04-11 9 views

答えて

0

: - END、NAMEおよびTITLE示唆すべきROOT後に自動補完ホットキーを押す

RootObject ::= ROOT (NameAttr | TitleAttr)* END 
private NameAttr ::= NAME string 
private TitleAttr ::= TITLE string 

明確に文法ここで

で定義されている完全な文法へのリンクですPsiElementに既に以下のような一般的なエラーの説明が含まれていることを確認してください。"FooTokenType.NAME, FooTokenType.TITLE or FooTokenType.END expected, got 'IntellijIdeaRulezzz'"私は非常に宣言的な方法でオートコンプリートを管理しています:

public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) { 
    PsiElement element = parameters.getPosition().getParent(); 
    String genericErrorDescription = ((PsiErrorElementImpl) element).getErrorDescription(); 
    errorDescription = errorDescription.substring(0, errorDescription.indexOf(" expected, got ")); 
    errorDescription = errorDescription.replaceAll("FooTokenType\\.", ""); 
    String[] suggestedTokens = errorDescription.split("(,)|(or)"); 
    for (String suggestedToken : suggestedTokens) { 
     resultSet.addElement(LookupElementBuilder.create(suggestedToken)); 
    } 
} 

予想される動作が発生します。私はこれが他人を助けてくれることを願っています。もっと良い解決策があれば教えてください。

関連する問題