Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Reference output problem.
Reference output problem. [message #1768793] Mon, 24 July 2017 00:29 Go to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Here is my grammar. I am not getting the output as per my expectation.
My references work but it imports file name from where i am importing the type. I don't want file names. You can see in my grammar below.

TypedefStatement:
	'typedef' name=(STRINGARG|KEY_IDENTIFIER)
	'{' (typedefsubstatemnet+=TypedefSubstatement)* '}';
		
TypedefSubstatement:
	(TypeStatement
	|DescriptionStatement
	|ReferenceStatement
	|DefaultStatement
	|StatusStatement
	)
	;

//The crossreference must be done in diferent blocks
//identifier-ref-arg-str 
//[TypedefStatement]

TypeStatement:
	'type' 

	(type=BuiltInType | (pre=[PrefixStatement] ':') ? importtype=[TypedefStatement])
	(';' 
	|'{' (typesubstatements+=TypeSubStatement)* '}');    





This is my output.

typedef AutonomousType {
    type ietf-yang-types."yang":ietf-yang-types.object-identifier;

// I got this output which is not right.

    description     
     "Represents an independently extensible type identification
      value.  It may, for example, indicate a particular sub-tree
      with further MIB definitions, or define a particular type of
      protocol or hardware.";
  }

  typedef InstancePointer {
    type yang:object-identifier;

// I want this output using reference in xtext.

    status obsolete;
    description     
     "A pointer to either a specific instance of a MIB object or
      a conceptual row of a MIB table in the managed device.  In
      the latter case, by convention, it is the name of the
      particular instance of the first accessible columnar object
      in the conceptual row.
      
      The two uses of this textual convention are replaced by
      VariablePointer and RowPointer, respectively.";
  }


Thanks.
Re: Reference output problem. [message #1768794 is a reply to message #1768793] Mon, 24 July 2017 03:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi

I cannnot folllow you. Please explain what you are doing and what your problem is


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1768796 is a reply to message #1768794] Mon, 24 July 2017 04:17 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Hi Christian,

I am writing a grammar for yang module.

//this is a small part of my dsl.  
As you can see in the below code, I am trying to import 'typedef' of one module as a 'type' of other module. 

 typedef object-identifier {
      type string {
        pattern
          '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))(\.(0|([1-9]\d*)))*';
      }
      description
        "The object-identifier type represents administratively
      assigned names in a registration-hierarchical-name tree.

      This type is a superset of the SMIv2 OBJECT IDENTIFIER type
      since it is not restricted to 128 sub-identifiers.  Hence,
      this type SHOULD NOT be used to represent the SMIv2 OBJECT
      IDENTIFIER type; the object-identifier-128 type SHOULD be
      used instead.";
      reference
        "ISO9834-1: Information technology -- Open Systems
        Interconnection -- Procedures for the operation of OSI
        Registration Authorities: General procedures and top
        arcs of the ASN.1 Object Identifier tree";

    }

    typedef object-identifier-128 {
      type object-identifier {
        pattern '\d*(\.\d*){1,127}';
      }
      description
        "This type represents object-identifiers restricted to 128
      sub-identifiers.

      In the value set and its semantics, this type is equivalent
      to the OBJECT IDENTIFIER type of the SMIv2.";
      reference
        "RFC 2578: Structure of Management Information Version 2
        	  (SMIv2)";

    }



Now I want the same output in two different files. I am importing different files for the 'type'.


module SNMPv2-MIB {

  namespace "urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB";
  prefix "snmpv2-mib";

  import SNMPv2-TC {
    prefix "snmpv2-tc";
  }

// These are my import statements.

  import ietf-yang-smiv2 {
    prefix "smiv2";
  }

  import ietf-yang-types {
    prefix "yang";
  }

leaf sysDescr {
                type yang:object-identifier;                                               // < I want output like this in my other files
        {
          length "0..255";
        }

        description
         "A textual description of the entity.  This value should
          include the full name and version identification of
          the system's hardware type, software operating-system,
          and networking software.";
        smiv2:max-access "read-only";
        smiv2:oid "1.3.6.1.2.1.1.1";
      }

      leaf sysObjectID {
        type yang:ietf-yang-types.object-identifier                             //< I got this output which is not correct.
        description
         "The vendor's authoritative identification of the
          network management subsystem contained in the entity.
          This value is allocated within the SMI enterprises
          subtree (1.3.6.1.4.1) and provides an easy and
          unambiguous means for determining `what kind of box' is
          being managed.  For example, if vendor `Flintstones,
          Inc.' was assigned the subtree 1.3.6.1.4.1.424242,
          it could assign the identifier 1.3.6.1.4.1.424242.1.1
          to its `Fred Router'.";
        smiv2:max-access "read-only";
        smiv2:oid "1.3.6.1.2.1.1.2";
      }



I hope this will useful.
Re: Reference output problem. [message #1768797 is a reply to message #1768796] Mon, 24 July 2017 04:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
What do you mean by output
What did you implement
In qualifiednameprovider, scoping etc


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1768798 is a reply to message #1768797] Mon, 24 July 2017 04:43 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
I am not using xtend.
I am only using Xtext.
Output means my dsl.
Re: Reference output problem. [message #1768799 is a reply to message #1768798] Mon, 24 July 2017 04:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Sorry I don't understand

Can you please share a complete but minimal sample grammar
And sample model project

What is bad about

type yang:ietf-yang-types.object-identifier //< I got this

output which is not correct

What did you implement in scoping and iqualifiednameprovider


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1768800 is a reply to message #1768799] Mon, 24 July 2017 05:20 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
This is my grammar.

TypedefStatement:
	'typedef' name=(STRINGARG|KEY_IDENTIFIER)
	'{' (typedefsubstatemnet+=TypedefSubstatement)* '}';
		
TypedefSubstatement:
	(TypeStatement
	|DescriptionStatement
	|ReferenceStatement
	|DefaultStatement
	|StatusStatement
	)
	;

//The crossreference must be done in different blocks
//identifier-ref-arg-str 
//[TypedefStatement]

TypeStatement:
	'type' 

	(type=BuiltInType | (pre=STRINGARG ':') ? imptype=[TypedefStatement])
	(';' 
	|'{' (typesubstatements+=TypeSubStatement)* '}');    


TypeSubStatement:
	(
	DefaultStatement
	|EnumStatement
	|LengthStatement
	|PatternStatement
	|RangeStatement
	|TypeStatement
	);


This is a yang dsl plugin which contains standard 'type' and 'typedef.
I am trying to reference from this file to another file. but I am not able to do it.

  module ietf-yang-types {

 namespace
      "urn:ietf:params:xml:ns:yang:ietf-yang-types";

    prefix "yang";

    organization
      "IETF NETMOD (NETCONF Data Modeling Language) Working Group";

    description
      "This module contains a collection of generally useful derived
    YANG data types.

    revision "2010-09-24" {
      description "Initial revision.";
      reference
        "RFC 6021: Common YANG Data Types";

    }


    typedef counter32 {
      type uint32;
      description
        "The counter32 type represents a non-negative integer
      that monotonically increases until it reaches a
      maximum value of 2^32-1 (4294967295 decimal), when it
      wraps around and starts increasing again from zero.

      In the value set and its semantics, this type is equivalent
      to the Counter32 type of the SMIv2.";
      reference
        "RFC 2578: Structure of Management Information Version 2
        	  (SMIv2)";

    }

    typedef zero-based-counter32 {
      type counter32;
      default "0";
      description
        "The zero-based-counter32 type represents a counter32
      that has the defined 'initial' value zero.

      In the value set and its semantics, this type is equivalent
      to the ZeroBasedCounter32 textual convention of the SMIv2.";
      reference
        "RFC 4502: Remote Network Monitoring Management Information
        	  Base Version 2";

    }

    typedef counter64 {
      type uint64;
      description
        "The counter64 type represents a non-negative integer
      that monotonically increases until it reaches a
      maximum value of 2^64-1 (18446744073709551615 decimal),
      when it wraps around and starts increasing again from zero.

      In the value set and its semantics, this type is equivalent
      to the Counter64 type of the SMIv2.";
      reference
        "RFC 2578: Structure of Management Information Version 2
        	  (SMIv2)";

    }

    typedef zero-based-counter64 {
      type counter64;
      default "0";
      description
        "The zero-based-counter64 type represents a counter64 that
      has the defined 'initial' value zero.
      In the value set and its semantics, this type is equivalent
      to the ZeroBasedCounter64 textual convention of the SMIv2.";
      reference
        "RFC 2856: Textual Conventions for Additional High Capacity
        	  Data Types";

    }

    typedef gauge32 {
      type uint32;
      description
        "The gauge32 type represents a non-negative integer, which
      may increase or decrease, but shall never exceed a maximum
      value, nor fall below a minimum value.  The maximum value
      cannot be greater than 2^32-1 (4294967295 decimal), and
      the minimum value cannot be smaller than 0.  The value of
      a gauge32 has its maximum value whenever the information
      being modeled is greater than or equal to its maximum
      value, and has its minimum value whenever the information
      being modeled is smaller than or equal to its minimum value.
      If the information being modeled subsequently decreases
      below (increases above) the maximum (minimum) value, the
      gauge32 also decreases (increases).

      In the value set and its semantics, this type is equivalent
      to the Gauge32 type of the SMIv2.";
      reference
        "RFC 2578: Structure of Management Information Version 2
        	  (SMIv2)";

    }

    typedef gauge64 {
      type uint64;
      description
        "The gauge64 type represents a non-negative integer, which
      may increase or decrease, but shall never exceed a maximum
      value, nor fall below a minimum value.  The maximum value
      cannot be greater than 2^64-1 (18446744073709551615), and
      the minimum value cannot be smaller than 0.  The value of
      a gauge64 has its maximum value whenever the information
      being modeled is greater than or equal to its maximum
      value, and has its minimum value whenever the information
      being modeled is smaller than or equal to its minimum value.
      If the information being modeled subsequently decreases
      below (increases above) the maximum (minimum) value, the
      gauge64 also decreases (increases).

      In the value set and its semantics, this type is equivalent
      to the CounterBasedGauge64 SMIv2 textual convention defined
      in RFC 2856";
      reference
        "RFC 2856: Textual Conventions for Additional High Capacity
        	  Data Types";

    }

    typedef object-identifier {
      type string {
        pattern
          '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))(\.(0|([1-9]\d*)))*';
      }
      description
        "The object-identifier type represents administratively
      assigned names in a registration-hierarchical-name tree.";
      reference
        "ISO9834-1: Information technology -- Open Systems
        Interconnection -- Procedures for the operation of OSI
        Registration Authorities: General procedures and top
        arcs of the ASN.1 Object Identifier tree";

    }

    typedef object-identifier-128 {
      type object-identifier {
        pattern '\d*(\.\d*){1,127}';
      }
      description
        "This type represents object-identifiers restricted to 128
      sub-identifiers.

      In the value set and its semantics, this type is equivalent
      to the OBJECT IDENTIFIER type of the SMIv2.";
      reference
        "RFC 2578: Structure of Management Information Version 2
        	  (SMIv2)";

    }

    
    typedef timeticks {
      type uint32;
      description
        "The timeticks type represents a non-negative integer that
      represents the time, modulo 2^32 (4294967296 decimal), in
      hundredths of a second between two epochs.  When a schema
      node is defined that uses this type, the description of
      the schema node identifies both of the reference epochs.

      In the value set and its semantics, this type is equivalent
      to the TimeTicks type of the SMIv2.";
      reference
        "RFC 2578: Structure of Management Information Version 2
        	  (SMIv2)";

    }

    typedef timestamp {
      type timeticks;
      description
        "The timestamp type represents the value of an associated
      timeticks schema node at which a specific occurrence
      happened.  The specific occurrence must be defined in the
      description of any schema node defined using this type.  When
      the specific occurrence occurred prior to the last time the
      associated timeticks attribute was zero, then the timestamp
      value is zero.  Note that this requires all timestamp values
      to be reset to zero when the value of the associated timeticks
      attribute reaches 497+ days and wraps around to zero.

      In the value set and its semantics, this type is equivalent
      to the TimeStamp textual convention of the SMIv2.";
      reference
        "RFC 2579: Textual Conventions for SMIv2";

    }
    
    }

    
  }  // module ietf-yang-types



This is my another DSL plugin 'snmpv2-mib.yang'
I am trying to reference 'type' from ietf-yang-types.yang > snmpv2-mib.yang

module SNMPv2-MIB {

  namespace "urn:ietf:params:xml:ns:yang:smiv2:SNMPv2-MIB";
  prefix "snmpv2-mib";

  import SNMPv2-TC {
    prefix "snmpv2-tc";
  }

  import ietf-yang-smiv2 {
    prefix "smiv2";
  }

  import ietf-yang-types {
    prefix "yang";
  }

  organization
   "IETF SNMPv3 Working Group";

  revision 1993-04-01 {
    description
     "The initial revision of this MIB module was published
      as RFC 1450.";
  }

  container SNMPv2-MIB {
    config false;

    container system {
      smiv2:oid "1.3.6.1.2.1.1";

      leaf sysDescr {
        type yang:ietf-yang-types.object-identifier 
        {
          length "0..255";
        }
        description
         "A textual description of the entity.  This value should
          include the full name and version identification of
          the system's hardware type, software operating-system,
          and networking software.";
        smiv2:max-access "read-only";
        smiv2:oid "1.3.6.1.2.1.1.1";
      }

      leaf sysObjectID {
        type yang:object-identifier;
        description
         "The vendor's authoritative identification of the
          network management subsystem contained in the entity.
          This value is allocated within the SMI enterprises
          subtree (1.3.6.1.4.1) and provides an easy and
          unambiguous means for determining `what kind of box' is
          being managed.  For example, if vendor `Flintstones,
          Inc.' was assigned the subtree 1.3.6.1.4.1.424242,
          it could assign the identifier 1.3.6.1.4.1.424242.1.1
          to its `Fred Router'.";
        smiv2:max-access "read-only";
        smiv2:oid "1.3.6.1.2.1.1.2";
      }



I hope now you can understand my problem.

Thanks.
Re: Reference output problem. [message #1768801 is a reply to message #1768800] Mon, 24 July 2017 05:23 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
In above code of snmpv2-mib.yang file,
type yang:object-identifier;            > I want this in my dsl plugin


but I am getting

type yang:ietf-yang-types.object-identifier 


which is wrong according to yang module.

[Updated on: Mon, 24 July 2017 05:25]

Report message to a moderator

Re: Reference output problem. [message #1768805 is a reply to message #1768801] Mon, 24 July 2017 05:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
what did you implement in your IQualifiedNameProvider?!?
the default impl is

<grandparentname>.<parentname>.<name>

see DefaultDeclarativeQualifedNameProvider


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1768806 is a reply to message #1768805] Mon, 24 July 2017 06:00 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
I am not implementing IQualifiedNameProvider.

I am new in Xtext.
Re: Reference output problem. [message #1768807 is a reply to message #1768806] Mon, 24 July 2017 06:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
then have a look on how to implement it

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1768808 is a reply to message #1768807] Mon, 24 July 2017 06:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
e.g. https://christiandietrich.wordpress.com/2011/07/16/iqualifiednameproviders-in-xtext-2-0/

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1768927 is a reply to message #1768808] Tue, 25 July 2017 04:57 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Hi Christian,

I was checking your blogs and I find your blog on Xtext and Strings as Cross-References.

I am also trying to achieve cross-referencing. But I get some extra syntax in my editor when trying ctrl+space. It comes with module and type (eg.
type ietf-yang-types.object-identifier;


but I only want type name which looks like

type object-identifier;


I am still not getting the point to use IQualifiedNameProvider.

Can I only use Xtext grammar for the above dsl?

Thanks.
Re: Reference output problem. [message #1768929 is a reply to message #1768927] Tue, 25 July 2017 05:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
you might get ietf-yang-types.object-identifier cause thats the name of the thing.
if you dislike the name you have to change the name.
that is what IQualifiedNameProvider does


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1768939 is a reply to message #1768929] Tue, 25 July 2017 06:53 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Thanks Christian,

I am creating yang plugin using xtext grammar based on this project which is already a yang plugin by AT&T.

https://github.com/att/yang-design-studio/blob/master/yang.Manager/src/yang/YANG.xtext

I couldn't find IQualifiedNameProvider in the whole project.
Please check it and let me know where I am wrong, If possible.

Thanks.
Re: Reference output problem. [message #1768943 is a reply to message #1768939] Tue, 25 July 2017 07:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Simply create a new one

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1768945 is a reply to message #1768943] Tue, 25 July 2017 07:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
EG subclass defaultdeclsrativequalifiednameprovider as I do in my blog

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1768947 is a reply to message #1768945] Tue, 25 July 2017 07:43 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member

Can you please explain with more details?
Thanks.
Re: Reference output problem. [message #1768955 is a reply to message #1768947] Tue, 25 July 2017 08:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
in eclipse you find a file menu
there you can select new JavaClass

Enter a package and a name
select DefaultDeclarativeQualifiedNameProvider as supertyper

implement a

QualifiedName qualifiedName(<TypeYouWantToName> xxxx) {
//TODO
return QualifiedName.create("part1", "part2");
}

method

add a binding to yourdslruntimemodule


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769032 is a reply to message #1768955] Wed, 26 July 2017 03:32 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Hi Christian,

I am still getting the same error. I think you should try my grammar and dsl.

https://drive.google.com/open?id=0B1qBozMfAwyAZUlFYTJJSnhmQk0

This is my whole project. There are all the instruction of the project.

It will take only 5 minutes to try it by yourself.

Please help me with this problem.

Thanks.

[Updated on: Wed, 26 July 2017 03:33]

Report message to a moderator

Re: Reference output problem. [message #1769037 is a reply to message #1769032] Wed, 26 July 2017 04:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
well its nice to have 1000 lines of young files but its not nice not to have a language spec
you did not share your nameprovider

thus it could be

public class MyDslQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider {

	@Inject
	private IQualifiedNameConverter qnc;
	
	public QualifiedName qualifiedName(TypedefStatement s) {
		return qnc.toQualifiedName(s.getName());
	}
	
}



class MyDslRuntimeModule extends AbstractMyDslRuntimeModule {
	
	override bindIQualifiedNameProvider() {
		MyDslQualifiedNameProvider
	}
	
}



or it could be something different like ( i dont know how that stuff before the colon work?)

package org.xtext.example.mydsl3;

import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider;
import org.eclipse.xtext.naming.IQualifiedNameConverter;
import org.eclipse.xtext.naming.QualifiedName;
import org.xtext.example.mydsl3.myDsl.Module;
import org.xtext.example.mydsl3.myDsl.PrefixStatement;
import org.xtext.example.mydsl3.myDsl.Statement;
import org.xtext.example.mydsl3.myDsl.TypedefStatement;

import com.google.inject.Inject;

public class MyDslQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider {

	@Inject
	private IQualifiedNameConverter qnc;
	
	public QualifiedName qualifiedName(TypedefStatement s) {
		// TODO handle submodule etc
		//TODO are multiple prefixes possible then better adapt
		// IDefaultResourceDescritionStrategy
		// its your logic
		Module m = EcoreUtil2.getContainerOfType(s, Module.class);
		if (m != null)  {
			for (Statement sm : m.getStatements()) {
				if (sm instanceof PrefixStatement) {
					String name = ((PrefixStatement) sm).getName();
					if (name != null) {
						// dont know if you have a ivalueconverter service that strips the ""
						name = name.substring(1, name.length()-1);
						return qnc.toQualifiedName(name).append(qnc.toQualifiedName(s.getName()));
					}
				}
			}
		}
		
		return qnc.toQualifiedName(s.getName());
	}
	
}



package org.xtext.example.mydsl3.scoping;

import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.naming.IQualifiedNameConverter;
import org.eclipse.xtext.scoping.impl.ImportNormalizer;
import org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider;
import org.xtext.example.mydsl3.myDsl.TypeStatement;

import com.google.inject.Inject;

public class MyDslImportedNamespaceAwareLocalScopeProvider extends ImportedNamespaceAwareLocalScopeProvider {

	@Inject
	private IQualifiedNameConverter qnc;
	
	@Override
	protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(EObject context, boolean ignoreCase) {
		List<ImportNormalizer> result = super.internalGetImportedNamespaceResolvers(context, ignoreCase);
		if (context instanceof TypeStatement) {
			TypeStatement s = (TypeStatement)context;
			if (s.getPre() != null)
			result.add(doCreateImportNormalizer(qnc.toQualifiedName(((TypeStatement) context).getPre()) , true, ignoreCase));
		}
		return result;
	}
	
}



class MyDslRuntimeModule extends AbstractMyDslRuntimeModule {
	
	override bindIQualifiedNameProvider() {
		MyDslQualifiedNameProvider
	}


	override configureIScopeProviderDelegate(Binder binder) {
		binder.bind(IScopeProvider).annotatedWith(Names.named(AbstractDeclarativeScopeProvider.NAMED_DELEGATE))
		.to(MyDslImportedNamespaceAwareLocalScopeProvider) 

	}
	
}





or you turn the prefix thingy to a reference as well and implement scoping based on the prefix thingy


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769040 is a reply to message #1769037] Wed, 26 July 2017 05:15 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
none of above are working.

don't look at the yang files yet.

just run the xtext file in eclipse. then copy all four files into the new eclipse application which pop ups after running the project. (run as > new eclipse application).

After you copy all four files it will show you errors in "SNMPv2-TC.yang" and "SNMPv2-MIB.yang"

other two files are ok.

Thanks for your help.
Re: Reference output problem. [message #1769042 is a reply to message #1769040] Wed, 26 July 2017 05:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
please share complete code !!!!!!!!!

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769043 is a reply to message #1769040] Wed, 26 July 2017 05:18 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Prefix element is set as STRINGARG. so it's not a problem. You can check the TypeStatement and TypedefStatement in the xtext file.

Thanks.
Re: Reference output problem. [message #1769044 is a reply to message #1769042] Wed, 26 July 2017 05:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
and of your its not yourdsl or mydslruntime module in your case but yangruntimemodule or whatever
thats obvious isnt it ?!?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769046 is a reply to message #1769044] Wed, 26 July 2017 05:23 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
https://drive.google.com/open?id=0B1qBozMfAwyAQjBhMWstWHNLTTA

Check this for my full project.

Yes I know. It's YangDefinitionRuntimeModule.
Re: Reference output problem. [message #1769049 is a reply to message #1769046] Wed, 26 July 2017 05:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
your code does not contain the name provider

did you do a clean build in both the development and runtime eclipse.
did you restart the runtime eclipse?

the only errors i get are

mismatched input 'list' expecting '}'

but thats a different thing


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769052 is a reply to message #1769049] Wed, 26 July 2017 05:51 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
I select Build Automatically option from the project menu. So whenever I build, My name provider file is automatically deleted.

those error mismatched input list expecting '}' is beacause of I haven't created rule for the 'list'.

By the way, I have unchecked the build automatically option and then tried the namequalifiedprovider and the bind in the runtime model.

Now it's interesting,
I can get few types perfectly but not all.
I can get the those types which I am importing from the SNMPv2-TC.yang file but the others are showing error of "Couldn't resolve reference to TypedefStatement 'counter32'."

The types from ietf-yang-types.yang and ietf-yang-smiv2.yang are showing errors.

Thanks.
Re: Reference output problem. [message #1769053 is a reply to message #1769052] Wed, 26 July 2017 06:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
which of my solutions did you pick now?
the first one? the second one?

see my screenshot

i have no idea what you are exactly doing

did you use the open model element dialog
(navigate menu)
to see that the actual names are



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769054 is a reply to message #1769053] Wed, 26 July 2017 06:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
and as i said: you need to clean build the project so that gthe new names get picked up

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769056 is a reply to message #1769054] Wed, 26 July 2017 06:19 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member


I have used first solution.
You are getting no errors of type.

I wil try it with clean and build.

https://drive.google.com/open?id=0B1qBozMfAwyAZEwxd1g1bGZZZ00

This is my updated project.


Yes, I used open model element dialog but it shows me only few actual names.
But the names from the file ietf-yang-types.yang and ietf-yang-smiv2.yang are with the module name.


As you can see in my screenshot,
there are two types
one with yang prefix and
second with snmpv2-tc prefix.

One shows me error and other is not.


Re: Reference output problem. [message #1769058 is a reply to message #1769056] Wed, 26 July 2017 06:25 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Can you please share your project with me?

Thanks.
Re: Reference output problem. [message #1769059 is a reply to message #1769058] Wed, 26 July 2017 06:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
please close the project containing the yang file and reopen it

the name of timeticks is timeticks in my case.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769060 is a reply to message #1769059] Wed, 26 July 2017 06:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
here is a screenshot

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769063 is a reply to message #1769060] Wed, 26 July 2017 06:57 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
It works.
Thanks heaps Christian.
as you told me reopen all the project works perfectly.
appreciate your help.

Thanks once again.
Re: Reference output problem. [message #1769221 is a reply to message #1769063] Fri, 28 July 2017 01:58 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Hi Christian,

Thanks for your help. I have one more question. Can I use QualifiedNameProvider for multiple statement for the cross-reference?

Regards,
Kaushal.
Re: Reference output problem. [message #1769231 is a reply to message #1769221] Fri, 28 July 2017 06:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
sorry dont understand what " for multiple statement for the cross-reference?" means

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769232 is a reply to message #1769231] Fri, 28 July 2017 06:20 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
The problem is fixed.
Multiple means many statements
I mean one and more statements.

[Updated on: Fri, 28 July 2017 06:21]

Report message to a moderator

Re: Reference output problem. [message #1769233 is a reply to message #1769232] Fri, 28 July 2017 06:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
i still dont understand

if you have

Hello World!

the IQualifiedNAmeProvider gices the Greeting that name "World"
what do you want to do?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference output problem. [message #1769359 is a reply to message #1769233] Mon, 31 July 2017 01:52 Go to previous messageGo to next message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Hi Christian,

That error is solved.
I was just trying to use IQualifiedNameProvider for two statements as you can see in the below code.


public class YangDefinitionQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider {

	@Inject
	private IQualifiedNameConverter qnc;
	
	public QualifiedName qualifiedName(TypedefStatement s) {
		return qnc.toQualifiedName(s.getName());
	}
	
	public QualifiedName qualifiedName(GroupingStatement g) {
		return qnc.toQualifiedName(g.getName());
	}



This error is solved.


Now my question is,
I am trying to use cross reference in unknown statement but I am not able to use it.
When i press contol+space it does not show me any values.



ExtensionStatement:
	'extension' name=(STRINGARG | KEY_IDENTIFIER) 
        (';' | '{'
		(extensionsubstatements+=ExtensionSubStatement)*
		'}'
	)
;

UnknownStatement:
	((pre=STRINGARG ':')? (extension=[ExtensionStatement]) (arg=STRINGARG)?)
	(';'
		| '{'
			(unknownsubstatements+= UnknownStatement)*
		'}'
	);



I want value of extension statement in unknown statement.
Re: Reference output problem. [message #1769361 is a reply to message #1769359] Mon, 31 July 2017 02:30 Go to previous message
Kaushal Patel is currently offline Kaushal PatelFriend
Messages: 72
Registered: June 2017
Member
Again,

All errors are solved.
Thanks.
Previous Topic:Couldn't resolve reference to FunctionblockModel 'RainSensor'.
Next Topic:Is there incremental parser or partial parser in Xtext or ANTLR
Goto Forum:
  


Current Time: Tue Mar 19 09:22:51 GMT 2024

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

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

Back to the top