Class NameLogic
java.lang.Object
com.github.javaparser.symbolsolver.resolution.naming.NameLogic
NameLogic contains a set of static methods to implement the abstraction of a "Name" as defined
in Chapter 6 of the JLS. This code could be moved to an interface or base class in a successive version of
JavaParser.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceNameLogic.PredicateOnParentAndChild<P extends Node, C extends Node> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic NameCategoryclassifyReference(Node name, TypeSolver typeSolver) static NameRoleclassifyRole(Node name) What is the Role of the given name? Does it represent a Declaration or a Reference?private static NodegetQualifier(Node node) private static NodegetRightMostName(Node node) static booleanDoes the Node represent a Name?static booleanisQualifiedName(Node node) Is the given node a qualified name?static booleanisSimpleName(Node node) Is the given node a non-qualified name?private static booleanprivate static booleanprivate static booleanprivate static booleanprivate static booleanprivate static booleanprivate static booleanisSyntacticallyATypeName(Node name) static StringnameAsString(Node name) Return the string representation of the nameprivate static NameCategoryreclassificationOfContextuallyAmbiguousNames(Node name, NameCategory ambiguousCategory, TypeSolver typeSolver) JLS 6.5.2.private static NameCategoryreclassificationOfContextuallyAmbiguousPackageOrTypeName(Node name, TypeSolver typeSolver) private static NameCategoryreclassificationOfContextuallyAmbiguousQualifiedAmbiguousName(Node nameNode, TypeSolver typeSolver) private static NameCategoryreclassificationOfContextuallyAmbiguousSimpleAmbiguousName(Node nameNode, TypeSolver typeSolver) static NameCategorySee JLS 6.5.1 Syntactic Classification of a Name According to Context.whenParentIs(Class<P> parentClass, C child) whenParentIs(Class<P> parentClass, C child, NameLogic.PredicateOnParentAndChild<P, C> predicate)
-
Constructor Details
-
NameLogic
public NameLogic()
-
-
Method Details
-
isSimpleName
Is the given node a non-qualified name?- Throws:
IllegalArgumentException- if the node is not a name
-
isQualifiedName
Is the given node a qualified name?- Throws:
IllegalArgumentException- if the node is not a name
-
isAName
Does the Node represent a Name?Note that while most specific AST classes either always represent names or never represent names there are exceptions as the FieldAccessExpr
-
getQualifier
-
getRightMostName
-
classifyRole
What is the Role of the given name? Does it represent a Declaration or a Reference?This classification is purely syntactical, i.e., it does not require symbol resolution. For this reason in the future this could be moved to the core module of JavaParser.
-
classifyReference
-
reclassificationOfContextuallyAmbiguousNames
private static NameCategory reclassificationOfContextuallyAmbiguousNames(Node name, NameCategory ambiguousCategory, TypeSolver typeSolver) JLS 6.5.2. Reclassification of Contextually Ambiguous Names -
reclassificationOfContextuallyAmbiguousPackageOrTypeName
private static NameCategory reclassificationOfContextuallyAmbiguousPackageOrTypeName(Node name, TypeSolver typeSolver) -
reclassificationOfContextuallyAmbiguousQualifiedAmbiguousName
private static NameCategory reclassificationOfContextuallyAmbiguousQualifiedAmbiguousName(Node nameNode, TypeSolver typeSolver) -
reclassificationOfContextuallyAmbiguousSimpleAmbiguousName
private static NameCategory reclassificationOfContextuallyAmbiguousSimpleAmbiguousName(Node nameNode, TypeSolver typeSolver) -
syntacticClassificationAccordingToContext
See JLS 6.5.1 Syntactic Classification of a Name According to Context.Most users do not want to call directly this method but call classifyReference instead.
-
isSyntacticallyAAmbiguousName
-
isSyntacticallyAPackageOrTypeName
-
isSyntacticallyAMethodName
-
isSyntacticallyAModuleName
-
isSyntacticallyAPackageName
-
isSyntacticallyATypeName
-
isSyntacticallyAnExpressionName
-
nameAsString
-
whenParentIs
-
whenParentIs
private static <P extends Node, C extends Node> boolean whenParentIs(Class<P> parentClass, C child, NameLogic.PredicateOnParentAndChild<P, C> predicate)
-