Class LocalVariableExtractValidator
- java.lang.Object
-
- com._1c.g5.v8.dt.bsl.ui.refactoring.LocalVariableExtractValidator
-
- Direct Known Subclasses:
MethodExtractValidator
public class LocalVariableExtractValidator extends Object
Validator for selected text in Bsl module before extracting local variable Instances ofLocalVariableExtractValidator
are stateful and are not safe for use by multiple threads.
-
-
Field Summary
Fields Modifier and Type Field Description protected Module
module
protected org.eclipse.xtext.nodemodel.INode
moduleNode
protected org.eclipse.jface.text.ITextSelection
selection
protected org.eclipse.xtext.nodemodel.INode
startLeafNode
-
Constructor Summary
Constructors Constructor Description LocalVariableExtractValidator(Module module, org.eclipse.jface.text.ITextSelection selection)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.eclipse.xtext.util.Pair<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject>
getBorderUnitCompilation(org.eclipse.xtext.nodemodel.INode startNode, int stopPos)
Gets grammar elements corresponding to the start and end of the selection Also collects all nodes in selection area without hidden nodes.String
getErrorMessage()
Gets validating error messageprotected String
getKeywordValue(org.eclipse.xtext.nodemodel.INode node)
Gets keyword value by correspondingINode
protected org.eclipse.xtext.nodemodel.INode
getNextNode(org.eclipse.xtext.nodemodel.INode startNode)
Gets nextINode
List<org.eclipse.xtext.nodemodel.INode>
getSelectedTreeNodes()
Gets allINode
corresponding to selectionboolean
isAllowedReplaceAllOccurrences()
Check that selected state allows use 'replace all occurrences' in refactoringprotected boolean
isLastNodePunctuation(boolean isLastNodePunctuation)
Checks that last node was punctuation nodeprotected void
setErrorMessage(String errorMessage)
Sets error validation messageprotected boolean
simpleValidate(org.eclipse.emf.ecore.EObject startUnitCompilation, org.eclipse.emf.ecore.EObject endUnitCompilation, int startPos, int stopPos)
Validate selection for extracting local variableboolean
validate()
Validate selection text in bsl module for extracting local variable
-
-
-
Field Detail
-
module
protected final Module module
-
selection
protected final org.eclipse.jface.text.ITextSelection selection
-
moduleNode
protected final org.eclipse.xtext.nodemodel.INode moduleNode
-
startLeafNode
protected final org.eclipse.xtext.nodemodel.INode startLeafNode
-
-
Method Detail
-
getErrorMessage
public String getErrorMessage()
Gets validating error message- Returns:
- validating error message if error was detected or empty string if no errors. Can't be
null
-
getSelectedTreeNodes
public List<org.eclipse.xtext.nodemodel.INode> getSelectedTreeNodes()
Gets allINode
corresponding to selection- Returns:
- list of
INode
corresponding to selection, there are no hidden nodes in this list, or empty list if errors were detected. Can't benull
-
validate
public boolean validate()
Validate selection text in bsl module for extracting local variable- Returns:
true
if all are correct,false
otherwise
-
isAllowedReplaceAllOccurrences
public boolean isAllowedReplaceAllOccurrences()
Check that selected state allows use 'replace all occurrences' in refactoring- Returns:
false
if select area corresponding to literal expression,true
otherwise
-
setErrorMessage
protected void setErrorMessage(String errorMessage)
Sets error validation message- Parameters:
errorMessage
- validation message, can't benull
-
getBorderUnitCompilation
protected org.eclipse.xtext.util.Pair<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject> getBorderUnitCompilation(org.eclipse.xtext.nodemodel.INode startNode, int stopPos)
Gets grammar elements corresponding to the start and end of the selection Also collects all nodes in selection area without hidden nodes.- Parameters:
startNode
- the first selectionINode
, can't benull
stopPos
- last selection position
-
isLastNodePunctuation
protected boolean isLastNodePunctuation(boolean isLastNodePunctuation)
Checks that last node was punctuation node- Parameters:
isLastNodePunctuation
- flag says that ingetBorderUnitCompilation(org.eclipse.xtext.nodemodel.INode, int)
last node was punctuation- Returns:
true
if last node was punctuation,false
otherwise
-
simpleValidate
protected boolean simpleValidate(org.eclipse.emf.ecore.EObject startUnitCompilation, org.eclipse.emf.ecore.EObject endUnitCompilation, int startPos, int stopPos)
Validate selection for extracting local variable- Parameters:
startUnitCompilation
- start semantic object corresponding to selection, can't benull
endUnitCompilation
- end semantic object corresponding to selection, can't benull
startPos
- start selection positionstopPos
- stop selection position- Returns:
true
if selection is valid by semantic,false
otherwise
-
getKeywordValue
protected String getKeywordValue(org.eclipse.xtext.nodemodel.INode node)
Gets keyword value by correspondingINode
- Parameters:
node
- grammar node, can't benull
- Returns:
- value of keyword or empty string, if node is not keyword node. Can't be
null
-
getNextNode
protected org.eclipse.xtext.nodemodel.INode getNextNode(org.eclipse.xtext.nodemodel.INode startNode)
Gets nextINode
- Parameters:
startNode
- current node, can't benull
- Returns:
- next
INode
, can benull
if node wasn't found
-
-