Updates for issue #597

Fixing issue with assigning indents for lines that were not assigned indents.

  1)  Updated documentation
  2)  Updated tests
  3)  Assigning indent to lines which were not assigned indents before
This commit is contained in:
Jeremiah Leary 2021-09-18 10:07:27 -05:00
parent cfea1b4ab2
commit bec4264ac1
7 changed files with 43 additions and 1 deletions

View File

@ -69,6 +69,7 @@ comment_011
|phase_1| |disabled| |error|
This rule checks for in-line comments and moves them to the line above.
The indent of the comment will be set to the indent of the current line.
.. NOTE:: This rule is disabled by default.

View File

@ -34,6 +34,7 @@ class rule_011(rule.Rule):
lTemp = lTokens[dAction['iToken']:]
lTemp.append(parser.carriage_return())
lTemp.extend(lTokens[:dAction['iToken']])
lTemp[dAction['index']].set_indent(dAction['indent'])
oViolation.set_tokens(lTemp)
@ -62,8 +63,11 @@ def create_action(lTokens, iToken):
dAction = {}
if isinstance(lTokens[iToken - 1], parser.whitespace):
dAction['iToken'] = iToken - 1
dAction['index'] = 1
else:
dAction['iToken'] = iToken
dAction['index'] = 0
dAction['indent'] = utils.get_indent_of_line(lTokens)
return dAction

View File

@ -98,3 +98,10 @@ def get_index_of_token_in_list(oToken, lTokens):
if isinstance(token, oToken):
return iToken
return None
def get_indent_of_line(lTokens):
if isinstance(lTokens[0], parser.whitespace):
return lTokens[1].get_indent()
else:
return lTokens[0].get_indent()

View File

@ -17,4 +17,21 @@ begin
-- Comment 3
e <= f;
-- BQ1/M3S1
rx_tdata_remapped <= rx_tdata(119 downto 112) & rx_tdata(127 downto 120) &
-- BI1/M2S1
rx_tdata(87 downto 80) & rx_tdata(95 downto 88) &
-- BQ0/M3S0
rx_tdata(103 downto 96) & rx_tdata(111 downto 104) &
-- BQ0/M2S0
rx_tdata(71 downto 64) & rx_tdata(79 downto 72) &
-- AQ1/M1S1
rx_tdata(55 downto 48) & rx_tdata(63 downto 56) &
-- AI1/M0S1
rx_tdata(23 downto 16) & rx_tdata(31 downto 24) &
-- AQ0/M1S0
rx_tdata(39 downto 32) & rx_tdata(47 downto 40) &
-- AI0/M0S0
rx_tdata(7 downto 0) & rx_tdata(15 downto 8);
end architecture rtl;

View File

@ -13,4 +13,13 @@ begin
c <= d; -- Comment 2
e <= f; -- Comment 3
rx_tdata_remapped <= rx_tdata(119 downto 112) & rx_tdata(127 downto 120) & -- BQ1/M3S1
rx_tdata(87 downto 80) & rx_tdata(95 downto 88) & -- BI1/M2S1
rx_tdata(103 downto 96) & rx_tdata(111 downto 104) & -- BQ0/M3S0
rx_tdata(71 downto 64) & rx_tdata(79 downto 72) & -- BQ0/M2S0
rx_tdata(55 downto 48) & rx_tdata(63 downto 56) & -- AQ1/M1S1
rx_tdata(23 downto 16) & rx_tdata(31 downto 24) & -- AI1/M0S1
rx_tdata(39 downto 32) & rx_tdata(47 downto 40) & -- AQ0/M1S0
rx_tdata(7 downto 0) & rx_tdata(15 downto 8); -- AI0/M0S0
end architecture rtl;

View File

@ -30,7 +30,7 @@ class test_comment_rule(unittest.TestCase):
self.assertEqual(oRule.name, 'comment')
self.assertEqual(oRule.identifier, '011')
lExpected = [5, 12, 13, 14]
lExpected = [5, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))

View File

@ -27,6 +27,8 @@ def set_token_indent(dIndentMap, lTokens):
sUniqueId = oToken.get_unique_id(sJoin=':')
iTokenIndent = None
if sUniqueId in lTokenKeys:
token_key = dIndents[sUniqueId]['token']
after_key = dIndents[sUniqueId]['after']
@ -105,6 +107,8 @@ def set_token_indent(dIndentMap, lTokens):
dVars['insideConcurrentSignalAssignment'] = False
continue
oToken.set_indent(iTokenIndent)
def update_indent_var(iIndent, update):
if str(update).startswith('+'):