Class Message

  • All Implemented Interfaces:
    IMessage

    public class Message
    extends Message
    Implements a message issues by the model translator (in order to provide feedback on multiple issues at once).
    Author:
    Holger Eichelberger
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  Message.IssueLocation
      Represents an issue location.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.eclipse.emf.ecore.EObject cause
      Stores the ECore element causing the error.
      private org.eclipse.emf.ecore.EStructuralFeature causingFeature
      Stores the (sub-)feature of cause.
      private int code
      A code representing the message.
      static int CODE_IGNORE
      Defines the code used for messages which can be ignored.
    • Constructor Summary

      Constructors 
      Constructor Description
      Message​(java.lang.String message, Status status, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature, int code)
      Creates a message object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String fieldToString​(java.lang.Object obj, java.lang.Class<?> cls, java.lang.String field)
      Tries to obtain the value of the field field from obj as a String.
      private static java.lang.String fieldToString​(java.lang.Object obj, java.lang.String field)
      Tries to obtain the value of the field field from obj as a String.
      org.eclipse.emf.ecore.EObject getCause()
      Returns the cause of the message (in terms of the causing ECore element).
      org.eclipse.emf.ecore.EStructuralFeature getCausingFeature()
      Returns the causing feature (within getCause()).
      int getCode()
      Returns a code for the message.
      java.lang.String getDetailedDescription()
      Returns a detailed message description (if available) or IMessage.getDescription().
      protected Message.IssueLocation getLocationData​(org.eclipse.emf.ecore.EObject obj, org.eclipse.emf.ecore.EStructuralFeature structuralFeature, int index)
      Returns the location for a given cause obj, structuralFeatue and index of the node within obj.
      protected Message.IssueLocation getLocationForNode​(org.eclipse.xtext.nodemodel.INode node)
      Returns the issue location for the given node.
      protected Message.IssueLocation getLocationForNode​(org.eclipse.xtext.nodemodel.INode node, int offset, int length)
      Computes the Message.IssueLocation for the given offset and length in the given node.
      boolean ignore()
      Returns whether this message can be ignored.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CODE_IGNORE

        public static final int CODE_IGNORE
        Defines the code used for messages which can be ignored.
        See Also:
        Constant Field Values
      • cause

        private org.eclipse.emf.ecore.EObject cause
        Stores the ECore element causing the error.
      • causingFeature

        private org.eclipse.emf.ecore.EStructuralFeature causingFeature
        Stores the (sub-)feature of cause.
      • code

        private int code
        A code representing the message.
        See Also:
        CODE_IGNORE
    • Constructor Detail

      • Message

        public Message​(java.lang.String message,
                       Status status,
                       org.eclipse.emf.ecore.EObject cause,
                       org.eclipse.emf.ecore.EStructuralFeature causingFeature,
                       int code)
        Creates a message object.
        Parameters:
        message - the message text
        status - the message status
        cause - the ECore element causing the message
        causingFeature - the feature within cause
        code - a numerical code representing the message (see CODE_IGNORE)
    • Method Detail

      • getCause

        public org.eclipse.emf.ecore.EObject getCause()
        Returns the cause of the message (in terms of the causing ECore element).
        Returns:
        the cause of the message
      • getCausingFeature

        public org.eclipse.emf.ecore.EStructuralFeature getCausingFeature()
        Returns the causing feature (within getCause()).
        Returns:
        the causing feature
      • getCode

        public int getCode()
        Returns a code for the message.
        Returns:
        the code
      • ignore

        public boolean ignore()
        Returns whether this message can be ignored.
        Returns:
        true if it can be ignored, false else
      • getDetailedDescription

        public java.lang.String getDetailedDescription()
        Description copied from interface: IMessage
        Returns a detailed message description (if available) or IMessage.getDescription(). Details may e.g., include file position or line number. As e.g. xText cares for location and position itself, this information would be superfluous there, but helpful in a command line context, where this method shall be used instead.
        Specified by:
        getDetailedDescription in interface IMessage
        Overrides:
        getDetailedDescription in class Message
        Returns:
        the (detailed) message description
      • getLocationForNode

        protected Message.IssueLocation getLocationForNode​(org.eclipse.xtext.nodemodel.INode node)
        Returns the issue location for the given node.
        Parameters:
        node - the node to return the location for
        Returns:
        the issue location
      • getLocationForNode

        protected Message.IssueLocation getLocationForNode​(org.eclipse.xtext.nodemodel.INode node,
                                                           int offset,
                                                           int length)
        Computes the Message.IssueLocation for the given offset and length in the given node.
        Parameters:
        node - the node
        offset - the text offset of the node
        length - the text length of the node
        Returns:
        the issue location
      • getLocationData

        protected Message.IssueLocation getLocationData​(org.eclipse.emf.ecore.EObject obj,
                                                        org.eclipse.emf.ecore.EStructuralFeature structuralFeature,
                                                        int index)
        Returns the location for a given cause obj, structuralFeatue and index of the node within obj.
        Parameters:
        obj - the object to look into
        structuralFeature - the structural feature within obj
        index - the node index within obj, usually 0
        Returns:
        the location, may be the beginning of a document if the parse nodes cannot be found (may be null)
      • fieldToString

        private static java.lang.String fieldToString​(java.lang.Object obj,
                                                      java.lang.String field)
        Tries to obtain the value of the field field from obj as a String.
        Parameters:
        obj - the object to query
        field - the name of the field to query
        Returns:
        the value of the field as String, may be null if field does not exist.
        See Also:
        fieldToString(Object, Class, String)
      • fieldToString

        private static java.lang.String fieldToString​(java.lang.Object obj,
                                                      java.lang.Class<?> cls,
                                                      java.lang.String field)
        Tries to obtain the value of the field field from obj as a String.
        Parameters:
        obj - the object to query
        cls - the class of obj to use (immediate or parent)
        field - the name of the field to query
        Returns:
        the value of the field as String, may be null if field does not exist.