2016-06-08 16 views
0

Ich versuche, eine Inhaltshilfe in meiner RCP-Anwendung zu machen. Dafür benutze ich Xtend und AbstractJavaBasedContentProposalProvider. Also habe ich meinen AbstratMyDSLProposalProvider erstellt und schreibe jetzt die MyDSLProposalProvider-Klasse. Im Folgenden wird die xtend Datei und ein Auszug meiner Grammatik: helfenXtend Syntax Inhaltshilfe

// Xtend Datei

override void completeKeyword(Keyword keyword,ContentAssistContextcontentAssistContext, ICompletionProposalAcceptor acceptor) { 
    //acceptor.accept(createCompletionProposal(keyword, context)) 
    if(keyword.getValue().equals("const")){ 
     return; 
    } 
    super.completeKeyword(keyword, contentAssistContext, acceptor); 
} 

// Grammatikdatei

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals 

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" 

Model: 
    NEWLINE* 
    (sections+=Options_sect?)? 
    (sections+=Parameters_sect)? 
; 

Options_sect 
: name=SEC_OPTIONS QUOTE_COMMENT? NEWLINE+ suiteOpt=Suite_options? 
; 

Suite_options 
: {Suite_options} INDENT (options+=Opt)* DEDENT NEWLINE? 
; 

Opt 
: name=OPTION_NAME EQUAL (value=DECIMALINTEGER) NEWLINE+ 
; 

Parameters_sect 
: name=SEC_PARAMETERS QUOTE_COMMENT? NEWLINE+ suiteParam=Suite_parameters? 
; 

Suite_parameters 
: {Suite_parameters} INDENT (params+=Param)* DEDENT NEWLINE? 
; 

Param 
: CONST name=NAME EQUAL value=DECIMALINTEGER NEWLINE+ 
; 

terminal SEC_OPTIONS : 'options'SPACES*':'; 
terminal SEC_PARAMETERS : 'parameters'SPACES*':'; 
terminal EQUAL : '='; 
terminal DECIMALINTEGER : '0'|('1'..'9'(('_'|'0'..'9')*'0'..'9')?); 
terminal NAME 
: ((PP_LABEL* ID_START ID_CONTINUE* PP_LABEL*) | PP_LABEL)('.' (PP_LABEL|ID_CONTINUE)*)* 
; 
terminal PP_LABEL 
: '%'ID_START ID_CONTINUE*'%' 
; 
terminal fragment ID_START 
: '_' 
| 'A'..'Z' 
| 'a'..'z' 
; 
terminal fragment ID_CONTINUE 
: ID_START 
| '0'..'9' 
; 
terminal OPTION_NAME : '$'NAME; 
terminal CONST : 'const'; 
terminal NEWLINE : ((NLINE SPACES?)+); 
terminal fragment NLINE:('\r'? '\n' | '\r'); 
terminal SPACES: (' '|'\t')+; 

terminal QUOTE_COMMENT : INVERTED_COMMA -> INVERTED_COMMA; 
terminal INVERTED_COMMA : '\"'; 

// Indentation 
terminal INDENT :'µµµ'; 
terminal DEDENT : '£££'; 

Aber der Inhalt nicht funktioniert. Ist es der beste Weg, eine Inhaltshilfe in Xtext zu erstellen?

Danke

+0

Was ist Ihre Absicht dieser Anpassung –

+0

Ps Sie erstellen keine Terminals für Schlüsselwörter in der Regel. Einfach inline sie –

Antwort

0

Sie haben die komplette Methode spezifisch für Ihren Terminal Regel complete_CONST außer Kraft zu setzen - nicht vollständige Schlüsselwort. Wenn Sie zu dem Ort gehen, wo Sie die neue Methode schreiben würden, erhalten Sie Vorschläge für die Methode, die Sie überschreiben können

+0

So? : override void complete_CONST (EObject Modell RuleCall ruleCall, ContentAssistContext Zusammenhang ICompletionProposalAcceptor Akzeptor) { \t \t acceptor.accept (createCompletionProposal ("const", context)) \t \t super.complete_CONST (Modell, ruleCall, Kontext, Akzeptor) } – alexmouth

+0

Ja, das sieht gut aus –

+0

Okay, aber es funktioniert nicht immer ... vielleicht ist es die Grammatik? In meinem Fall die 'const' wird nur in 'Parameter' Abschnitt verwendet: 'Param: CONST name = EQUAL Wert NAME = Expr NEWLINE +;' – alexmouth