Class LocalVariableExtractValidator

    • 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  
    • 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 message
      protected String getKeywordValue​(org.eclipse.xtext.nodemodel.INode node)
      Gets keyword value by corresponding INode
      protected org.eclipse.xtext.nodemodel.INode getNextNode​(org.eclipse.xtext.nodemodel.INode startNode)
      Gets next INode
      List<org.eclipse.xtext.nodemodel.INode> getSelectedTreeNodes()
      Gets all INode corresponding to selection
      boolean isAllowedReplaceAllOccurrences()
      Check that selected state allows use 'replace all occurrences' in refactoring
      protected boolean isLastNodePunctuation​(boolean isLastNodePunctuation)
      Checks that last node was punctuation node
      protected void setErrorMessage​(String errorMessage)
      Sets error validation message
      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
      boolean 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
    • Constructor Detail

      • LocalVariableExtractValidator

        public LocalVariableExtractValidator​(Module module,
                                             org.eclipse.jface.text.ITextSelection selection)
        Constructor
        Parameters:
        module - bsl Module. Can't be null
        selection - current validating selection in bsl module. Can't be null
    • 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 all INode 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 be null
      • 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 be null
      • 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 selection INode, can't be null
        stopPos - last selection position
      • isLastNodePunctuation

        protected boolean isLastNodePunctuation​(boolean isLastNodePunctuation)
        Checks that last node was punctuation node
        Parameters:
        isLastNodePunctuation - flag says that in getBorderUnitCompilation(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 be null
        endUnitCompilation - end semantic object corresponding to selection, can't be null
        startPos - start selection position
        stopPos - 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 corresponding INode
        Parameters:
        node - grammar node, can't be null
        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 next INode
        Parameters:
        startNode - current node, can't be null
        Returns:
        next INode, can be null if node wasn't found