|
Re: Grammar Mixins [message #1007975 is a reply to message #1007459] |
Fri, 08 February 2013 07:17 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi,
please make sure that the runtime plugin for the definitions language
exports all its packages, esp. the package
org.xtext.example.definitions.services
Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 05.02.13 23:39, schrieb junior developer:
> Hello all ,
> I work grammar inheritance and ı take an error I think this error about
> path (egisterGeneratedEPackage ,registerGenModelFile)but I dont solved
> it :( I try this example from xtext documentation.Add a plug-in
> dependency in the MANIFEST.MF.(add required path in the
> GenerateUsages.MWE2).I generated language artifacts I do not take an
> error when debuging.I take ANTLR error , so that I do not create useges
> extension.Error is in the InternalUsagesParser class(UI package).How
> solve this problem? ,please help me .
>
> Error:The method getRuleAAccess() from the type UsagesGrammarAccess
> refers to the missing type RuleAElements- The type
> org.xtext.example.definitions.services.DefinitionsGrammarAccess$RuleAElements
> cannot be resolved. It is indirectly referenced from required .class files
> --------------------------------------------------------------------------------
>
> My supergrammar:
> grammar org.xtext.example.definitions.Definitions with
> org.eclipse.xtext.common.Terminals
>
> generate definitions "http://www.xtext.org/example/definitions/Definitions"
>
> RuleA : "a" stuff=RuleB;
> RuleB : "{" name=ID "}";
> ------------------------------------------------------------------------------------
>
> My subgrammar :
> grammar org.xtext.example.usages.Usages with
> org.xtext.example.definitions.Definitions
>
> generate usages "http://www.xtext.org/example/usages/Usages"
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>
> Model : (ruleAs+=RuleA)*;
>
> RuleB : '[' name=ID ']'; //overriding
> ----------------------------------------------------------------------
>
|
|
|
Re: Grammar Mixins [message #1008129 is a reply to message #1007975] |
Sun, 10 February 2013 12:28 |
junior developer Messages: 354 Registered: January 2013 |
Senior Member |
|
|
Hi Sebastian,
When I generate the language code, I receive previously mentioned error for InternalUsagesParser class in org.xtext.example.usages.ui.contentassist.antlr.internal package. The error occures in the grammarAccess.getRuleAAccess() function call of the automatically generated ruleRuleA() function. Interestingly the project works without any problem. I write programs in the editor and I don't take any error, e.g. I can use overriding rule.
Could you possibly introduce me a solution to resolve this error?
Best regards
[Updated on: Sun, 10 February 2013 12:31] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Grammar Mixins [message #1009609 is a reply to message #1009555] |
Fri, 15 February 2013 11:32 |
|
HI,
sorry i do not get it? i cannot teach you how to write java
import org.eclipse.xtext.GrammarUtil;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.nodemodel.SyntaxErrorMessage;
import org.eclipse.xtext.parser.antlr.SyntaxErrorMessageProvider;
import com.google.inject.Inject;
public class MyDslSyntaxErrorMessageProvider extends SyntaxErrorMessageProvider {
public static final String USED_RESERVED_KEYWORD = "USED_RESERVED_KEYWORD";
@Inject
IGrammarAccess grammarAccess;
@Override
public SyntaxErrorMessage getSyntaxErrorMessage(IParserErrorContext context) {
if (context.getRecognitionException() != null
&& context.getRecognitionException().token != null) {
String unexpectedText = context.getRecognitionException().token
.getText();
if (GrammarUtil.getAllKeywords(grammarAccess.getGrammar())
.contains(unexpectedText)) {
return new SyntaxErrorMessage(
unexpectedText
+ " is a reserved keyword which is not allowed as Identifier",
USED_RESERVED_KEYWORD);
}
}
return super.getSyntaxErrorMessage(context);
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
|
|
Re: Grammar Mixins [message #1010716 is a reply to message #1010074] |
Mon, 18 February 2013 05:01 |
junior developer Messages: 354 Registered: January 2013 |
Senior Member |
|
|
Hi Christian,
My problem is to change default automatic validation error and warning messages and looking for a general solution how to do that.
I've got an example written in xtend-class (see below). I want to extend this code. For different or existing automatic validation error and warning messages I want to add custom messages. For example, I get for Cross-reference an error message ** Couldn't resolve reference to Name 'something' ** which is an automatic validation error, so I want to add or overide with my own code to get my error message something like that ** You cannot call 'something' **. Which functions do I need to realize that and where should I add this to existing keywords. I didn't have found enough sources to get this run, can you give me a hint how to realise it?
package org.xtext.example.mydsl1.ui;
import org.eclipse.xtext.GrammarUtil;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.nodemodel.SyntaxErrorMessage;
import org.eclipse.xtext.parser.antlr.SyntaxErrorMessageProvider;
import com.google.inject.Inject;
public class MyDsl1SyntaxErrorMessageProvider extends SyntaxErrorMessageProvider {
public static final String USED_RESERVED_KEYWORD = "USED_RESERVED_KEYWORD";
@Inject
IGrammarAccess grammarAccess;
/* I want to change Cross Reference Default Error Message:Couldn't resolve reference to Name 'something'... in my own custom message */
@Override
public SyntaxErrorMessage getSyntaxErrorMessage(IParserErrorContext context) {
if (context.getRecognitionException() != null && context.getRecognitionException().token != null) {
String unexpectedText = context.getRecognitionException().token.getText();
if(GrammarUtil.getAllKeywords(grammarAccess.getGrammar()).contains(unexpectedText)) {
return new SyntaxErrorMessage( "is a reserved keyword which is not allowed as Identifier",USED_RESERVED_KEYWORD);//changed Automatic validation (mismatched input //'Hello' expecting RULE_ID)
}
}
return super.getSyntaxErrorMessage(context);
}
}
[Updated on: Mon, 18 February 2013 07:41] Report message to a moderator
|
|
|
|
|
|
|
Re: Grammar Mixins [message #1744557 is a reply to message #1008211] |
Wed, 28 September 2016 09:11 |
Martin Westerkamp Messages: 9 Registered: September 2016 |
Junior Member |
|
|
junior developer wrote on Mon, 11 February 2013 13:41My problem is solved.
Could you please let us know how you solved the problem? I'm struggling with the same issue right now.
EDIT: I just figured out the solution. The plug-in of the super language needs to be added to the manifest.mf file of the .ide project of the sub language.
[Updated on: Wed, 28 September 2016 09:30] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.06213 seconds