Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext scope(Newbie needs help)
Xtext scope [message #1790015] Sun, 03 June 2018 02:34 Go to next message
Anton Hughes is currently offline Anton HughesFriend
Messages: 66
Registered: January 2013
Member
Hello

I am trying to learn Xtext by studying existing projects.

I am trying to make a project that uses the Sculptor framework xtext.

The xtext dsl is:


/*
 * Copyright 2013 The Sculptor Project Team, including the original 
 * author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

grammar org.sculptor.dsl.Sculptordsl with org.eclipse.xtext.common.Terminals

generate sculptordsl "http://sculptor.org/dsl/sculptordsl"


DslModel :
  (imports+=DslImport)*
  app=DslApplication;

DslImport :
	'import' importURI=STRING;

DslApplication :
  (doc=STRING)?
  (("Application" name=ID "{"
    "basePackage" "=" basePackage=DslJavaIdentifier) |
  ("ApplicationPart"  name=ID "{"))

    (modules+=DslModule)*
  "}";

DslModule :
  (doc=STRING)?
  "Module" name=ID "{"
    (external?="external")?
    ("basePackage" "=" basePackage=DslJavaIdentifier )?
    ("hint" "=" hint=STRING)?
    ((services+=DslService) |
     (resources+=DslResource) |
     (consumers+=DslConsumer) |
     (domainObjects+=DslSimpleDomainObject))*
  "}";

DslService :
  (doc=STRING)?
  "Service" name=ID "{"
  	(
  	 ((gapClass?="gap") | (noGapClass?="nogap"))? &
     ("hint" "=" hint=STRING)? &
  	 (webService?="webservice")? &
  	 (subscribe=DslSubscribe)?
  	)
    (dependencies+=DslDependency)*
    (operations+=DslServiceOperation)*
  "}";

DslResource :
  (doc=STRING)?
  "Resource" name=ID "{"
  	(
  	 ((gapClass?="gap") | (noGapClass?="nogap"))? &
     ("hint" "=" hint=STRING)? &
     (scaffold?="scaffold")? &
     ("path" "=" path=STRING)?
  	)
    (dependencies+=DslServiceDependency)*
    (operations+=DslResourceOperation)*
  "}";

DslConsumer :
  (doc=STRING)?
  "Consumer" name=ID "{"
    ("hint" "=" hint=STRING)?
    (dependencies+=DslDependency)*
    ("unmarshall to" ("@")?messageRoot=[DslDomainObject])?
    (
     (("queueName" | "topicName") "=" channel=DslChannelIdentifier )? &
     (subscribe=DslSubscribe)?
    )
  "}";

DslSubscribe :
	"subscribe" "to" topic=DslChannelIdentifier ("eventBus" "=" eventBus=ID)?
;

DslPublish :
	"publish" (("@")?eventType=[DslEvent])? "to" topic=DslChannelIdentifier ("eventBus" "=" eventBus=ID)?
;

DslEvent :
	DslDomainEvent | DslCommandEvent;

DslDomainObjectTypedElement :
  DslServiceOperation | DslRepositoryOperation | DslDomainObjectOperation | DslParameter;

DslServiceOperation :
  (doc=STRING)?
  (visibility=DslVisibility)?
  (returnType=DslComplexType)?
  name=ID ("(" (parameters+=DslParameter)?("," parameters+=DslParameter)* ")")?
    (
      ("throws" throws=DslThrowsIdentifier)? &
	  ("hint" "=" hint=STRING)? &
	  (publish=DslPublish)?
    )
    (delegateHolder=DslServiceOperationDelegate)? ";"
;

DslServiceOperationDelegate :
    DELEGATE ("@")? delegate=[DslServiceRepositoryOption]"."delegateOperation=[DslServiceRepositoryOperationOption];

DslServiceRepositoryOption :
	DslRepository | DslService;

DslServiceRepositoryOperationOption :
	DslRepositoryOperation | DslServiceOperation;

DslResourceOperation :
  (doc=STRING)?
  (visibility=DslVisibility)?
  (returnType=DslComplexType)?
  name=ID ("(" (parameters+=DslParameter)?("," parameters+=DslParameter)* ")")?
    (
      ("throws" throws=DslThrowsIdentifier)? &
	  ("hint" "=" hint=STRING)? &
	  (httpMethod=DslHttpMethod)? &
	  ("path" "=" path=STRING)? &
	  ("return" "=" returnString=STRING)?
    )
    (delegateHolder=DslResourceOperationDelegate)? ";"
;

DslResourceOperationDelegate :
    DELEGATE ("@")? delegate=[DslService]"."delegateOperation=[DslServiceOperation];

enum DslHttpMethod :
	None | GET="GET" | POST="POST" | PUT="PUT" | DELETE="DELETE";

DslRepositoryOperation :
  (doc=STRING)?
  (visibility=DslVisibility)?
  (returnType=DslComplexType)?
  name=ID ("(" (parameters+=DslParameter)?("," parameters+=DslParameter)* ")")?
    (
      ("throws" throws=DslThrowsIdentifier)? &
      ("hint" "=" hint=STRING)? &
      (cache?="cache")? &
      ((gapOperation?="gap") | (noGapOperation?="nogap"))? &
      ("query" "=" query=STRING)? &
      ("condition" "=" condition=STRING)? &
      ("select" "=" select=STRING)? &
      ("groupBy" "=" groupBy=STRING)? &
      ("orderBy" "=" orderBy=STRING)? &
      (construct?="construct")? &
      (build?="build")? &
      (map?="map")? &
      (publish=DslPublish)?
    )
    (delegateToAccessObject?=DELEGATE (("AccessObject") | (accessObjectName=ID)))? ";"
;

DslParameter :
  (doc=STRING)?
  parameterType=DslComplexType name=ID;

DslComplexType :
  (collectionType=DslCollectionType"<"(("@"domainObjectType=[DslSimpleDomainObject]) | (type=DslType) | (type=DslType"<""@"domainObjectType=[DslSimpleDomainObject]">"))">") |
  (mapCollectionType=DSL_MAP_COLLECTION_TYPE"<"(mapKeyType=DslType | "@"mapKeyDomainObjectType=[DslSimpleDomainObject])","(("@"domainObjectType=[DslSimpleDomainObject]) | (type=DslType) | (type=DslType"<""@"domainObjectType=[DslSimpleDomainObject]">"))">") |
  ("@"domainObjectType=[DslSimpleDomainObject]) |
  (type=DslType) |
  (type=DslType"<""@"domainObjectType=[DslSimpleDomainObject]">");

DslSimpleDomainObject :
  DslBasicType | DslEnum | DslDomainObject | DslDataTransferObject | DslTrait;

DslDomainObject :
  DslEntity | DslValueObject | DslEvent;

DslEntity :
  (doc=STRING)?
  (abstract?="abstract")? "Entity" name=ID ("extends" (("@"extends=[DslEntity]) | (extendsName=DslJavaIdentifier)))?
  ("with" ("@")?traits+=[DslTrait])* "{"
    ("package" "=" package=DslJavaIdentifier )?
    (((notOptimisticLocking?=NOT "optimisticLocking") | ("optimisticLocking"))? &
     ((notAuditable?=NOT "auditable") | ("auditable"))? &
     ((cache?="cache") | (NOT "cache"))? &
     ((gapClass?="gap") | (noGapClass?="nogap"))? &
     (scaffold?="scaffold")? &
     ("hint" "=" hint=STRING)? &
     ("databaseTable" "=" databaseTable=STRING)? &
     ("discriminatorValue" "=" discriminatorValue=STRING)? &
     ("discriminatorColumn" "=" discriminatorColumn=STRING)? &
     ("discriminatorType" "=" discriminatorType=DslDiscriminatorType)? &
     ("discriminatorLength" "=" discriminatorLength=STRING)? &
     ("inheritanceType" "=" inheritanceType=DslInheritanceType)? &
     ("validate" "=" validate=STRING)? &
     ((notAggregateRoot?=NOT "aggregateRoot") | ("aggregateRoot"))? &
     ("belongsTo" (("@")?belongsTo=[DslDomainObject]))?)
    ((attributes+=DslAttribute) |
     (references+=DslReference) |
     (operations+=DslDomainObjectOperation))*
    (repository=DslRepository)?
  "}";

DslValueObject :
  (doc=STRING)?
  (abstract?="abstract")? "ValueObject" name=ID ("extends" (("@"extends=[DslValueObject]) | (extendsName=DslJavaIdentifier)))?
  ("with" ("@")?traits+=[DslTrait])* "{"
    ("package" "=" package=DslJavaIdentifier )?
    (((notOptimisticLocking?=NOT "optimisticLocking") | ("optimisticLocking"))? &
     ((notImmutable?=NOT "immutable") | ("immutable"))? &
     ((cache?="cache") | (NOT "cache"))? &
     ((gapClass?="gap") | (noGapClass?="nogap"))? &
     (scaffold?="scaffold")? &
     ("hint" "=" hint=STRING)? &
     ("databaseTable" "=" databaseTable=STRING)? &
     ("discriminatorValue" "=" discriminatorValue=STRING)? &
     ("discriminatorColumn" "=" discriminatorColumn=STRING)? &
     ("discriminatorType" "=" discriminatorType=DslDiscriminatorType)? &
     ("discriminatorLength" "=" discriminatorLength=STRING)? &
     ("inheritanceType" "=" inheritanceType=DslInheritanceType)? &
     ("validate" "=" validate=STRING)? &
     ((persistent?="persistent") | (notPersistent?=NOT "persistent"))? &
     ((notAggregateRoot?=NOT "aggregateRoot") | ("aggregateRoot"))? &
     ("belongsTo" (("@")?belongsTo=[DslDomainObject]))?)
    ((attributes+=DslAttribute) |
     (references+=DslReference) |
     (operations+=DslDomainObjectOperation))*
    (repository=DslRepository)?
  "}";

DslDomainEvent :
  (doc=STRING)?
  (abstract?="abstract")? "DomainEvent" name=ID ("extends" (("@"extends=[DslDomainEvent]) | (extendsName=DslJavaIdentifier)))?
  ("with" ("@")?traits+=[DslTrait])* "{"
    ("package" "=" package=DslJavaIdentifier )?
    (
     ((cache?="cache") | (NOT "cache"))? &
     ((gapClass?="gap") | (noGapClass?="nogap"))? &
     (scaffold?="scaffold")? &
     ("hint" "=" hint=STRING)? &
     ("databaseTable" "=" databaseTable=STRING)? &
     ("discriminatorValue" "=" discriminatorValue=STRING)? &
     ("discriminatorColumn" "=" discriminatorColumn=STRING)? &
     ("discriminatorType" "=" discriminatorType=DslDiscriminatorType)? &
     ("discriminatorLength" "=" discriminatorLength=STRING)? &
     ("inheritanceType" "=" inheritanceType=DslInheritanceType)? &
     ("validate" "=" validate=STRING)? &
     (persistent?="persistent")? &
     ((notAggregateRoot?=NOT "aggregateRoot") | ("aggregateRoot"))? &
     ("belongsTo" (("@")?belongsTo=[DslDomainObject]))?
    )
    ((attributes+=DslAttribute) |
     (references+=DslReference) |
     (operations+=DslDomainObjectOperation))*
    (repository=DslRepository)?
  "}";

DslCommandEvent :
  (doc=STRING)?
  (abstract?="abstract")? "CommandEvent" name=ID ("extends" (("@"extends=[DslCommandEvent]) | (extendsName=DslJavaIdentifier)))?
  ("with" ("@")?traits+=[DslTrait])* "{"
    ("package" "=" package=DslJavaIdentifier )?
    (
     ((cache?="cache") | (NOT "cache"))? &
     ((gapClass?="gap") | (noGapClass?="nogap"))? &
     (scaffold?="scaffold")? &
     ("hint" "=" hint=STRING)? &
     ("databaseTable" "=" databaseTable=STRING)? &
     ("discriminatorValue" "=" discriminatorValue=STRING)? &
     ("discriminatorColumn" "=" discriminatorColumn=STRING)? &
     ("discriminatorType" "=" discriminatorType=DslDiscriminatorType)? &
     ("discriminatorLength" "=" discriminatorLength=STRING)? &
     ("inheritanceType" "=" inheritanceType=DslInheritanceType)? &
     ("validate" "=" validate=STRING)? &
     (persistent?="persistent")? &
     ((notAggregateRoot?=NOT "aggregateRoot") | ("aggregateRoot"))? &
     ("belongsTo" (("@")?belongsTo=[DslDomainObject]))?
    )
    ((attributes+=DslAttribute) |
     (references+=DslReference) |
     (operations+=DslDomainObjectOperation))*
    (repository=DslRepository)?
  "}";

DslTrait :
  (doc=STRING)?
  "Trait" name=ID "{"
    ("package" "=" package=DslJavaIdentifier )?
    ("hint" "=" hint=STRING)?
    ((attributes+=DslAttribute) |
     (references+=DslReference) |
     (operations+=DslDomainObjectOperation))*

  "}";

DslDomainObjectOperation :
  (doc=STRING)?
  OP (abstract?="abstract")? (visibility=DslVisibility)?
  (returnType=DslComplexType)?
  name=ID ("(" (parameters+=DslParameter)?("," parameters+=DslParameter)* ")")?
    (
      ("throws" throws=DslThrowsIdentifier)? &
	  ("hint" "=" hint=STRING)?
    )
    ";";

DslDataTransferObject :
  (doc=STRING)?
  (abstract?="abstract")? "DataTransferObject" name=ID ("extends" (("@"extends=[DslDataTransferObject]) | (extendsName=DslJavaIdentifier)))? "{"
    ("package" "=" package=DslJavaIdentifier )?
    (
     ((gapClass?="gap") | (noGapClass?="nogap"))? &
     ("hint" "=" hint=STRING)? &
     ("validate" "=" validate=STRING)?
    )
    ((attributes+=DslDtoAttribute) |
     (references+=DslDtoReference))*
  "}";

DslBasicType :
  (doc=STRING)?
  "BasicType" name=ID
  ("with" ("@")?traits+=[DslTrait])* "{"
    ("package" "=" package=DslJavaIdentifier )?
    (((notImmutable?=NOT "immutable") | ("immutable"))? &
     ((gapClass?="gap") | (noGapClass?="nogap"))? &
     ("hint" "=" hint=STRING)?
    )
    ((attributes+=DslAttribute) |
     (references+=DslReference) |
     (operations+=DslDomainObjectOperation))*
  "}";

DslAttribute :
  (doc=STRING)?
  (visibility=DslVisibility)? (collectionType=DslCollectionType"<")? type=DslType (">")? name=ID
    ((key?="key")? &
     ((notChangeable?=NOT "changeable") | ("changeable"))? &
     ((required?="required") | (NOT "required"))? &
     (((nullable?="nullable") | (NOT "nullable")) ("=" nullableMessage=STRING)?)? &
     (index?="index")? &
     ((assertFalse?="assertFalse") ("=" assertFalseMessage=STRING)?)? &
     ((assertTrue?="assertTrue") ("=" assertTrueMessage=STRING)?)? &
     ("hint" "=" hint=STRING)? &
     ((creditCardNumber?="creditCardNumber") ("=" creditCardNumberMessage=STRING)?)? &
     ("digits" "=" digits=STRING)? &
     ((email?="email") ("=" emailMessage=STRING)?)? &
     ((future?="future") ("=" futureMessage=STRING)?)? &
     ((past?="past") ("=" pastMessage=STRING)?)? &
     ("max" "=" max=STRING)? &
     ("min" "=" min=STRING)? &
     ("decimalMax" "=" decimalMax=STRING)? &
     ("decimalMin" "=" decimalMin=STRING)? &
     ((notEmpty?="notEmpty") ("=" notEmptyMessage=STRING)?)? &
     ((notBlank?="notBlank") ("=" notBlankMessage=STRING)?)? &
     ("pattern" "=" pattern=STRING)? &
     ("range" "=" range=STRING)? &
     ("size" "=" size=STRING)? &
     ("length" "=" length=STRING)? &
     ("scriptAssert" "=" scriptAssert=STRING)? &
     ("url" "=" url=STRING)? &
     ("validate" "=" validate=STRING)? &
     (transient?="transient")? &
     ("databaseColumn" "=" databaseColumn=STRING)? &
     ("databaseType" "=" databaseType=STRING)?) (";")?;

DslReference :
  (doc=STRING)?
  REF (visibility=DslVisibility)? (collectionType=DslCollectionType"<")? (("@")?domainObjectType=[DslSimpleDomainObject]) (">")? name=ID
    ((key?="key")? &
     ((notChangeable?=NOT "changeable") | ("changeable"))? &
     ((required?="required") | (NOT "required"))? &
     (((nullable?="nullable") | (NOT "nullable")) ("=" nullableMessage=STRING)?)? &
     ("hint" "=" hint=STRING)? &
     ("cascade" "=" cascade=STRING)? &
     ("fetch" "=" fetch=STRING)? &
     ((cache?="cache") | (NOT "cache"))? &
     ((inverse?="inverse") | (NOT "inverse"))? &
     ("databaseColumn" "=" databaseColumn=STRING)? &
     ("databaseJoinTable" "=" databaseJoinTable=STRING)? &
     ("databaseJoinColumn" "=" databaseJoinColumn=STRING)? &
     ((notEmpty?="notEmpty") ("=" notEmptyMessage=STRING)?)? &
     ("size" "=" size=STRING)? &
     ((valid?="valid") ("=" validMessage=STRING)?)? &
     ("validate" "=" validate=STRING)? &
     (transient?="transient")? &
     ("orderby" "=" orderBy=STRING)? &
     ((orderColumn?="orderColumn") ("=" orderColumnName=STRING)?)? &
     (oppositeHolder=DslOppositeHolder)?)
    (";")?;

DslDtoAttribute :
  (doc=STRING)?
  (visibility=DslVisibility)? (collectionType=DslCollectionType"<")? type=DslType (">")? name=ID
    ((key?="key")? &
     ((notChangeable?=NOT "changeable") | ("changeable"))? &
     ((required?="required") | (NOT "required"))? &
     (((nullable?="nullable") | (NOT "nullable")) ("=" nullableMessage=STRING)?)? &
     (transient?="transient")? &
     ((assertFalse?="assertFalse") ("=" assertFalseMessage=STRING)?)? &
     ((assertTrue?="assertTrue") ("=" assertTrueMessage=STRING)?)? &
     ((creditCardNumber?="creditCardNumber") ("=" creditCardNumberMessage=STRING)?)? &
     ("digits" "=" digits=STRING)? &
     ((email?="email") ("=" emailMessage=STRING)?)? &
     ((future?="future") ("=" futureMessage=STRING)?)? &
     ((past?="past") ("=" pastMessage=STRING)?)? &
     ("max" "=" max=STRING)? &
     ("min" "=" min=STRING)? &
     ("decimalMax" "=" decimalMax=STRING)? &
     ("decimalMin" "=" decimalMin=STRING)? &
     ((notEmpty?="notEmpty") ("=" notEmptyMessage=STRING)?)? &
     ((notBlank?="notBlank") ("=" notBlankMessage=STRING)?)? &
     ("pattern" "=" pattern=STRING)? &
     ("range" "=" range=STRING)? &
     ("size" "=" size=STRING)? &
     ("length" "=" length=STRING)? &
     ("scriptAssert" "=" scriptAssert=STRING)? &
     ("url" "=" url=STRING)? &
     ("validate" "=" validate=STRING)? &
     ("hint" "=" hint=STRING)?
	) (";")?;

DslDtoReference :
  (doc=STRING)?
  REF (visibility=DslVisibility)? (collectionType=DslCollectionType"<")? (("@")?domainObjectType=[DslSimpleDomainObject]) (">")? name=ID
    ((key?="key")? &
     ((notChangeable?=NOT "changeable") | ("changeable"))? &
     ((required?="required") | (NOT "required"))? &
     (((nullable?="nullable") | (NOT "nullable")) ("=" nullableMessage=STRING)?)? &
     (transient?="transient")? &
     ((notEmpty?="notEmpty") ("=" notEmptyMessage=STRING)?)? &
     ("size" "=" size=STRING)? &
     ((valid?="valid") ("=" validMessage=STRING)?)? &
     ("validate" "=" validate=STRING)? &
     ("hint" "=" hint=STRING)?
	) (";")?;

DslOppositeHolder :
	OPPOSITE opposite=[DslReference];

DslRepository :
  (doc=STRING)?
  "Repository" name=ID "{"
    (
      ((gapClass?="gap") | (noGapClass?="nogap"))? &
      ("hint" "=" hint=STRING)? &
      (subscribe=DslSubscribe)?
    )
    (dependencies+=DslDependency)*
    (operations+=DslRepositoryOperation)*
  "}";

DslServiceDependency :
  ('>'|'inject') ("@"dependency=[DslService]);

DslDependency :
  ('>'|'inject') (("@"dependency=[DslServiceRepositoryOption])|name=ID);

DslEnum :
  (doc=STRING)?
  "enum" name=ID "{"
    ("package" "=" package=DslJavaIdentifier )?
    ("hint" "=" hint=STRING)?
    (ordinal?="ordinal")?
    (attributes+=DslEnumAttribute)*
    (values+=DslEnumValue) ("," values+=DslEnumValue)* (";")?
  "}";

DslEnumAttribute :
  (doc=STRING)?
  type=DslType name=ID (key?="key")? (";")?;

DslEnumValue :
  (doc=STRING)?
  name=ID ("(" parameters+=DslEnumParameter ("," parameters+=DslEnumParameter)* ")")?;

DslEnumParameter :
	((value=STRING) | (integerValue = INT));

DslAnyProperty :
	DslProperty | DslDtoProperty;

DslProperty :
	DslAttribute | DslReference;

DslDtoProperty :
	DslDtoAttribute | DslDtoReference;

enum DslInheritanceType :
	JOINED="JOINED" | SINGLE_TABLE="SINGLE_TABLE";

enum DslDiscriminatorType :
	STRING="STRING" | CHAR="CHAR" | INTEGER="INTEGER";

DslType :
  ("String"|"int"|"Integer"|"long"|"Long"|"boolean"|"Boolean"|"Date"|"DateTime"|"Timestamp"|"BigDecimal"|"BigInteger"|
  	"double"|"Double"|"float"|"Float"|"Key"|"PagingParameter"|"PagedResult"|"Blob"|"Clob"|"Object[]"|
  	DslJavaIdentifier);

enum DslCollectionType :
	None | Set="Set" | List="List" | Bag="Bag" | Collection="Collection";

terminal DSL_MAP_COLLECTION_TYPE :
  "Map";

enum DslVisibility :
  public="public" | protected="protected" | private="private" | package="package";

DslJavaIdentifier :
  (ID ("." ID)*);

DslChannelIdentifier :
  (ID (((".") | ("/") | (":")) ID)*);

DslThrowsIdentifier :
  (DslJavaIdentifier ("," DslJavaIdentifier)*);

terminal NOT :
  ('!'|'not');

terminal DELEGATE :
  ('=>'|('delegates to'));

terminal OPPOSITE :
  ('<->'|'opposite');

terminal REF :
  ('-'|'reference');

terminal OP :
  ('*'|'def');


However, when I test this in Eclipse I get the following error:
https://imgur.com/a/Gqtf0Cn


I tried adding these scoping classes but it didnt make any difference.

https://github.com/sculptor/sculptor/tree/develop/sculptor-eclipse/org.sculptor.dsl/src/org/sculptor/dsl/scoping

Re: Xtext scope [message #1790019 is a reply to message #1790015] Sun, 03 June 2018 08:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12356
Registered: July 2009
Senior Member
- having such a huge grammar as starting point discourages people from answering.
- what do you mean by "adding scoping classes"
- how did you implement the namesprovider/ indexing (if you use open model element dialog in navigate menu or crtl+shift+f3 which name does it give for the DSL service)


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext scope [message #1790066 is a reply to message #1790019] Mon, 04 June 2018 11:31 Go to previous messageGo to next message
Anton Hughes is currently offline Anton HughesFriend
Messages: 66
Registered: January 2013
Member
Hi Christian

Firstly, thank you for your kind help. It is greatly appreciated.

Quote:

- having such a huge grammar as starting point discourages people from answering.


Yes, I can appreciate that.
I supplied the complete - and large - grammar as I thought that perhaps some readers here are already familiar with it, being that the Sculptor framework is somewhat well known.


Quote:

- what do you mean by "adding scoping classes"

To clarify, I have created a new xtext project, and am using the Sculptor xtext grammar.
I then, also added the https://github.com/sculptor/sculptor/blob/develop/sculptor-eclipse/org.sculptor.dsl/src/org/sculptor/dsl/scoping/SculptordslScopeProvider.xtend to my project.

Quote:

- how did you implement the namesprovider/ indexing (if you use open model element dialog in navigate menu or crtl+shift+f3 which name does it give for the DSL service)


I have not implemented any namesprivider or indexing.

I am learning Xtext, and so far I am not familiar with what a namesprovider is.

I suspect that the issue is to do with Scoping, but am not certain.

Can you please clarify - is scoping what provides the code hints when typing? Is this all it does? Or does it also provide validation?

While debugging, I can see that the methods in the ScopeProvider are called, however I am not clear on a few points. I can see that when typing in the xtext dsl ide that these methods are called.
What exactly triggers calling the ScopeProvider? Is it simply every time someone types, or is it when entering a dot?
How is the 'context' determined? A context in the ScopeProvider is an EObject? But is this determined by the current syntax, or where the cursor in the IDE?

I hope my questions make sense.
And again, thanks for any assistance.

Regards




Re: Xtext scope [message #1790068 is a reply to message #1790066] Mon, 04 June 2018 11:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12356
Registered: July 2009
Senior Member
xtext reference things by names.
either this is done by the defaults
or by building scopes manually.

if you use defaults it will uses elements names (and parents names)
thus the name of the thing you refer might be grandparentname.parentname.name instead of simply name as you seem to expect.
you can fix that by customizing your IQualifiedNameProvider (ususally a subclass of DefaultDeclarativeQualifiednameProvider)

=> first you should investagate which names are actually used to index the stuff (see open model element dialog)


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext scope [message #1790069 is a reply to message #1790068] Mon, 04 June 2018 11:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12356
Registered: July 2009
Senior Member
p.S: and your importURI needs some custom bindings. i dont know what you did do for that so far.
the default in xtext is to have name based imports, not file based

=> i am not sure which of the stack of problems you try to solve right now


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 04 June 2018 11:49]

Report message to a moderator

Re: Xtext scope [message #1790074 is a reply to message #1790069] Mon, 04 June 2018 12:14 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12356
Registered: July 2009
Senior Member
pps: the original sculptor code uses these two things

fragment = org.eclipse.xtext.generator.adapter.FragmentAdapter {
fragment = org.eclipse.xtext.generator.scoping.ImportURIScopingFragment {
generateXtendStub = true
}
}
fragment = exporting.SimpleNamesFragment2 {}

these enable the uri based import that simple names instead of qualified names beeing used.


SculptordslScopeProvider does further customization of the scoping.


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:code gen when Build Automatically disabled
Next Topic:Reference other Xtext model
Goto Forum:
  


Current Time: Tue Nov 13 05:19:12 GMT 2018

Powered by FUDForum. Page generated in 0.02240 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top