Refactored rule entity_016 to use tokens.
This commit is contained in:
parent
b2a57f4c93
commit
bed396c5f4
|
|
@ -1,12 +1,15 @@
|
|||
|
||||
from vsg.rules import remove_blank_lines_above_rule
|
||||
from vsg.rules import remove_blank_lines_above_item_rule
|
||||
|
||||
from vsg.token import entity as token
|
||||
|
||||
|
||||
class rule_016(remove_blank_lines_above_rule):
|
||||
class rule_016(remove_blank_lines_above_item_rule):
|
||||
'''
|
||||
Entity rule 016 checks for a blank line above the "end entity" keywords.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
remove_blank_lines_above_rule.__init__(self, 'entity', '016', 'isEndEntityDeclaration')
|
||||
self.solution = 'Remove blank line(s) above "end entity" keywords.'
|
||||
remove_blank_lines_above_item_rule.__init__(self, 'entity', '016', token.end_keyword, 0)
|
||||
self.regionBegin = token.end_keyword
|
||||
self.regionEnd = token.end_keyword
|
||||
|
|
|
|||
|
|
@ -197,9 +197,9 @@ class testRuleEntityMethods(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, 'entity')
|
||||
self.assertEqual(oRule.identifier, '016')
|
||||
|
||||
dExpected = utils.add_violation_list([33,146])
|
||||
lExpected = [33,146]
|
||||
oRule.analyze(oFile)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines(oRule.violations))
|
||||
|
||||
def test_rule_017(self):
|
||||
oRule = entity.rule_017()
|
||||
|
|
|
|||
|
|
@ -389,6 +389,10 @@ class vhdlFile():
|
|||
dIndent['insideContextDeclaration'] = False
|
||||
dIndent['level'] = 0
|
||||
for oLine in self.lines:
|
||||
|
||||
if len(oLine.objects) == 0:
|
||||
continue
|
||||
|
||||
if _does_line_start_with_item_or_whitespace_and_then_item(oLine, parser.context_keyword):
|
||||
oLine.indentLevel = 0
|
||||
dIndent['insideContextDeclaration'] = True
|
||||
|
|
@ -415,9 +419,6 @@ class vhdlFile():
|
|||
dIndent['level'] = 1
|
||||
oLine.indentLevel = 0
|
||||
|
||||
if len(oLine.objects) == 0:
|
||||
continue
|
||||
|
||||
if _does_line_start_with_item_or_whitespace_and_then_item(oLine, constant_declaration.assignment_expression):
|
||||
if type(oLine.objects[0]) == constant_declaration.assignment_expression:
|
||||
if oLine.objects[0].get_value() == '(':
|
||||
|
|
|
|||
Loading…
Reference in New Issue