src/eric7/DataViews/CodeMetrics.py

branch
eric7
changeset 9500
5771348ded12
parent 9473
3f23dbf37dbe
child 9653
e67609152c5e
equal deleted inserted replaced
9499:dd389c57c2f0 9500:5771348ded12
18 import io 18 import io
19 import keyword 19 import keyword
20 import os 20 import os
21 import token 21 import token
22 import tokenize 22 import tokenize
23
24 from dataclasses import dataclass
23 25
24 from eric7 import Utilities 26 from eric7 import Utilities
25 27
26 KEYWORD = token.NT_OFFSET + 1 28 KEYWORD = token.NT_OFFSET + 1
27 COMMENT = tokenize.COMMENT 29 COMMENT = tokenize.COMMENT
29 DEDENT = token.DEDENT 31 DEDENT = token.DEDENT
30 NEWLINE = token.NEWLINE 32 NEWLINE = token.NEWLINE
31 EMPTY = tokenize.NL 33 EMPTY = tokenize.NL
32 34
33 35
36 @dataclass
34 class Token: 37 class Token:
35 """ 38 """
36 Class to store the token related infos. 39 Class to store the token related info.
37 """ 40 """
38 41
39 def __init__(self, **kw): 42 type: int
40 """ 43 text: str
41 Constructor 44 row: int
42 45 col: int
43 @keyparam **kw list of key, value pairs 46 line: str
44 """
45 self.__dict__.update(kw)
46 47
47 48
48 class Parser: 49 class Parser:
49 """ 50 """
50 Class used to parse the source code of a Python file. 51 Class used to parse the source code of a Python file.
155 Public method used to store an identifier. 156 Public method used to store an identifier.
156 157
157 @param identifier the identifier to be remembered (string) 158 @param identifier the identifier to be remembered (string)
158 @param row the row, the identifier is defined in (int) 159 @param row the row, the identifier is defined in (int)
159 """ 160 """
160 if len(self.active) > 1 and self.indent_level > self.active[-1][1]: 161 qualified = (
161 # __IGNORE_WARNING_Y108__ 162 self.active[-1][0] + "." + identifier
162 qualified = self.active[-1][0] + "." + identifier 163 if len(self.active) > 1 and self.indent_level > self.active[-1][1]
163 else: 164 else identifier
164 qualified = identifier 165 )
165 self.active.append((qualified, self.indent_level, row)) 166 self.active.append((qualified, self.indent_level, row))
166 self.identifiers.append(qualified) 167 self.identifiers.append(qualified)
167 168
168 def inc(self, key, value=1): 169 def inc(self, key, value=1):
169 """ 170 """

eric ide

mercurial