-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue#882: Moving rule concurrent_007 to conditional_waveforms_001. (#…
- Loading branch information
1 parent
e5ca972
commit 0096b7d
Showing
10 changed files
with
184 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,12 @@ | ||
|
||
from vsg import parser | ||
from vsg import token | ||
from vsg import violation | ||
from vsg import deprecated_rule | ||
|
||
from vsg.vhdlFile import utils | ||
from vsg.rule_group import structure | ||
|
||
lSplitTokens = [] | ||
lSplitTokens.append(token.conditional_waveforms.else_keyword) | ||
|
||
lTokenPairs = [] | ||
lTokenPairs.append([token.concurrent_conditional_signal_assignment.assignment, token.concurrent_conditional_signal_assignment.semicolon]) | ||
|
||
|
||
class rule_007(structure.Rule): | ||
class rule_007(deprecated_rule.Rule): | ||
''' | ||
This rule checks for code after the **else** keyword. | ||
.. NOTE:: There is a configuration option :code:`allow_single_line` which allows single line concurrent statements. | ||
:code:`allow_single_line` set to :code:`no` (Default) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
**Violation** | ||
.. code-block:: vhdl | ||
wr_en <= '0' when overflow = '0' else '1'; | ||
wr_en <= '0' when overflow = '0' else '1' when underflow = '1' else sig_a; | ||
**Fix** | ||
.. code-block:: vhdl | ||
wr_en <= '0' when overflow = '0' else | ||
'1'; | ||
wr_en <= '0' when overflow = '0' else | ||
'1' when underflow = '1' else | ||
sig_a; | ||
:code:`allow_single_line` set to :code:`yes` | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
**Violation** | ||
.. code-block:: vhdl | ||
wr_en <= '0' when overflow = '0' else '1'; | ||
wr_en <= '0' when overflow = '0' else '1' when underflow = '1' else sig_a; | ||
**Fix** | ||
.. code-block:: vhdl | ||
wr_en <= '0' when overflow = '0' else '1'; | ||
wr_en <= '0' when overflow = '0' else | ||
'1' when underflow = '1' else | ||
sig_a; | ||
This rule has been renamed to `conditional_waveforms_001 <conditional_waveforms_rules.html#conditional-waveforms-001>`_. | ||
''' | ||
|
||
def __init__(self): | ||
structure.Rule.__init__(self, 'concurrent', '007') | ||
self.solution = 'move code after else to next line.' | ||
self.subphase = 2 | ||
self.lSplitTokens = lSplitTokens | ||
self.lTokenPairs = lTokenPairs | ||
self.allow_single_line = 'no' | ||
self.configuration.append('allow_single_line') | ||
self.configuration_documentation_link = None | ||
|
||
def _get_tokens_of_interest(self, oFile): | ||
lToi = [] | ||
for lTokenPair in lTokenPairs: | ||
aToi = oFile.get_tokens_bounded_by(lTokenPair[0], lTokenPair[1]) | ||
lToi = utils.combine_two_token_class_lists(lToi, aToi) | ||
return lToi | ||
|
||
def _analyze(self, lToi): | ||
self.allow_single_line = utils.convert_yes_no_option_to_boolean(self.allow_single_line) | ||
|
||
for oToi in lToi: | ||
lTokens = oToi.get_tokens() | ||
|
||
if utils.find_carriage_return(lTokens) is None and self.allow_single_line: | ||
for oSplitToken in self.lSplitTokens: | ||
if utils.count_token_types_in_list_of_tokens(oSplitToken, lTokens) > 1: | ||
break | ||
else: | ||
continue | ||
|
||
iLine = oToi.get_line_number() | ||
for iToken, oToken in enumerate(lTokens): | ||
iLine = utils.increment_line_number(iLine, oToken) | ||
for oSplitToken in self.lSplitTokens: | ||
if isinstance(oToken, oSplitToken): | ||
if utils.are_next_consecutive_token_types([parser.whitespace, parser.comment], iToken + 1, lTokens): | ||
continue | ||
if utils.are_next_consecutive_token_types([parser.comment], iToken + 1, lTokens): | ||
continue | ||
if utils.are_next_consecutive_token_types([parser.carriage_return], iToken + 1, lTokens): | ||
continue | ||
oViolation = violation.New(iLine, oToi.extract_tokens(iToken, iToken), self.solution) | ||
self.add_violation(oViolation) | ||
break | ||
|
||
def _fix_violation(self, oViolation): | ||
lTokens = oViolation.get_tokens() | ||
lTokens.append(parser.carriage_return()) | ||
oViolation.set_tokens(lTokens) | ||
deprecated_rule.Rule.__init__(self, 'concurrent', '007') | ||
self.message.append('Rule ' + self.unique_id + ' has been renamed to conditional_waveforms_001.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
|
||
from vsg import parser | ||
from vsg import token | ||
from vsg import violation | ||
|
||
from vsg.vhdlFile import utils | ||
from vsg.rule_group import structure | ||
|
||
lSplitTokens = [] | ||
lSplitTokens.append(token.conditional_waveforms.else_keyword) | ||
|
||
lTokenPairs = [] | ||
lTokenPairs.append([token.concurrent_conditional_signal_assignment.assignment, token.concurrent_conditional_signal_assignment.semicolon]) | ||
|
||
|
||
class rule_001(structure.Rule): | ||
''' | ||
This rule checks for code after the **else** keyword. | ||
.. NOTE:: There is a configuration option :code:`allow_single_line` which allows single line concurrent statements. | ||
:code:`allow_single_line` set to :code:`no` (Default) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
**Violation** | ||
.. code-block:: vhdl | ||
wr_en <= '0' when overflow = '0' else '1'; | ||
wr_en <= '0' when overflow = '0' else '1' when underflow = '1' else sig_a; | ||
**Fix** | ||
.. code-block:: vhdl | ||
wr_en <= '0' when overflow = '0' else | ||
'1'; | ||
wr_en <= '0' when overflow = '0' else | ||
'1' when underflow = '1' else | ||
sig_a; | ||
:code:`allow_single_line` set to :code:`yes` | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
**Violation** | ||
.. code-block:: vhdl | ||
wr_en <= '0' when overflow = '0' else '1'; | ||
wr_en <= '0' when overflow = '0' else '1' when underflow = '1' else sig_a; | ||
**Fix** | ||
.. code-block:: vhdl | ||
wr_en <= '0' when overflow = '0' else '1'; | ||
wr_en <= '0' when overflow = '0' else | ||
'1' when underflow = '1' else | ||
sig_a; | ||
''' | ||
|
||
def __init__(self): | ||
structure.Rule.__init__(self, 'conditional_waveforms', '001') | ||
self.solution = 'move code after else to next line.' | ||
self.subphase = 2 | ||
self.lSplitTokens = lSplitTokens | ||
self.lTokenPairs = lTokenPairs | ||
self.allow_single_line = 'no' | ||
self.configuration.append('allow_single_line') | ||
self.configuration_documentation_link = None | ||
|
||
def _get_tokens_of_interest(self, oFile): | ||
lToi = [] | ||
for lTokenPair in lTokenPairs: | ||
aToi = oFile.get_tokens_bounded_by(lTokenPair[0], lTokenPair[1]) | ||
lToi = utils.combine_two_token_class_lists(lToi, aToi) | ||
return lToi | ||
|
||
def _analyze(self, lToi): | ||
self.allow_single_line = utils.convert_yes_no_option_to_boolean(self.allow_single_line) | ||
|
||
for oToi in lToi: | ||
lTokens = oToi.get_tokens() | ||
|
||
if utils.find_carriage_return(lTokens) is None and self.allow_single_line: | ||
for oSplitToken in self.lSplitTokens: | ||
if utils.count_token_types_in_list_of_tokens(oSplitToken, lTokens) > 1: | ||
break | ||
else: | ||
continue | ||
|
||
iLine = oToi.get_line_number() | ||
for iToken, oToken in enumerate(lTokens): | ||
iLine = utils.increment_line_number(iLine, oToken) | ||
for oSplitToken in self.lSplitTokens: | ||
if isinstance(oToken, oSplitToken): | ||
if utils.are_next_consecutive_token_types([parser.whitespace, parser.comment], iToken + 1, lTokens): | ||
continue | ||
if utils.are_next_consecutive_token_types([parser.comment], iToken + 1, lTokens): | ||
continue | ||
if utils.are_next_consecutive_token_types([parser.carriage_return], iToken + 1, lTokens): | ||
continue | ||
oViolation = violation.New(iLine, oToi.extract_tokens(iToken, iToken), self.solution) | ||
self.add_violation(oViolation) | ||
break | ||
|
||
def _fix_violation(self, oViolation): | ||
lTokens = oViolation.get_tokens() | ||
lTokens.append(parser.carriage_return()) | ||
oViolation.set_tokens(lTokens) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.