Package sc.lang.java

Class IdentifierExpression

    • Field Detail

      • identifiers

        public java.util.List<IString> identifiers
    • Constructor Detail

      • IdentifierExpression

        public IdentifierExpression()
    • Method Detail

      • getAllIdentifiers

        public java.util.List<IString> getAllIdentifiers()
      • setIdentifiersFromArgs

        protected void setIdentifiersFromArgs​(java.lang.String... args)
      • setAssignment

        public void setAssignment​(boolean assign)
        Description copied from class: Expression
        Only needed for expressions that are the left hand side of the equals sign
        Overrides:
        setAssignment in class Expression
      • getAssignedProperty

        public java.lang.Object getAssignedProperty()
      • getBoundType

        public java.lang.Object getBoundType​(int ix)
      • getBoundTypeNoParamType

        public java.lang.Object getBoundTypeNoParamType​(int ix)
      • makeBindable

        public static void makeBindable​(Statement expr,
                                        java.lang.String propertyName,
                                        IdentifierExpression.IdentifierType idType,
                                        java.lang.Object boundType,
                                        java.lang.Object typeForIdentifier,
                                        java.lang.Object referenceType,
                                        boolean referenceOnly,
                                        boolean checkAnnotations)
        Utility method for IdentifierExpr and SelectExpr to apply the data binding contract to a given property of the referenced object. When referenceOnly = true, this is a getX reference only - not requiring that the referred property be made bindable. This method both ensures the property is registered with it's parent type and adds a reference to that type in ReverseDependencies - reflecting the dependency from the type which needs this property bindable. When checkAnnotations is true, referenceOnly starts out false but then turns to 'true' if this property is marked as @Bindable so that we inject it during the code-gen phase (i.e. not manual bindable).
      • getReferenceType

        public java.lang.Object getReferenceType()
        Returns the type which is referring to the value of this expression
      • getParentReferenceType

        public java.lang.Object getParentReferenceType()
        Returns the type which is referring to the value of this expression
        Overrides:
        getParentReferenceType in class Expression
      • getReferencePropertyName

        public java.lang.String getReferencePropertyName()
        Description copied from class: Expression
        Only implemented for subclasses that can return needsSetMethod=true. For "a.b.c" returns "c"
        Overrides:
        getReferencePropertyName in class Expression
      • findClosestMethod

        public static java.lang.Object findClosestMethod​(java.lang.Object currentType,
                                                         java.lang.String nextName,
                                                         java.util.List<Expression> args)
        For error checking, return a method of the same name which has the fewest mismatching arguments
      • offset

        protected int offset()
      • getIdentifierPathName

        public java.lang.String getIdentifierPathName​(int ix)
      • getQualifiedClassIdentifier

        public java.lang.String getQualifiedClassIdentifier()
      • eval

        public java.lang.Object eval​(java.lang.Class expectedType,
                                     ExecutionContext ctx)
      • needsSetMethod

        public boolean needsSetMethod()
        If we are part of an assignment and our last value points to a field with a set method and we are not in the set method itself, we need to be transformed into a setX expression.
        Overrides:
        needsSetMethod in class Expression
      • needsGetMethod

        public boolean needsGetMethod​(int ix)
      • convertPropertyToSetName

        public static java.lang.String convertPropertyToSetName​(java.lang.String propertyName)
      • convertPropertyToGetName

        protected java.lang.String convertPropertyToGetName​(int ix,
                                                            java.lang.String propertyName)
      • convertToSetMethod

        public void convertToSetMethod​(Expression arg)
        Description copied from class: Expression
        Only needed for expressions that are the left hand side of the equals sign
        Overrides:
        convertToSetMethod in class Expression
      • isGetSetConversionDisabled

        public boolean isGetSetConversionDisabled​(int ix)
      • getTypeForIdentifier

        public java.lang.Object getTypeForIdentifier​(int ix)
      • getGenericTypeForIdentifier

        public java.lang.Object getGenericTypeForIdentifier​(int ix)
      • getTypeDeclaration

        public java.lang.Object getTypeDeclaration()
      • reresolveTypeReference

        public void reresolveTypeReference()
      • 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 Expression
      • evalBindingArgs

        public void evalBindingArgs​(java.util.List<java.lang.Object> bindArgs,
                                    boolean isStatic,
                                    java.lang.Class expectedType,
                                    ExecutionContext ctx)
        Overrides:
        evalBindingArgs in class Expression
      • 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 Statement
      • 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)
        Description copied from class: JavaSemanticNode
        Used to create a list of suggestions to complete this node. Returns the character offset into the parse-tree (or command string if there's no parse tree) where the completion should start. Parameters: prefix is the starting sequence of chars in the identifier to complete. All candidates returned will start with the prefix if it's provided. currentType provides a context for the current type if the node is not embedded in a model - i.e. an identifier expression on its own but known to live in a specific type If ctx is not null, it's an execution context we can use to evaluate the "root value" - i.e. in a.b the value of the variable 'a' is evaluated and the returned instance can be used to suggest candidates. This is useful in live-programming situations. The command String parameter is used to determine the offset returned for where the completion starts for the case where the parseNode tree is not available.
        Overrides:
        suggestCompletions in class JavaSemanticNode
      • 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 JavaSemanticNode
      • styleNode

        public void styleNode​(IStyleAdapter adapter)
        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 SemanticNode
      • callsSuper

        public boolean callsSuper​(boolean checkModSuper)
        Description copied from class: Statement
        Does this method call "super(xxx)" for a constructor definition
        Overrides:
        callsSuper in class Statement
      • callsSuperMethod

        public boolean callsSuperMethod​(java.lang.String methName)
        Description copied from class: Statement
        Does this method call super.methName()
        Overrides:
        callsSuperMethod in class Statement
      • 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 ArgumentsExpression
      • removeIdentifier

        public void removeIdentifier​(int ix)
      • deepCopy

        public IdentifierExpression 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 Expression
      • changeToRHS

        public void changeToRHS()
        Description copied from class: Expression
        Called when we are moving an expression from the left to the right hand side.
        Overrides:
        changeToRHS in class Expression
      • isDeclaredConstant

        public boolean isDeclaredConstant()
        Description copied from class: Expression
        This is like isConstant but does not "start" anything so you can use it during initialization
        Overrides:
        isDeclaredConstant in class Expression
      • argsToGenerateString

        protected static java.lang.String argsToGenerateString​(SemanticNodeList<Expression> args,
                                                               int nestingDepth)
      • generateIdentString

        public void generateIdentString​(java.lang.StringBuilder sb,
                                        int ix)
      • getNodeContainsPart

        public boolean getNodeContainsPart​(ISrcStatement fromSt)
        Description copied from class: Statement
        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
        Overrides:
        getNodeContainsPart in class Statement
      • 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 Statement
      • needsEnclosingClass

        public boolean needsEnclosingClass()
        Description copied from class: Statement
        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)
        Overrides:
        needsEnclosingClass in class Statement
      • 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 Expression
      • execForRuntime

        public Statement.RuntimeStatus execForRuntime​(LayeredSystem runtimeSys)
        Description copied from class: Statement
        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.
        Overrides:
        execForRuntime in class Statement