Package sc.lang.java
Class JavaSemanticNode
- java.lang.Object
-
- sc.lang.SemanticNode
-
- sc.lang.java.JavaSemanticNode
-
- All Implemented Interfaces:
ISemanticNode
,ILifecycle
- Direct Known Subclasses:
AbstractComment
,AbstractErrorNode
,AttrExpr
,BaseOperand
,Definition
,ErrorSemanticNode
,HTMLComment
,JavaModel
,JavaType
,Node
,Package
,Selector
,TypeParameter
public abstract class JavaSemanticNode extends SemanticNode
This is the basic class for all major Java program elements, types, statements, expressions, etc. They are organized into a tree so this method abstracts many of the tree-based "find" operations and core node information. TODO: As we add more languages it may make sense to split out LanguageNode and LanguageModel base classes from JavaSemanticNode and JavaModel to hold features that are shared between Java and the rest of the major languages without picking up features that are definitely specific to Java.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JavaSemanticNode.DepTypeCtx
Mode parameter for addDependentTypes family of methodsstatic class
JavaSemanticNode.DepTypeMode
class
JavaSemanticNode.MemberCache
static class
JavaSemanticNode.MemberType
-
Field Summary
Fields Modifier and Type Field Description static boolean
debugDisablePrettyToString
When debugging problems in toLanguageString - i.e.static java.lang.String
STOP_SEARCHING_SENTINEL
Return from findMemberInBody when an Object has been found-
Fields inherited from class sc.lang.SemanticNode
debugDiffTrace, initialized, PARENT_NODE_PROPERTY, parentNode, PARSE_NODE_PROPERTY, parseletId, parseNode, parseNodeInvalid, processed, started, transformed, validated
-
Fields inherited from interface sc.lang.ISemanticNode
CopyAll, CopyIndependent, CopyInitLevels, CopyNormal, CopyParseNode, CopyReplace, CopyState, CopyTransformed, SkipParseNode
-
-
Constructor Summary
Constructors Constructor Description JavaSemanticNode()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addDependentType(java.util.Set<java.lang.Object> types, java.lang.Object type, JavaSemanticNode.DepTypeCtx ctx)
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)
This works like suggestCompletions but designed to conform to the requirements of IntelliJ.boolean
applyPartialValue(java.lang.Object value)
When Parser.enablePartialValues is set, and we do not complete parsing the input we'll have a set of errors which represent model fragments.boolean
canInsertStatementBefore(Expression fromExpr)
java.lang.Object
declaresConstructor(java.util.List<?> parametersOrExpressions, ITypeParamContext ctx)
java.lang.Object
definesConstructor(java.util.List<?> parametersOrExpressions, ITypeParamContext ctx, boolean isTransformed)
java.lang.Object
definesMember(java.lang.String name, java.util.EnumSet<JavaSemanticNode.MemberType> type, java.lang.Object refType, TypeContext ctx, boolean skipIfaces, boolean isTransformed)
java.lang.Object
definesMethod(java.lang.String name, java.util.List<?> parametersOrExpressions, ITypeParamContext ctx, java.lang.Object refType, boolean isTransformed, boolean staticOnly, java.lang.Object inferredType, java.util.List<JavaType> methodTypeArgs)
java.lang.Object
definesType(java.lang.String name, TypeContext ctx)
void
detectCycles()
Called to kick off the cycle detection for this nodevoid
displayError(java.lang.String... args)
Used for errors that should always be displayedvoid
displayFormattedError(java.lang.String err)
boolean
displayTypeError(java.lang.String... args)
Used for errors involving type resolution.void
displayVerboseWarning(java.lang.String... args)
void
displayWarning(java.lang.String... args)
java.lang.Object
findMember(java.lang.String name, java.util.EnumSet<JavaSemanticNode.MemberType> type, java.lang.Object fromChild, java.lang.Object refType, TypeContext ctx, boolean skipIfaces)
java.lang.Object
findMemberOwner(java.lang.String name, java.util.EnumSet<JavaSemanticNode.MemberType> type)
java.lang.Object
findMethod(java.lang.String name, java.util.List<? extends java.lang.Object> parametersOrExpressions, java.lang.Object fromChild, java.lang.Object refType, boolean staticOnly, java.lang.Object inferredType)
Statement
findStatement(Statement in)
java.lang.Object
findType(java.lang.String name)
java.lang.Object
findType(java.lang.String name, java.lang.Object refType, TypeContext context)
java.lang.String
getDependencyDisabledText()
Returns null or the text describing a dependency which is disabled to augment the error - e.g.IBlockStatement
getEnclosingBlockStatement()
Will retrieve the node which holds the list of statements, for searching for variables, etc.IMethodDefinition
getEnclosingIMethod()
ITypeDeclaration
getEnclosingIType()
Used by the JavaType classes which may be parented by something other than a JavaModelAbstractMethodDefinition
getEnclosingMethod()
AbstractMethodDefinition
getEnclosingMethod(boolean initLambda)
Statement
getEnclosingStatement()
Element
getEnclosingTag()
Template
getEnclosingTemplate()
TypeDeclaration
getEnclosingType()
int
getExecMode()
Elements of Template objects (tags) can either run on the client or on the server or both based on this flag.java.lang.String
getImportedTypeName(java.lang.String typeName)
JavaLanguage
getJavaLanguage()
JavaModel
getJavaModel()
LayeredSystem
getLayeredSystem()
protected java.lang.String
getMessageString(java.lang.String... args)
Element
getRootTag()
TypeDeclaration
getRootType()
BodyTypeDeclaration
getStructuralEnclosingType()
Like the regular getEnclosingType but does not try to initialize an anonymous type from a new expressionboolean
isCollapsibleNode()
Return true for nodes like simple ClassType expressions "a.b.c" which can collapse into a simpler node type in the IDE.boolean
isDynamicType()
boolean
isReferenceValueObject()
boolean
isStatic()
boolean
needsDataBinding()
JavaSemanticNode
refreshNode()
Needs to be implemented for IDE support on nodes which can be referenced outside of the same file.void
runtimeError(java.lang.Class<? extends java.lang.RuntimeException> excClass, java.lang.String... args)
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)
Used to create a list of suggestions to complete this node.java.lang.String
toFileString()
java.lang.String
toGenerateString()
int
transformTemplate(int ix, boolean statefulContext)
A pass over the semantic node tree to convert template statements into layer cake statements.void
visitTypeReferences(CycleInfo cycle, TypeContext ctx)
overridden by nodes to visit values in the reference chain-
Methods inherited from class sc.lang.SemanticNode
changeLanguage, clearInitialized, clearParseNode, clearStarted, computeNearString, containsChild, deepCopy, deepEquals, diffNode, ensureValidated, equals, formatLeftParenDelegateToParent, formatSpaceBeforeAngleBracket, getAnyChildParseNode, getChildAtIndex, getChildNestingDepth, getEnclosingSrcStatement, getLanguageModel, getNestingDepth, getNodeCount, getNodeErrorRange, getNodeErrorText, getNodeWarningText, getNotFoundError, getParentNode, getParseErrorNode, getParseletId, getParseNode, getRootNode, getStartIndex, getStopSemanticProps, getTransformed, getUserVisibleName, hasErrors, hashCode, indexOfChild, init, isInitialized, isParseNodeValid, isProcessed, isSemanticChildValue, isSemanticProperty, isSemanticProperty, isStarted, isTrailingSrcStatement, isValidated, needsTransform, process, regenerate, regenerateIfTracking, removeChild, replaceChild, restoreParseNode, restoreParseNode, sameSrcLocation, serialize, setParentNode, setParseErrorNode, setParselet, setParseletId, setParseNode, setParseNodeValid, setProperty, setProperty, spaceAfterParen, start, stop, styleNode, styleNode, toDeclarationString, toDefinitionString, toDefinitionString, toDefinitionString, toHeaderString, toLanguageString, toLanguageString, toLocationString, toLocationString, toLocationString, toModelString, toModelString, toSafeLanguageString, transform, validate, validateParseNode
-
-
-
-
Field Detail
-
debugDisablePrettyToString
public static boolean debugDisablePrettyToString
When debugging problems in toLanguageString - i.e. generating a language description from a changed model, set this to true to prevent the debugger from generating the thing during it's variable display
-
STOP_SEARCHING_SENTINEL
public static final java.lang.String STOP_SEARCHING_SENTINEL
Return from findMemberInBody when an Object has been found- See Also:
- Constant Field Values
-
-
Method Detail
-
getJavaModel
public JavaModel getJavaModel()
-
getLayeredSystem
public LayeredSystem getLayeredSystem()
-
findMethod
public java.lang.Object findMethod(java.lang.String name, java.util.List<? extends java.lang.Object> parametersOrExpressions, java.lang.Object fromChild, java.lang.Object refType, boolean staticOnly, java.lang.Object inferredType)
-
definesMethod
public java.lang.Object definesMethod(java.lang.String name, java.util.List<?> parametersOrExpressions, ITypeParamContext ctx, java.lang.Object refType, boolean isTransformed, boolean staticOnly, java.lang.Object inferredType, java.util.List<JavaType> methodTypeArgs)
-
definesConstructor
public java.lang.Object definesConstructor(java.util.List<?> parametersOrExpressions, ITypeParamContext ctx, boolean isTransformed)
-
declaresConstructor
public java.lang.Object declaresConstructor(java.util.List<?> parametersOrExpressions, ITypeParamContext ctx)
-
findMember
public java.lang.Object findMember(java.lang.String name, java.util.EnumSet<JavaSemanticNode.MemberType> type, java.lang.Object fromChild, java.lang.Object refType, TypeContext ctx, boolean skipIfaces)
-
findMemberOwner
public java.lang.Object findMemberOwner(java.lang.String name, java.util.EnumSet<JavaSemanticNode.MemberType> type)
-
definesMember
public java.lang.Object definesMember(java.lang.String name, java.util.EnumSet<JavaSemanticNode.MemberType> type, java.lang.Object refType, TypeContext ctx, boolean skipIfaces, boolean isTransformed)
-
findType
public java.lang.Object findType(java.lang.String name)
-
findType
public java.lang.Object findType(java.lang.String name, java.lang.Object refType, TypeContext context)
-
definesType
public java.lang.Object definesType(java.lang.String name, TypeContext ctx)
-
getRootType
public TypeDeclaration getRootType()
-
getEnclosingIType
public ITypeDeclaration getEnclosingIType()
Used by the JavaType classes which may be parented by something other than a JavaModel
-
getStructuralEnclosingType
public BodyTypeDeclaration getStructuralEnclosingType()
Like the regular getEnclosingType but does not try to initialize an anonymous type from a new expression
-
getEnclosingType
public TypeDeclaration getEnclosingType()
-
getEnclosingBlockStatement
public IBlockStatement getEnclosingBlockStatement()
Will retrieve the node which holds the list of statements, for searching for variables, etc.
-
getEnclosingStatement
public Statement getEnclosingStatement()
-
getEnclosingMethod
public AbstractMethodDefinition getEnclosingMethod(boolean initLambda)
-
getEnclosingMethod
public AbstractMethodDefinition getEnclosingMethod()
-
getEnclosingIMethod
public IMethodDefinition getEnclosingIMethod()
-
displayTypeError
public boolean displayTypeError(java.lang.String... args)
Used for errors involving type resolution. These errors can be disabled during certain operations like transform
-
getMessageString
protected java.lang.String getMessageString(java.lang.String... args)
-
runtimeError
public void runtimeError(java.lang.Class<? extends java.lang.RuntimeException> excClass, java.lang.String... args)
-
displayError
public void displayError(java.lang.String... args)
Used for errors that should always be displayed
-
displayWarning
public void displayWarning(java.lang.String... args)
-
displayVerboseWarning
public void displayVerboseWarning(java.lang.String... args)
-
displayFormattedError
public void displayFormattedError(java.lang.String err)
-
toFileString
public java.lang.String toFileString()
-
isStatic
public boolean isStatic()
-
canInsertStatementBefore
public boolean canInsertStatementBefore(Expression fromExpr)
-
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)
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.
-
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)
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).
-
applyPartialValue
public boolean applyPartialValue(java.lang.Object value)
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.
-
visitTypeReferences
public void visitTypeReferences(CycleInfo cycle, TypeContext ctx)
overridden by nodes to visit values in the reference chain
-
detectCycles
public void detectCycles()
Called to kick off the cycle detection for this node
-
isReferenceValueObject
public boolean isReferenceValueObject()
-
isDynamicType
public boolean isDynamicType()
-
needsDataBinding
public boolean needsDataBinding()
-
transformTemplate
public int transformTemplate(int ix, boolean statefulContext)
A pass over the semantic node tree to convert template statements into layer cake statements.
-
getEnclosingTag
public Element getEnclosingTag()
-
getRootTag
public Element getRootTag()
-
getEnclosingTemplate
public Template getEnclosingTemplate()
-
getExecMode
public int getExecMode()
Elements of Template objects (tags) can either run on the client or on the server or both based on this flag. Right now, it's set at the Template level since those are the only types which support mixed client/server mode.
-
toGenerateString
public java.lang.String toGenerateString()
-
getJavaLanguage
public JavaLanguage getJavaLanguage()
-
isCollapsibleNode
public boolean isCollapsibleNode()
Return true for nodes like simple ClassType expressions "a.b.c" which can collapse into a simpler node type in the IDE.
-
refreshNode
public JavaSemanticNode refreshNode()
Needs to be implemented for IDE support on nodes which can be referenced outside of the same file. If the model in which this references lives has been removed (or really replaced by another version of the same model), we need to find the node in the other model that corresponds to this node and return it.- Specified by:
refreshNode
in interfaceISemanticNode
- Overrides:
refreshNode
in classSemanticNode
-
getDependencyDisabledText
public java.lang.String getDependencyDisabledText()
Description copied from interface:ISemanticNode
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.- Specified by:
getDependencyDisabledText
in interfaceISemanticNode
- Overrides:
getDependencyDisabledText
in classSemanticNode
-
addDependentType
public static void addDependentType(java.util.Set<java.lang.Object> types, java.lang.Object type, JavaSemanticNode.DepTypeCtx ctx)
-
getImportedTypeName
public java.lang.String getImportedTypeName(java.lang.String typeName)
-
-