Esempio n. 1
0
    def __init__(self,
                 file=None,
                 index=None,
                 language=None,
                 start: NlSectionPosition,
                 end: (NlSectionPosition, None) = None,
                 temp_file=None):
        """
        Creates a new NlSection.

        :param start:       A NlSectionPosition indicating the start of the 
                            section in original file.
        :param end:         A NlSectionPosition indicating the end of the 
                            section in the original file.
                            If ``None`` is given, the start object will be used
                            here. end must be in the same file and be greater
                            than start as negative ranges are not allowed.
        :param language:    The programming language of the lines.
        :param index:       The index of the nl_section.
        :param file:        The name of the original file
        :param temp_file:   The name of the temporary segregated file 
        :raises TypeError:  Raised when
                            - start is not of type NlSectionPosition.
                            - end is neither of type NlSectionPosition, nor 
                              is it None.
        :raises ValueError: Raised when file of start and end mismatch.
        """
        TextRange.__init__(self, start, end)
        self.index = index
        self.language = language
        self.file = file
        """
        :linted_start: The start of the section in the linted file.Initially it 
                       is same as that of the start of the original file. It 
                       changes only when any patches are applied on that line.
        :linted_end:   The end of the section in the linted file.Initially it 
                       is same as that of the end of the original file. It 
                       changes only when any patches are applied on that line.
        """
        self.linted_start = NlSectionPosition(file, start.line, start.column)
        if end:
            self.linted_end = NlSectionPosition(file, end.line, end.column)
        else:
            end = None

        if self.start.file != self.end.file:
            raise ValueError('File of start and end position do not match.')
Esempio n. 2
0
    def __init__(self, start: SourcePosition, end: (SourcePosition, None) = None):
        """
        Creates a new SourceRange.

        :param start:       A SourcePosition indicating the start of the range.
        :param end:         A SourcePosition indicating the end of the range.
                            If ``None`` is given, the start object will be used
                            here. end must be in the same file and be greater
                            than start as negative ranges are not allowed.
        :raises TypeError:  Raised when
                            - start is not of type SourcePosition.
                            - end is neither of type SourcePosition, nor is it
                              None.
        :raises ValueError: Raised when file of start and end mismatch.
        """
        TextRange.__init__(self, start, end)

        if self.start.file != self.end.file:
            raise ValueError("File of start and end position do not match.")
Esempio n. 3
0
    def __init__(self,
                 start: SourcePosition,
                 end: (SourcePosition, None) = None):
        """
        Creates a new SourceRange.

        :param start:       A SourcePosition indicating the start of the range.
        :param end:         A SourcePosition indicating the end of the range.
                            If ``None`` is given, the start object will be used
                            here. end must be in the same file and be greater
                            than start as negative ranges are not allowed.
        :raises TypeError:  Raised when
                            - start is no SourcePosition or None.
                            - end is no SourcePosition.
        :raises ValueError: Raised when file of start and end mismatch.
        """
        TextRange.__init__(self, start, end)

        if self.start.file != self.end.file:
            raise ValueError("File of start and end position do not match.")