2017-04-11 1 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'" 필자는 Autocompletion을 매우 실용적인 방식으로 관리했습니다.

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)); 
    } 
} 

이로 인해 예상되는 동작이 발생합니다. 이것이 다른 사람들을 돕고 더 좋은 해결책이 있다면 알려주 길 바란다.

관련 문제