Class NameLogic
- java.lang.Object
-
- com.github.javaparser.symbolsolver.resolution.naming.NameLogic
-
public class NameLogic extends java.lang.Object
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 Classes Modifier and Type Class Description private static interface
NameLogic.PredicateOnParentAndChild<P extends Node,C extends Node>
-
Constructor Summary
Constructors Constructor Description NameLogic()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NameCategory
classifyReference(Node name, TypeSolver typeSolver)
static NameRole
classifyRole(Node name)
What is the Role of the given name? Does it represent a Declaration or a Reference?private static Node
getQualifier(Node node)
private static Node
getRightMostName(Node node)
static boolean
isAName(Node node)
Does the Node represent a Name?static boolean
isQualifiedName(Node node)
Is the given node a qualified name?static boolean
isSimpleName(Node node)
Is the given node a non-qualified name?private static boolean
isSyntacticallyAAmbiguousName(Node name)
private static boolean
isSyntacticallyAMethodName(Node name)
private static boolean
isSyntacticallyAModuleName(Node name)
private static boolean
isSyntacticallyAnExpressionName(Node name)
private static boolean
isSyntacticallyAPackageName(Node name)
private static boolean
isSyntacticallyAPackageOrTypeName(Node name)
private static boolean
isSyntacticallyATypeName(Node name)
static java.lang.String
nameAsString(Node name)
Return the string representation of the nameprivate static NameCategory
reclassificationOfContextuallyAmbiguousNames(Node name, NameCategory ambiguousCategory, TypeSolver typeSolver)
JLS 6.5.2.private static NameCategory
reclassificationOfContextuallyAmbiguousPackageOrTypeName(Node name, TypeSolver typeSolver)
private static NameCategory
reclassificationOfContextuallyAmbiguousQualifiedAmbiguousName(Node nameNode, TypeSolver typeSolver)
private static NameCategory
reclassificationOfContextuallyAmbiguousSimpleAmbiguousName(Node nameNode, TypeSolver typeSolver)
static NameCategory
syntacticClassificationAccordingToContext(Node name)
See JLS 6.5.1 Syntactic Classification of a Name According to Context.private static <P extends Node,C extends Node>
booleanwhenParentIs(java.lang.Class<P> parentClass, C child)
private static <P extends Node,C extends Node>
booleanwhenParentIs(java.lang.Class<P> parentClass, C child, NameLogic.PredicateOnParentAndChild<P,C> predicate)
-
-
-
Method Detail
-
isSimpleName
public static boolean isSimpleName(Node node)
Is the given node a non-qualified name?- Throws:
java.lang.IllegalArgumentException
- if the node is not a name
-
isQualifiedName
public static boolean isQualifiedName(Node node)
Is the given node a qualified name?- Throws:
java.lang.IllegalArgumentException
- if the node is not a name
-
isAName
public static boolean isAName(Node node)
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
-
classifyRole
public static NameRole classifyRole(Node name)
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
public static NameCategory classifyReference(Node name, TypeSolver typeSolver)
-
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
public static NameCategory syntacticClassificationAccordingToContext(Node name)
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
private static boolean isSyntacticallyAAmbiguousName(Node name)
-
isSyntacticallyAPackageOrTypeName
private static boolean isSyntacticallyAPackageOrTypeName(Node name)
-
isSyntacticallyAMethodName
private static boolean isSyntacticallyAMethodName(Node name)
-
isSyntacticallyAModuleName
private static boolean isSyntacticallyAModuleName(Node name)
-
isSyntacticallyAPackageName
private static boolean isSyntacticallyAPackageName(Node name)
-
isSyntacticallyATypeName
private static boolean isSyntacticallyATypeName(Node name)
-
isSyntacticallyAnExpressionName
private static boolean isSyntacticallyAnExpressionName(Node name)
-
nameAsString
public static java.lang.String nameAsString(Node name)
Return the string representation of the name
-
whenParentIs
private static <P extends Node,C extends Node> boolean whenParentIs(java.lang.Class<P> parentClass, C child)
-
whenParentIs
private static <P extends Node,C extends Node> boolean whenParentIs(java.lang.Class<P> parentClass, C child, NameLogic.PredicateOnParentAndChild<P,C> predicate)
-
-