summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-10-25 11:57:24 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-10-25 11:57:24 -0500
commit91a1ce47d6cf2a0161546fec7268cc42fece89c5 (patch)
tree24749677e08541aefbec386728ada0d3fd706417 /src
parenta90c94ab2281737c038bcdca873c6f07239eee59 (diff)
parent9cf8603e9494420ebd1a48bea33b31d4979525d7 (diff)
downloadflake8-91a1ce47d6cf2a0161546fec7268cc42fece89c5.tar.gz
Merge branch 'file-tokens' of xzise/flake8
Diffstat (limited to 'src')
-rw-r--r--src/flake8/processor.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/flake8/processor.py b/src/flake8/processor.py
index 44024e5..0e8c153 100644
--- a/src/flake8/processor.py
+++ b/src/flake8/processor.py
@@ -42,6 +42,7 @@ class FileProcessor(object):
- :attr:`previous_indent_level`
- :attr:`previous_logical`
- :attr:`tokens`
+ - :attr:`file_tokens`
- :attr:`total_lines`
- :attr:`verbose`
"""
@@ -98,6 +99,19 @@ class FileProcessor(object):
self.statistics = {
'logical lines': 0,
}
+ self._file_tokens = None
+
+ @property
+ def file_tokens(self):
+ if self._file_tokens is None:
+ line_iter = iter(self.lines)
+ try:
+ self._file_tokens = list(tokenize.generate_tokens(
+ lambda: next(line_iter)))
+ except tokenize.TokenError as exc:
+ raise exceptions.InvalidSyntax(exc.message, exception=exc)
+
+ return self._file_tokens[:]
@contextlib.contextmanager
def inside_multiline(self, line_number):