Package sc.lang

Interface ISemanticNode

    • Field Detail

      • CopyParseNode

        static final int CopyParseNode
        Options for the deepCopy method - OR'd together as bit flags. Copy the complete parse node tree
        See Also:
        Constant Field Values
      • CopyState

        static final int CopyState
        Copy the semantic node initialization state
        See Also:
        Constant Field Values
      • CopyInitLevels

        static final int CopyInitLevels
        Match the initialization level of the node to be copied.
        See Also:
        Constant Field Values
      • CopyTransformed

        static final int CopyTransformed
        Used to indicate this is the special clone for the transformed model. This let's the models register against each other as needed.
        See Also:
        Constant Field Values
      • CopyReplace

        static final int CopyReplace
        Indicates that the copy will replace the current statement in the model which is started. E.g. a TemplateExpression sets replaceStatement to the copy, so we can trace from the original to the actual code-model which is resolved
        See Also:
        Constant Field Values
      • CopyIndependent

        static final int CopyIndependent
        Used to avoid copying the fromStatement, like when we clone a model for a different system we don't want the copy pointing back to the original
        See Also:
        Constant Field Values
      • CopyNormal

        static final int CopyNormal
        Copy just some of the state in the semantic nodes. Used to speed things up and make code more robust during transform so expressions don't get re-resolved mid-stream. This mode does not copy the parse node but does create a new parse node which points to the parselet so we can re-generate this child. No initialized, started, etc. flags are copied.
        See Also:
        Constant Field Values
      • CopyAll

        static final int CopyAll
        Hook for copying everything - the complete initialized state of each of the objects
        See Also:
        Constant Field Values
    • Method Detail

      • setParseNode

        void setParseNode​(IParseNode pn)
      • restoreParseNode

        void restoreParseNode​(IParseNode pn)
        Like setParseNode but called from the restore method
      • setParseletId

        void setParseletId​(int id)
      • getParseletId

        int getParseletId()
      • getNestingDepth

        int getNestingDepth()
        Returns the number of levels of nesting of top-level constructs for indentation
      • getChildNestingDepth

        int getChildNestingDepth()
      • toHeaderString

        java.lang.String toHeaderString()
      • process

        void process()
        After validate, before transform
      • needsTransform

        boolean needsTransform()
      • toLanguageString

        java.lang.String toLanguageString()
      • toLanguageString

        java.lang.String toLanguageString​(Parselet p)
      • containsChild

        boolean containsChild​(java.lang.Object toReplace)
      • indexOfChild

        int indexOfChild​(java.lang.Object child)
      • getChildAtIndex

        java.lang.Object getChildAtIndex​(int ix)
      • replaceChild

        int replaceChild​(java.lang.Object toReplace,
                         java.lang.Object other)
        Finds the "toReplace" object in this nodes children, then replaces that node with the other object
      • removeChild

        int removeChild​(java.lang.Object toRemove)
      • getNodeErrorText

        java.lang.String getNodeErrorText()
        Returns null or an error string for this node
      • getNodeErrorRange

        ParseRange getNodeErrorRange()
        Returns null to mark the entire node - otherwise return a range that's more convenient for marking
      • getNotFoundError

        boolean getNotFoundError()
        Returns true if this is a special "not found" error
      • getNodeWarningText

        java.lang.String getNodeWarningText()
      • getDependencyDisabledText

        java.lang.String getDependencyDisabledText()
        Returns null or the text describing a dependency which is disabled to augment the error - e.g. for when a Layer is disabled and you want to reflect that in the error message you give to the user.
      • deepCopy

        ISemanticNode deepCopy​(int options,
                               java.util.IdentityHashMap<java.lang.Object,​java.lang.Object> oldNewMap)
        Performs a deep copy of the semantic node tree. Subclasses should do their own copy implementation to decide what else to copy. Uses the copy options flags above. The default, with 0, just copies the semantic node information so you get a new tree like's it parsed but without parse node info. Use that mode only if you want to throw away the original source and regenerate it all from scratch. Otherwise, you can copy the parse tree as well. If you want to copy the semantic node's initial resolved state - including it's init/start, etc. and whatever the subclass adds to that copy, use CopyState or CopyNormal - for both parse nodes and state.
      • getTransformed

        boolean getTransformed()
      • isInitialized

        boolean isInitialized()
      • isStarted

        boolean isStarted()
      • isValidated

        boolean isValidated()
      • clearStarted

        void clearStarted()
      • clearInitialized

        void clearInitialized()
      • regenerate

        boolean regenerate​(boolean finalGen)
        Regenerates the parsed description for this node
      • regenerateIfTracking

        void regenerateIfTracking​(boolean finalGen)
      • validateParseNode

        void validateParseNode​(boolean finalGen)
      • styleNode

        void styleNode​(IStyleAdapter adapter)
        By default, you configure styles using the parselet's styleName property. When you need to alter the syntax highlighting rules for a given node, you can override this method.
      • toModelString

        java.lang.CharSequence toModelString()
      • setParseNodeValid

        void setParseNodeValid​(boolean v)
      • isParseNodeValid

        boolean isParseNodeValid()
      • changeLanguage

        void changeLanguage​(Language l)
        It's common to want to convert from one language to another, particularly when those languages are related in a type hierarchy. For example, our Javascript language derives from Java so you can switch from one to the other. Any overlapping nodes, will swap parselets with the corresponding parselet in the other language. This handles cases like Java arrayInitializer to Javascript array initializer automatically, i.e. those cases which simply reorganize the syntax of the same program elements.
      • isSemanticChildValue

        boolean isSemanticChildValue​(ISemanticNode child)
        Sometimes in a semantic node, you need to add children which are semantic nodes but which are not part of the semantic node tree. For example, in type declaration, we have "hiddenBody" which stores body elements that behave as though they are added to the type but are not saved to the transformed file.

        For these cases, you should override this method and return false when child == hiddenBody. That way, we do not propagate up refresh events and things when nodes in that tree change.

      • deepEquals

        boolean deepEquals​(java.lang.Object other)
        Returns true if this object equals the other object by comparing all other properties with deepEquals
      • diffNode

        void diffNode​(java.lang.Object other,
                      java.lang.StringBuilder diffs)
        For debugging - produce a string representation of the diffs between two models
      • refreshNode

        ISemanticNode refreshNode()
        For nodes that are able to re-resolve themselves to the latest version, return the latest version. otherwise returns this.
      • isTrailingSrcStatement

        boolean isTrailingSrcStatement()
        Most statements if started before the newline that signals a breakpoint should be considered the 'source statement' for that line. Block statement is used to signal the end of the statement and is an exception.
      • setParseErrorNode

        void setParseErrorNode​(boolean v)
        If we failed to parse this node and instead parsed this node as an incomplete token (e.g. a ClassType as part of a classBodyDeclarations), this method is called with 'true'.
      • getParseErrorNode

        boolean getParseErrorNode()
        Returns the value of the parse error node flag. If your semantic value is used in a skipOnErrorParselet, you can implement this to differentiate error nodes from regularly parsed nodes
      • getNodeCount

        int getNodeCount()
        Returns number of nodes in this tree for helping to diagnose memory use
      • serialize

        void serialize​(sc.binf.ModelOutStream out)
        Saves all of the properties of this model as parsed. If you need to save additional state with the semantic model that's not set directly from the grammar, you can override this method, set additional fields and just make sure they are not marked 'transient'
      • clearParseNode

        void clearParseNode()