Package sc.lang.java

Class NewExpression

    • Field Detail

      • ANON_TYPE_PREFIX

        public static java.lang.String ANON_TYPE_PREFIX
      • typeIdentifier

        public java.lang.String typeIdentifier
      • boundType

        public transient java.lang.Object boundType
      • classPropertyName

        public transient java.lang.String classPropertyName
      • boundTypeName

        public transient java.lang.String boundTypeName
      • anonType

        public transient AnonClassDeclaration anonType
        For anonymous types, we may create a real top-level type to represent it in the runtime model.
      • anonTypeTransformed

        public transient AnonClassDeclaration anonTypeTransformed
        This is a clone of the anonType which gets transformed. It is only available in the transformed model
      • constructor

        public transient java.lang.Object constructor
      • isStaticContext

        public transient boolean isStaticContext
      • lambdaExpression

        public transient boolean lambdaExpression
        True if this new expression is part of a lambda expression. If so, it does not create a real type in the type system
    • Constructor Detail

      • NewExpression

        public NewExpression()
    • Method Detail

      • setInferredType

        public boolean setInferredType​(java.lang.Object inferredType,
                                       boolean finalType)
        Description copied from class: Expression
        Called once for each parent-child expression relationship during the start process to propagate the parent's inferredType to the child as we walk up the expression tree so that, for example, we know the initial information in the parameter type so we can find the right method, so the method's parameter types further refine types of the args. The last time we call it, finalType is set to true. When an error occurs and the type becomes "unknown" - we call this with type = UnknownReferredType and finalType =true
        Overrides:
        setInferredType in class IdentifierExpression
      • findMethod

        public java.lang.Object findMethod​(java.lang.String name,
                                           java.util.List<? extends java.lang.Object> params,
                                           java.lang.Object fromChild,
                                           java.lang.Object refType,
                                           boolean staticOnly,
                                           java.lang.Object inferredType)
        Overrides:
        findMethod in class JavaSemanticNode
      • evalTypeArguments

        public java.util.List<java.lang.Object> evalTypeArguments​(java.lang.Object type)
      • inNewMethod

        protected boolean inNewMethod()
      • resolve

        public void resolve()
      • getAnonymousType

        public ClassDeclaration getAnonymousType​(boolean xform)
      • getBindingTypeName

        public java.lang.String getBindingTypeName()
        Description copied from class: Expression
        Subclasses override this to return the class name to use for the binding expression
        Overrides:
        getBindingTypeName in class IdentifierExpression
      • styleNode

        public void styleNode​(IStyleAdapter adapter)
        Description copied from class: IdentifierExpression
        Styling for identifier expressions is complicated because the information we need to do the styling is at this level, but the elements we are styling are buried down in the parse-tree of this node. So far this is the only problematic case for Java so we are living with it but adding some features at the parselets level would help. One problem is that the parseNode for the IdentifierExpression may be expression, optExpression or exprStatement. We optionally need to 'drill down' to get the parse-node for the IdentifierExpression, then wrap the output with any parse nodes we skipped before or after. To handle this at the parselet level, we could skip those levels automatically. Another problem is that the path name is split into the first name, then "." followed by each subsequent name so there's an extra bump in the hierarchy to deal with the second and subsequent path-names. We could add a method called - childStyleHandler which is called for each child parse node that produces an array value (in this case, the identifiers array). It would return null for parse nodes which are ignored in styling or 'member' or 'staticMember' as necessary for each segment in the identifiers array. That method would be passed the current parent parse node, the child-index, and the current parse-node so it could go back into the identifier expression and find the right style for that segment of the path-name. It could probaby just unmap the value array and deal with the hierarchy skip so maybe we don't need that much context in that method.
        Specified by:
        styleNode in interface ISemanticNode
        Overrides:
        styleNode in class IdentifierExpression
      • transformTemplate

        public int transformTemplate​(int ix,
                                     boolean statefulContext)
        Description copied from class: JavaSemanticNode
        A pass over the semantic node tree to convert template statements into layer cake statements.
        Overrides:
        transformTemplate in class IdentifierExpression
      • deepCopy

        public NewExpression 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 IdentifierExpression
      • dimsToGenerateString

        protected java.lang.String dimsToGenerateString()
      • suggestCompletions

        public int suggestCompletions​(java.lang.String prefix,
                                      java.lang.Object currentType,
                                      ExecutionContext ctx,
                                      java.lang.String command,
                                      int cursor,
                                      java.util.Set<java.lang.String> candidates,
                                      java.lang.Object continuation,
                                      int max)
        TODO: very similar to ClassValueExpression.suggestCompletions - try to share this code?
        Overrides:
        suggestCompletions in class IdentifierExpression
      • addBreakpointNodes

        public void addBreakpointNodes​(java.util.List<ISrcStatement> res,
                                       ISrcStatement srcStatement)
        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
        Overrides:
        addBreakpointNodes in class IdentifierExpression
      • applyPartialValue

        public boolean applyPartialValue​(java.lang.Object value)
        Description copied from class: JavaSemanticNode
        When Parser.enablePartialValues is set, and we do not complete parsing the input we'll have a set of errors which represent model fragments. In some cases, it would be nice to put the model together as well as possible for code hinting. This method can append fragments onto it... if so return true.
        Overrides:
        applyPartialValue in class IdentifierExpression
      • addNodeCompletions

        public java.lang.String addNodeCompletions​(JavaModel origModel,
                                                   JavaSemanticNode origNode,
                                                   java.lang.String extMatchPrefix,
                                                   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 IdentifierExpression