2014-06-24 2 views
1

참조 된 요소를 구문 분석 할 수 없기 때문에 모델의 구문 오류로 인해 잘못된 연결 오류가 발생할 수 있습니다. 이러한 잘못된 연결 오류로 인해 사용자가 산만 해지고 근본 원인을 진단하기가 매우 어려워집니다. 우리가 원하는 것은 XtextSyntaxDiagnostic이 모델에 존재할 때 XtextLinkingDiagnostic을 숨기고, 일단 구문 오류가 수정되면 링크 오류가 평소대로 표시되어야합니다.구문 오류가있을 때 연결 오류 숨기기

Xtext 문서에서 표준 방법을 찾지 못했습니다. 따라서, 나는 앞뒤로 가서 ResourceValidatorImpl #createAcceptor()에 사용자 정의 IAcceptor를 구현하여 구문 오류가 있으면 링크 오류를 목록에서 제거합니다. 잘 작동하지만 ResourceValidator를 재정의하는 것보다 표준/더 좋은 방법이 있는지 궁금합니다.

감사합니다.

답변

1

링크 문제를 오류 대신 경고로 표시하는 것에 대해 어떻게 생각하십니까? 구문 오류는 빨간색으로 유지되고 자원에서 쉽게 찾을 수 있지만 링크 오류는 덜 중요한 문제이므로 노란색으로 표시됩니다.

에만 사용자 정의 LinkingDiagnosticMessageProvider 바인드 할 필요가 :

public Class<? extends ILinkingDiagnosticMessageProvider> bindILinkingDiagnosticMessageProvider() { 
    return CustomLinkingDiagnosticMessageProvider.class; 
} 

그런 다음이처럼 구현할 수 있습니다

public class CustomLinkingDiagnosticMessageProvider extends LinkingDiagnosticMessageProvider { 
    @Override 
    public DiagnosticMessage getUnresolvedProxyMessage(ILinkingDiagnosticContext context) { 
     DiagnosticMessage diagnosticMessage = super.getUnresolvedProxyMessage(context); 
     return new DiagnosticMessage(diagnosticMessage.getMessage(), 
       Severity.WARNING, 
       diagnosticMessage.getIssueCode(), 
       diagnosticMessage.getIssueData()); 
    } 
} 
관련 문제