Package sc.lang.java

Class Statement

    • Field Detail

      • errorArgs

        public transient java.lang.Object[] errorArgs
      • childNestingDepth

        public transient int childNestingDepth
      • excluded

        public transient boolean excluded
        Has this statement been determined not to be included in this runtime - e.g. it's a java only class and this is the js runtime
    • Constructor Detail

      • Statement

        public Statement()
    • Method Detail

      • getIndentStr

        public java.lang.String getIndentStr()
      • collectReferenceInitializers

        public void collectReferenceInitializers​(java.util.List<Statement> refInits)
      • collectConstructorPropInit

        public void collectConstructorPropInit​(ConstructorPropInfo cpi)
      • isLabeled

        public boolean isLabeled​(java.lang.String label)
      • displayTypeError

        public boolean displayTypeError​(java.lang.String... args)
        Description copied from class: JavaSemanticNode
        Used for errors involving type resolution. These errors can be disabled during certain operations like transform
        Overrides:
        displayTypeError in class JavaSemanticNode
      • displayError

        public void displayError​(java.lang.String... args)
        Description copied from class: JavaSemanticNode
        Used for errors that should always be displayed
        Overrides:
        displayError in class JavaSemanticNode
      • displayRangeError

        public void displayRangeError​(int fromIx,
                                      int toIx,
                                      boolean notFound,
                                      java.lang.String... args)
      • hasErrors

        public boolean hasErrors()
        Returns true if there are errors in this node or any child node of this node
        Overrides:
        hasErrors in class SemanticNode
      • callsSuper

        public boolean callsSuper​(boolean checkModSuper)
        Does this method call "super(xxx)" for a constructor definition
      • callsSuperMethod

        public boolean callsSuperMethod​(java.lang.String methName)
        Does this method call super.methName()
      • markFixedSuper

        public void markFixedSuper()
      • callsThis

        public boolean callsThis()
      • getConstrArgs

        public Expression[] getConstrArgs()
      • clearDynFields

        public void clearDynFields​(java.lang.Object inst,
                                   ExecutionContext ctx,
                                   boolean initExt)
      • refreshBoundTypes

        public abstract boolean refreshBoundTypes​(int flags)
      • addDependentTypes

        public abstract void addDependentTypes​(java.util.Set<java.lang.Object> types,
                                               JavaSemanticNode.DepTypeCtx mode)
      • setAccessTimeForRefs

        public abstract void setAccessTimeForRefs​(long time)
      • transformToJS

        public abstract Statement transformToJS()
      • addReturnStatements

        public void addReturnStatements​(java.util.List<Statement> res,
                                        boolean includeThrow)
      • setComment

        public void setComment​(java.lang.String s)
      • getComment

        public java.lang.String getComment()
      • addChildBodyStatements

        public void addChildBodyStatements​(java.util.List<java.lang.Object> statements)
      • clearTransformed

        public void clearTransformed()
      • deepCopy

        public Statement deepCopy​(int options,
                                  java.util.IdentityHashMap<java.lang.Object,​java.lang.Object> oldNewMap)
        Description copied from interface: ISemanticNode
        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.
        Specified by:
        deepCopy in interface ISemanticNode
        Overrides:
        deepCopy in class Definition
      • getStatementTerminator

        public java.lang.String getStatementTerminator()
      • getNodeContainsPart

        public boolean getNodeContainsPart​(ISrcStatement partNode)
        If this statement, as part of the transformed model was generated from this provided source statement. Override this statement to control which generated statements are produced from a given stc statement.
        Specified by:
        getNodeContainsPart in interface ISrcStatement
      • findFromStatement

        public ISrcStatement findFromStatement​(ISrcStatement st)
        Returns the statement that was generated from the given src statement. This will end up being the first one we encounter in the search for the src statement in the chain of fromStatements.
        Specified by:
        findFromStatement in interface ISrcStatement
      • addBreakpointNodes

        public void addBreakpointNodes​(java.util.List<ISrcStatement> res,
                                       ISrcStatement st)
        Description copied from interface: ISrcStatement
        Adds all of the generated statements to the resulting list, for the case where more than one fromStatement points to the same src statement. These are used to determine which statements in the generated code should cause a 'break' when the developer sets a breakpoint on this statement.
        Specified by:
        addBreakpointNodes in interface ISrcStatement
      • updateFromStatementRef

        public boolean updateFromStatementRef​(Statement fromSt,
                                              ISrcStatement defaultSt)
        During code-transformation, sometimes we end up parsing dynamically generated code which is derived from some source objects - e.g. during the object and property transformation. This method registers the generated code. You can provide a 'fromStatement' and a default statement. If the from statement matches, this node is updated. If the fromStatement is null the defaultStatement is used.

        To determine whether the fromStatement matches this statement, we call matchesStatement. For assignment expressions right now, that allows us to match the right assignment statement in the list to the source from which it was generated from.

      • matchesStatement

        public boolean matchesStatement​(Statement other)
      • getSrcStatement

        public ISrcStatement getSrcStatement​(Language lang)
        Description copied from interface: ISrcStatement
        When called on a generated node, finds the original source node for the specified language which must be one of the intermediate languages this node was generated from. Lang can be null in which case we trace generated nodes to find the original source language.
        Specified by:
        getSrcStatement in interface ISrcStatement
      • getFromStatement

        public ISrcStatement getFromStatement()
        Description copied from interface: ISrcStatement
        Returns the value of the 'fromStatement' field stored on this node to represent a link from a generated node from an original source one.
        Specified by:
        getFromStatement in interface ISrcStatement
      • childIsTopLevelStatement

        public boolean childIsTopLevelStatement​(Statement child)
      • needsEnclosingClass

        public boolean needsEnclosingClass()
        Disables the optimization where 'object foo extends bar' omits class foo for simple configuration objects. Certain constructs like methods, fields, clearly disable this. Others like EnclosingType.this also will because we can only evaluate that expression in the context of a class (unless I suppose the object happens to be a child of the same outer type)
      • addMembersByName

        public void addMembersByName​(java.util.Map<java.lang.String,​java.util.List<Statement>> membesByName)
      • conflictsWith

        public boolean conflictsWith​(Statement other,
                                     java.lang.String memberName)
        Does this statement conflict with another statement in the same list with this member name. Because fields can define more than one variable, (and variableDefinitions are not Statements) we need to report conflicts on a name-by-name basis.
      • addMemberByName

        public void addMemberByName​(java.util.Map<java.lang.String,​java.util.List<Statement>> membersByName,
                                    java.lang.String memberName)
      • isLeafStatement

        public boolean isLeafStatement()
      • isLineStatement

        public boolean isLineStatement()
      • getNumStatementLines

        public int getNumStatementLines()
        Returns the number of lines this statement occupies for means of navigation, breakpoints, debugging etc.
        Specified by:
        getNumStatementLines in interface ISrcStatement
      • addToFileLineIndex

        public void addToFileLineIndex​(GenFileLineIndex idx,
                                       int rootStartGenLine)
        Adds this statement to the generated file line index. If you pass in rootStartGenLen = -1, the generated source file is used to compute the line number using this parse-node's offset into that file. If you pass in a positive value, we count the lines in "currentStatement" of the index up until the parse-node's offset. You can use this mode to incrementally generate an index, even when there's no complete transformed model for the entire file (such as with generating JS). In that case, we have a generated model for each statement and are manually adding statements to the file, so we need to compute the line numbers relative to this "currentStatement" - i.e. the root statement.
      • setFromStatement

        public void setFromStatement​(ISrcStatement from)
      • addMappingForSrcStatement

        public static void addMappingForSrcStatement​(GenFileLineIndex lineIndex,
                                                     ISrcStatement srcStatement,
                                                     int genStartLine,
                                                     java.lang.CharSequence genStatementCode)
      • addMappingForStatement

        public static void addMappingForStatement​(GenFileLineIndex lineIndex,
                                                  Statement st,
                                                  int genStartLine,
                                                  java.lang.CharSequence genStatementCode)
      • addStatementNodeCompletions

        public static java.lang.String addStatementNodeCompletions​(JavaModel origModel,
                                                                   JavaSemanticNode origNode,
                                                                   java.lang.String matchPrefix,
                                                                   int offset,
                                                                   java.lang.String dummyIdentifier,
                                                                   java.util.Set<java.lang.String> candidates,
                                                                   boolean nextNameInPath,
                                                                   int max)
      • addNodeCompletions

        public java.lang.String addNodeCompletions​(JavaModel origModel,
                                                   JavaSemanticNode origNode,
                                                   java.lang.String matchPrefix,
                                                   int offset,
                                                   java.lang.String dummyIdentifier,
                                                   java.util.Set<java.lang.String> candidates,
                                                   boolean nextNameInPath,
                                                   int max)
        Description copied from class: JavaSemanticNode
        This works like suggestCompletions but designed to conform to the requirements of IntelliJ. We don't support the live programming use case in this version and have access (possibly) to the original model and original node which most closely approximates this node which is being parsed (so we can use more context to do a better job of matching because those values are all resolved).
        Overrides:
        addNodeCompletions in class JavaSemanticNode
      • execForRuntime

        public Statement.RuntimeStatus execForRuntime​(LayeredSystem sys)
        When choosing in which runtimes to run this statement, returns the member or type of the method or field used in the expression. Not always possible to determine so return null in those other cases.
      • getBuildInitExpression

        public Expression getBuildInitExpression​(java.lang.Object expectedType)
      • isIncompleteStatement

        public boolean isIncompleteStatement()