Class CreateMethodAndInvocationVariable

    • Constructor Detail

      • CreateMethodAndInvocationVariable

        public CreateMethodAndInvocationVariable​(org.eclipse.jface.text.IRegion region,
                                                 String name,
                                                 boolean isProcedure,
                                                 List<String> params)
        Creates new instance of this with given parameters
        Parameters:
        region - The region of the variable inside pattern, cannot be null
        name - The name of the method to create, cannot be null
        isProcedure - true if variable should create Procedure, false if should create Function
        params - The list of method parameters names, cannot be null
    • Method Detail

      • preApplyGlobal

        public IPlacementContext preApplyGlobal​(org.eclipse.xtext.ui.editor.model.XtextDocument document,
                                                int offset)
        Description copied from interface: IGlobalVariable
        Computes additional data for computing ApplyResult in method #applyGlobal(XtextDocument, IRegion) before content of the document will be changed by template pattern
        Specified by:
        preApplyGlobal in interface IGlobalVariable
        Parameters:
        document - actual document for applying ITemplate
        offset - offset of applying whole ITemplate
        Returns:
        additional data for computing ApplyResult in method #applyGlobal(XtextDocument, IRegion) before content of the document will be changed by template pattern, can be null if
      • applyGlobal

        public ApplyResult applyGlobal​(org.eclipse.xtext.ui.editor.model.XtextDocument document,
                                       org.eclipse.jface.text.IRegion variablePosition,
                                       IPlacementContext placementContext)
        Description copied from interface: IGlobalVariable
        Performs apply at any region of the document
        Specified by:
        applyGlobal in interface IGlobalVariable
        Parameters:
        document - The document to perform apply on, cannot be null
        variablePosition - The position of the variable after applying template and usual IVariable.apply(String), cannot be null
        placementContext - additional information for creating ApplyResult, computed in {@link #preApplyGlobal(XtextDocument, int), can be null if there is no additional information
        Returns:
        The result of global apply, cannot be null
      • getVariableText

        protected String getVariableText()
        Description copied from class: AbstractVariable
        Returns text of the variable for the given region
        Specified by:
        getVariableText in class AbstractVariable
        Returns:
        The text of the variable for the given region, can be null
      • setupVariableLinks

        protected Collection<LinkedGroup> setupVariableLinks​(org.eclipse.xtext.ui.editor.model.XtextDocument document,
                                                             org.eclipse.jface.text.IRegion variablePosition,
                                                             List<org.eclipse.text.edits.RangeMarker> nameGroup)
        Setups link groups for the variable text
        Parameters:
        document - The document to work on, cannot be null
        variablePosition - The position of the variable, cannot be null
        nameGroup - The list to add link group of the name to, cannot be null
        Returns:
        created LinkedGroup by template variable RangeMarker, never null
      • createMethod

        protected String createMethod​(Collection<LinkedGroup> groupsToLink,
                                      int replaceOffset,
                                      List<org.eclipse.text.edits.RangeMarker> nameGroup,
                                      String[] pragmas,
                                      boolean asynAllowed,
                                      ScriptVariant scriptVariant)
        Creates method text
        Parameters:
        groupsToLink - The groups to link to add needed linked groups, cannot be null
        replaceOffset - The replace offset for this procedure
        nameGroup - The name group to add created procedure name into, cannot be null
        Returns:
        The string representing the procedure text, cannot be null