Class BasicRefactoringTool
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.AbstractRefactoringTool
org.eclipse.persistence.jpa.jpql.tools.BasicRefactoringTool
- Direct Known Subclasses:
DefaultBasicRefactoringTool
,EclipseLinkBasicRefactoringTool
The abstract implementation providing refactoring support for JPQL queries. This version does not
change the
query
but
rather gather the changes in RefactoringDelta
and it is the responsibility of the invoker
to the actual change.
Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
- Since:
- 2.4
- Version:
- 2.6
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
The abstract class that all refactoring classes should extend, it automatically provides the MultiTextEdit that will hold theTextEdit
objects that are related to the same refactoring event.protected class
This visitor renames any segment of a path expression.protected class
This visitor renames a fully qualified class name.protected class
This visitor renames an entity name.protected class
This visitor renames an enum constant.protected static class
A simple implementation ofIQuery
.protected class
This visitor renames all the result variables found in the JPQL query.protected class
This visitor renames all the identification variables found in the JPQL query. -
Constructor Summary
ModifierConstructorDescriptionprotected
BasicRefactoringTool
(CharSequence jpqlQuery, JPQLGrammar jpqlGrammar, IManagedTypeProvider managedTypeProvider) Creates a newBasicRefactoringTool
.protected
BasicRefactoringTool
(CharSequence jpqlFragment, JPQLGrammar jpqlGrammar, IManagedTypeProvider managedTypeProvider, String jpqlQueryBNFId) Creates a newBasicRefactoringTool
. -
Method Summary
Modifier and TypeMethodDescriptionbuildAttributeNameRenamer
(String typeName, String oldAttributeName, String newAttributeName) Creates the visitor that will traverse the representation of the JPQL query and will rename a type's attribute name.protected BasicRefactoringTool.ClassNameRenamer
buildClassNameRenamer
(String oldClassName, String newClassName) Creates the visitor that will traverse the representation of the JPQL query and will rename the fully qualified class name.protected BasicRefactoringTool.EntityNameRenamer
buildEntityNameRenamer
(String oldEntityName, String newEntityName) Creates the visitor that will traverse the representation of the JPQL query and will rename the entity name.protected BasicRefactoringTool.EnumConstantRenamer
buildEnumConstantRenamer
(String oldClassName, String newClassName) Creates the visitor that will traverse the representation of the JPQL query and will rename the enum constant.protected abstract JPQLQueryContext
Creates a newJPQLQueryContext
that can retrieve information from the declaration portion of the JPQL query.buildResultVariableNameRenamer
(String oldVariableName, String newVariableName) Creates the visitor that will traverse the representation of the JPQL query and will rename a result variable.protected BasicRefactoringTool.VariableNameRenamer
buildVariableNameRenamer
(String oldVariableName, String newVariableName) Creates the visitor that will traverse the representation of the JPQL query and will rename an identification variable.getDelta()
Returns the delta of the changes made to the JPQL query.Returns the parsed tree representation of the JPQL query.Returns theJPQLGrammar
that is associated with this builder.Returns theJPQLQueryContext
that is used by this visitor.boolean
Determines whether some refactoring operations found changes to be made in the JPQL query.void
renameAttribute
(Class<?> type, String oldAttributeName, String newAttributeName) Renames the attribute (persistent field or persistent property) from the given type.void
renameAttribute
(String typeName, String oldAttributeName, String newAttributeName) Renames the attribute (persistent field or persistent property) from the given type.void
renameAttribute
(IType type, String oldAttributeName, String newAttributeName) Renames the attribute (persistent field or persistent property) from the given type.void
renameClassName
(String oldClassName, String newClassName) Renames a fully qualified class name.void
renameEntityName
(String oldEntityName, String newEntityName) Renames a given entity name.void
renameEnumConstant
(String oldEnumConstant, String newEnumConstant) Renames an enum constant, which has to be fully qualified.void
renameResultVariable
(String oldVariableName, String newVariableName) Renames a result variable name.void
renameVariable
(String oldVariableName, String newVariableName) Renames a variable name.Returns the resulted of the refactoring operations.Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.AbstractRefactoringTool
getJPQLFragment, getJPQLQueryBNFId, getManagedTypeProvider, isTolerant, setTolerant
-
Constructor Details
-
BasicRefactoringTool
protected BasicRefactoringTool(CharSequence jpqlQuery, JPQLGrammar jpqlGrammar, IManagedTypeProvider managedTypeProvider) Creates a newBasicRefactoringTool
.- Parameters:
jpqlQuery
- The JPQL query to manipulatejpqlGrammar
- TheJPQLGrammar
that was used to parse the JPQL querymanagedTypeProvider
- The external form of a provider that gives access to the JPA metadata
-
BasicRefactoringTool
protected BasicRefactoringTool(CharSequence jpqlFragment, JPQLGrammar jpqlGrammar, IManagedTypeProvider managedTypeProvider, String jpqlQueryBNFId) Creates a newBasicRefactoringTool
.- Parameters:
jpqlFragment
- The JPQL query to manipulate or a single JPQL fragment, which is parsed using the JPQL query BNF identifier by the given IDjpqlGrammar
- TheJPQLGrammar
that was used to parse the JPQL fragmentmanagedTypeProvider
- The external form of a provider that gives access to the JPA metadatajpqlQueryBNFId
- The unique identifier of theJPQLQueryBNF
that determines how to parse the JPQL fragment
-
-
Method Details
-
buildAttributeNameRenamer
protected BasicRefactoringTool.AttributeNameRenamer buildAttributeNameRenamer(String typeName, String oldAttributeName, String newAttributeName) Creates the visitor that will traverse the representation of the JPQL query and will rename a type's attribute name.- Parameters:
typeName
- The fully qualified name of the type that got one of its attributes renamedoldAttributeName
- The current name of the attribute to renamenewAttributeName
- The new name of the attribute- Returns:
- A new
BasicRefactoringTool.AttributeNameRenamer
-
buildClassNameRenamer
protected BasicRefactoringTool.ClassNameRenamer buildClassNameRenamer(String oldClassName, String newClassName) Creates the visitor that will traverse the representation of the JPQL query and will rename the fully qualified class name.- Parameters:
oldClassName
- The current name of the class to renamenewClassName
- The new name of the class- Returns:
- A new
BasicRefactoringTool.ClassNameRenamer
-
buildEntityNameRenamer
protected BasicRefactoringTool.EntityNameRenamer buildEntityNameRenamer(String oldEntityName, String newEntityName) Creates the visitor that will traverse the representation of the JPQL query and will rename the entity name.- Parameters:
oldEntityName
- The current name of the entity to renamenewEntityName
- The new name of the entity- Returns:
- A new
BasicRefactoringTool.EntityNameRenamer
-
buildEnumConstantRenamer
protected BasicRefactoringTool.EnumConstantRenamer buildEnumConstantRenamer(String oldClassName, String newClassName) Creates the visitor that will traverse the representation of the JPQL query and will rename the enum constant.- Parameters:
oldClassName
- The new name of the enum constantnewClassName
- The current name of the enum constant to rename- Returns:
- A new
BasicRefactoringTool.EnumConstantRenamer
-
buildJPQLQueryContext
Creates a newJPQLQueryContext
that can retrieve information from the declaration portion of the JPQL query.- Returns:
- A new concrete instance of
JPQLQueryContext
-
buildResultVariableNameRenamer
protected BasicRefactoringTool.ResultVariableNameRenamer buildResultVariableNameRenamer(String oldVariableName, String newVariableName) Creates the visitor that will traverse the representation of the JPQL query and will rename a result variable.- Parameters:
oldVariableName
- The current result variable namenewVariableName
- The new name of the result variable- Returns:
- A new
BasicRefactoringTool.ResultVariableNameRenamer
-
buildVariableNameRenamer
protected BasicRefactoringTool.VariableNameRenamer buildVariableNameRenamer(String oldVariableName, String newVariableName) Creates the visitor that will traverse the representation of the JPQL query and will rename an identification variable.- Parameters:
oldVariableName
- The current identification variable namenewVariableName
- The new name of the identification variable- Returns:
- A new
BasicRefactoringTool.VariableNameRenamer
-
getDelta
Returns the delta of the changes made to the JPQL query.- Returns:
- An object containing the refactoring events
-
getExpression
Returns the parsed tree representation of the JPQL query.- Returns:
- The root of the parsed tree
-
getGrammar
Returns theJPQLGrammar
that is associated with this builder.- Returns:
- The
JPQLGrammar
that was used to parse the JPQL query or JPQL fragments
-
getQueryContext
Returns theJPQLQueryContext
that is used by this visitor.- Returns:
- The
JPQLQueryContext
holding onto the JPQL query and the cached information
-
hasChanges
public boolean hasChanges()Determines whether some refactoring operations found changes to be made in the JPQL query.- Returns:
true
if there is at least oneTextEdit
;false
otherwise
-
renameAttribute
Renames the attribute (persistent field or persistent property) from the given type.- Parameters:
type
- The Java class from which the change originateoldAttributeName
- The current name of the attribute to renamenewAttributeName
- The new name of the attribute
-
renameAttribute
Renames the attribute (persistent field or persistent property) from the given type.- Parameters:
type
- TheIType
from which the change originateoldAttributeName
- The current name of the attribute to renamenewAttributeName
- The new name of the attribute
-
renameAttribute
Renames the attribute (persistent field or persistent property) from the given type.- Parameters:
typeName
- The fully qualified name of the type that got one of its attributes renamedoldAttributeName
- The current name of the attribute to renamenewAttributeName
- The new name of the attribute
-
renameClassName
Renames a fully qualified class name.- Parameters:
oldClassName
- The current fully qualified class name of the class to renamenewClassName
- The new fully qualified class name
-
renameEntityName
Renames a given entity name.- Parameters:
oldEntityName
- The current name of the entity to renamenewEntityName
- The new name of the entity
-
renameEnumConstant
Renames an enum constant, which has to be fully qualified.- Parameters:
oldEnumConstant
- The current fully qualified name of the enum constant to renamenewEnumConstant
- The new fully qualified name of the enum constant
-
renameResultVariable
Renames a result variable name.- Parameters:
oldVariableName
- The current identification variable namenewVariableName
- The new name of the identification variable
-
renameVariable
Renames a variable name.- Parameters:
oldVariableName
- The current identification variable namenewVariableName
- The new name of the identification variable
-
toActualText
Description copied from class:AbstractRefactoringTool
Returns the resulted of the refactoring operations. The list of changes will be removed after applying the changes.- Specified by:
toActualText
in classAbstractRefactoringTool
- Returns:
- The string representation of the JPQL query that contains the changes
-