Updates for issue #445

Adding ability for the user to adjust the indenting algorithm.

  1)  Added documentation
  2)  Refactored indent algorithm
      a)  Changed algorithm to use a YAML configuration file
  3)  Added indent dictionary to -oc output
  4)  Updated tests to use new YAML configuration file
This commit is contained in:
Jeremiah Leary 2020-12-20 18:06:07 -06:00
parent d7403e6273
commit be88d4a462
97 changed files with 5740 additions and 243 deletions

View File

@ -235,3 +235,4 @@ Configure the indent size for all rules by setting the **global** attribute.
.. include:: configuring_type_of_instantiations.rst
.. include:: configuring_optional_items.rst
.. include:: configuring_block_comments.rst
.. include:: configuring_indentation.rst

View File

@ -0,0 +1,135 @@
Configuring Indentation
-----------------------
VSG follows a predefined set of rules when indenting VHDL code.
The indenting alogrithm is driven by a YAML file.
The indent values feeding the algorithm can be obtained by using the **-oc** command line argument.
There will be a section starting with **indent**.
Understanding the Indent Configuration Data Structure
#####################################################
The indent configuration file follows this basic format:
.. code-block:: yaml
indent:
tokens:
group_name:
token_name:
token : value
after : value
where:
+-------------+--------------+-------------------------------------------------------------------+
| Attribute | Values | Description |
+=============+==============+===================================================================+
| indent | NA | Indicates the following information defines indent behavior. |
+-------------+--------------+-------------------------------------------------------------------+
| tokens | NA | Indicates the following information defines token level behavior. |
+-------------+--------------+-------------------------------------------------------------------+
| group_name | <string> | The group a token belongs to. |
+-------------+--------------+-------------------------------------------------------------------+
| token_name | <string> | The name of the token which has indent behavior. |
+-------------+--------------+-------------------------------------------------------------------+
| token | NA | Indicates the value to apply to the token. |
+-------------+--------------+-------------------------------------------------------------------+
| after | NA | Indicates the value to apply after the token. |
+-------------+--------------+-------------------------------------------------------------------+
| value | <integer> | The type of behavior to apply to the token or after the token. |
| | current | |
| | "+<integer>" | |
| | "-<integer>" | |
+-------------+--------------+-------------------------------------------------------------------+
The **group_name** and **token_name** keys provide unique identifier which can be matched to types of tokens after the file has been parsed.
There are more tokens than are currently defined in the indent configuration, as not all tokens require indenting rules.
The **token** key informs VSG how to apply indents when it encounters the token.
The **after** key informs VSG how to apply indents to successive tokens it encounters.
The **value** defines the behavior for each **token** and **after** key, and are defined as:
+----------------+-----------+-----------------------------------------------------------+
| Value | Type | Description |
+================+===========+===========================================================+
| [0-9][0-9]* | <integer> | Sets the indent level to the specified value. |
+----------------+-----------+-----------------------------------------------------------+
| current | <string> | Uses the existing indent level. |
+----------------+-----------+-----------------------------------------------------------+
| "+[0-9][0-9]*" | <string> | Increase the indent relative to the current indent level. |
+----------------+-----------+-----------------------------------------------------------+
| "-[0-9][0-9]*" | <string> | Decrease the indent relative to the current indent level. |
+----------------+-----------+-----------------------------------------------------------+
Using the **group_name** and **token_name** to identify types of VHDL tokens and then the **token** and **after** defines the behavior of the indenting algorithm.
Example
#######
VSG assumes the closing parenthesis will match with the **port** keyword.
.. code-block:: vhdl
entity some_block is
port (
I_CLK : std_logic;
I_RST : std_logic;
I_WR_EN : std_logic;
O_DATA : std_logic_vector(7 downto 0);
);
end entity some_block;
If we use the following configuration...
.. code-block:: yaml
indent:
tokens:
port_clause:
close_parenthesis:
token : current
after : '-2'
...then VSG will enforce the following format:
.. code-block:: vhdl
entity some_block is
port (
I_CLK : std_logic;
I_RST : std_logic;
I_WR_EN : std_logic;
O_DATA : std_logic_vector(7 downto 0);
);
end entity some_block;
How does this work?
^^^^^^^^^^^^^^^^^^^
VSG is setting the indent levels as it goes.
The port definitions in the above example are set to an indent of 2.
When the closing parenthesis is encountered, VSG checks the **port_clause.close_parenthesis.token** key to determine what to do.
In this case the key is set to **current**.
This tells VSG to keep the indent of 2 for the closing parenthesis token.
VSG then looks at the **port_clause.close_parenthesis.after** key and finds a **'-2'**.
This tells VSG to subtract two from the current indent value of 2.
Which will set the indent to 0.
The next token in the indent configuration with a **token** key value of **current** would then get 0.
The Challenge With Adjusting Indent Values
###########################################
The most difficult part of changing the indent values is knowing which **group_name** and **token_name** to use.
For the **group_name** use the VHDL LRM as a reference.
All group names match a *left-hand side* of a *production*.
For the **token_name**, refer to the output configuration using the **-oc**.
This will give the complete indent configuration.
The desired adjustment can be pulled out into a smaller file.
This file can then be applied with the **-c** option.

View File

@ -289,6 +289,7 @@ def generate_output_configuration(commandLineArguments, configuration):
if commandLineArguments.local_rules:
dOutputConfiguration['local_rules'] = commandLineArguments.local_rules
dOutputConfiguration['rule'] = oRules.get_configuration()
dOutputConfiguration['indent'] = configuration['indent']
with open(commandLineArguments.output_configuration, 'w') as json_file:
json.dump(dOutputConfiguration, json_file, sort_keys=True, indent=2)
sys.exit(fExitStatus)
@ -353,6 +354,35 @@ def add_debug_to_configuration(oCLA, dConfiguration):
return dConfiguration
def read_indent_configuration(dConfiguration):
'''
Reads the default indent dictionary and merges any changes from a user configuration.
Parameters:
dConfiguration: (dictionary)
Returns: (dictionary)
'''
sFileName = os.path.join(os.path.dirname(__file__), 'vhdlFile', 'indent', 'indent_config.yaml')
dReturn = open_configuration_file(sFileName)
### This merges an indent configuration into the base indent dictionary
if 'indent' in list(dConfiguration.keys()):
dGroups = dConfiguration['indent']['tokens']
print(dGroups)
for sGroup in list(dGroups.keys()):
for sToken in list(dGroups[sGroup].keys()):
for sParameter in list(dGroups[sGroup][sToken].keys()):
dReturn['indent']['tokens'][sGroup][sToken][sParameter] = dGroups[sGroup][sToken][sParameter]
dConfiguration['indent'] = dReturn['indent']
return dReturn
def main():
'''Main routine of the VHDL Style Guide (VSG) program.'''
@ -366,6 +396,8 @@ def main():
configuration = read_configuration_files(dStyle, commandLineArguments)
dIndent = read_indent_configuration(configuration)
fix_only = open_fix_file(commandLineArguments.fix_only)
update_command_line_arguments(commandLineArguments, configuration)
@ -398,6 +430,7 @@ def main():
dJsonEntry = {}
oVhdlFile = vhdlFile.vhdlFile(read_vhdlfile(sFileName))
oVhdlFile.filename = sFileName
oVhdlFile.set_indent_map(dIndent)
oRules = rule_list.rule_list(oVhdlFile, oSeverityList, commandLineArguments.local_rules)
oRules.configure(configuration)
try:

4675
vsg/blah.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -73,8 +73,10 @@ class item():
def set_all_code_tags(self):
self.code_tags = ['all']
def get_unique_id(self):
return self.base_token, self.sub_token
def get_unique_id(self, sJoin=None):
if sJoin is None:
return self.base_token, self.sub_token
return self.base_token + sJoin + self.sub_token
def get_base_token(self):
return self.base_token

View File

@ -14,3 +14,4 @@ class rule_016(remove_blank_lines_above_line_starting_with_token):
def __init__(self):
remove_blank_lines_above_line_starting_with_token.__init__(self, 'entity', '016', lTokens)
self.solution = 'Remove blank lines above'

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_architecture_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = architecture.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_007_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_007_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_architecture_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_007(self):
oRule = architecture.rule_007()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_008_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_008_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_architecture_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_008(self):
oRule = architecture.rule_008()

View File

@ -10,6 +10,10 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +23,8 @@ class test_assert_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = assert_statement.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_300_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_300_test_input.fixed.vhd'), lExpected, False)
@ -19,6 +21,7 @@ class test_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_300(self):
oRule = attribute_declaration.rule_300()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_300_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_300_test_input.fixed.vhd'), lExpected, False)
@ -19,6 +21,7 @@ class test_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_300(self):
oRule = attribute_specification.rule_300()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_300_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_300_test_input.fixed.vhd'), lExpected, False)
@ -19,6 +21,7 @@ class test_block_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_300(self):
oRule = block.rule_300()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_301_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_301_test_input.fixed.vhd'), lExpected, False)
@ -19,6 +21,7 @@ class test_block_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_301(self):
oRule = block.rule_301()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_302_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_302_test_input.fixed.vhd'), lExpected, False)
@ -19,6 +21,7 @@ class test_block_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_302(self):
oRule = block.rule_302()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_case_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = case.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_011_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_011_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_case_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_011(self):
oRule = case.rule_011()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_013_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_013_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_case_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_013(self):
oRule = case.rule_013()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_021_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_021_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_case_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_021(self):
oRule = case.rule_021()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_010_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_010_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_comment_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_010(self):
oRule = comment.rule_010()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_component_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = component.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_009_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_009_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_component_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_009(self):
oRule = component.rule_009()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_concurrent_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = concurrent.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_constant_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = constant.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_context_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = context.rule_001()

View File

@ -9,6 +9,8 @@ from vsg.tests import utils
sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_020_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_020_test_input.fixed.vhd'), lExpected)
@ -18,6 +20,7 @@ class test_context_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_020(self):
oRule = context.rule_020()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_context_ref_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = context_ref.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_entity_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = entity.rule_001()

View File

@ -19,6 +19,8 @@ class test_entity_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
dIndentMap = utils.read_indent_file()
self.oFile.set_indent_map(dIndentMap)
def test_rule_009(self):
oRule = entity.rule_009()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_file_statement_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = file_statement.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_for_loop_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = for_loop.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_002_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_002_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_for_loop_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_002(self):
oRule = for_loop.rule_002()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_function_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = function.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_008_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_008_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_function_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_008(self):
oRule = function.rule_008()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_016_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_016_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_function_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_016(self):
oRule = function.rule_016()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_generate_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = generate.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_006_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_006_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_generate_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_006(self):
oRule = generate.rule_006()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_007_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_007_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_generate_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_007(self):
oRule = generate.rule_007()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_016_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_016_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_generate_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_016(self):
oRule = generate.rule_016()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_018_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_018_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_generate_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_018(self):
oRule = generate.rule_018()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_002_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_002_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_generic_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_002(self):
oRule = generic.rule_002()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_004_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_004_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_generic_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_004(self):
oRule = generic.rule_004()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_008_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_008_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_generic_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_008(self):
oRule = generic.rule_008()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_if_statement_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = if_statement.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_012_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_012_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_if_statement_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_012(self):
oRule = if_statement.rule_012()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_013_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_013_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_if_statement_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_013(self):
oRule = if_statement.rule_013()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_014_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_014_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_if_statement_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_014(self):
oRule = if_statement.rule_014()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_032_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_032_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_if_statement_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_032(self):
oRule = if_statement.rule_032()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_033_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_033_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_if_statement_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_033(self):
oRule = if_statement.rule_033()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_instantiation_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = instantiation.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_library_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = library.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_008_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_008_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_library_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_008(self):
oRule = library.rule_008()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_009_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_009_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_library_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_009(self):
oRule = library.rule_009()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_package_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = package.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_015_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_015_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_package_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_015(self):
oRule = package.rule_015()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_300_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_300_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_package_body_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_300(self):
oRule = package_body.rule_300()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_301_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_301_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_package_body_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_301(self):
oRule = package_body.rule_301()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_002_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_002_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_port_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_002(self):
oRule = port.rule_002()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_004_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_004_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_port_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_004(self):
oRule = port.rule_004()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_015_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_015_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_port_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_015(self):
oRule = port.rule_015()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_procedure_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = procedure.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_002_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_002_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_procedure_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_002(self):
oRule = procedure.rule_002()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_003_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_003_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_procedure_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_003(self):
oRule = procedure.rule_003()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_004_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_004_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_procedure_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_004(self):
oRule = procedure.rule_004()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_005_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_005_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_procedure_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_005(self):
oRule = procedure.rule_005()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_006_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_006_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_procedure_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_006(self):
oRule = procedure.rule_006()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_300_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_300_test_input.fixed.vhd'), lExpected, False)
@ -19,6 +21,7 @@ class test_procedure_call_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_300(self):
oRule = procedure_call.rule_300()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_301_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_301_test_input.fixed.vhd'), lExpected, False)
@ -19,6 +21,7 @@ class test_procedure_call_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_301(self):
oRule = procedure_call.rule_301()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_302_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_302_test_input.fixed.vhd'), lExpected, False)
@ -19,6 +21,7 @@ class test_procedure_call_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_302(self):
oRule = procedure_call.rule_302()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_process_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = process.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_003_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_003_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_process_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_003(self):
oRule = process.rule_003()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_006_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_006_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_process_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_006(self):
oRule = process.rule_006()

View File

@ -7,8 +7,11 @@ from vsg import severity
from vsg.tests import utils
dIndentMap = utils.read_indent_file()
oSeverityList = severity.create_list({})
class testVsg(unittest.TestCase):
def test_extract_violation_dictionary(self):
@ -16,6 +19,7 @@ class testVsg(unittest.TestCase):
lFile = []
utils.read_file('vsg/tests/styles/code_examples/spi_master.vhd', lFile)
oFile = vhdlFile.vhdlFile(lFile)
oFile.set_indent_map(dIndentMap)
oRules = rule_list.rule_list(oFile, oSeverityList)
oRules.check_rules()
with open('vsg/tests/rule_list/extract_violation_dictionary.json') as jsonFile:
@ -27,6 +31,7 @@ class testVsg(unittest.TestCase):
lFile = []
utils.read_file('vsg/tests/styles/code_examples/spi_master.vhd', lFile)
oFile = vhdlFile.vhdlFile(lFile)
oFile.set_indent_map(dIndentMap)
oRules = rule_list.rule_list(oFile, oSeverityList)
oRules.check_rules(True)
with open('vsg/tests/rule_list/extract_violation_dictionary_w_all_phases_enabled.json') as jsonFile:

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_sequential_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = sequential.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_signal_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = signal.rule_001()

View File

@ -9,18 +9,26 @@ from vsg.tests import utils
sSourceDir = os.path.join(os.path.dirname(__file__),'..','..','code_examples','c16')
dIndentMap = utils.read_indent_file()
lBaudGen = utils.read_vhdlfile(os.path.join(sSourceDir,'BaudGen.vhd'))
oBaudGen = vhdlFile.vhdlFile(lBaudGen)
oBaudGen.set_indent_map(dIndentMap)
lBoardCpu = utils.read_vhdlfile(os.path.join(sSourceDir,'Board_cpu.vhd'))
oBoardCpu = vhdlFile.vhdlFile(lBoardCpu)
oBoardCpu.set_indent_map(dIndentMap)
lDataCore = utils.read_vhdlfile(os.path.join(sSourceDir,'data_core.vhd'))
oDataCore = vhdlFile.vhdlFile(lDataCore)
oDataCore.set_indent_map(dIndentMap)
dLegacyConfig = utils.read_configuration(os.path.join(os.path.dirname(__file__),'..','..','..','..','styles', 'indent_only.yaml'))
dLegacyConfig['debug'] = False
oSeverityList = severity.create_list({})
class testCodeExample(unittest.TestCase):
def test_baudgen(self):

View File

@ -1,7 +1,6 @@
import os
import unittest
from vsg import vhdlFile
from vsg import rule_list
from vsg import severity
@ -9,26 +8,42 @@ from vsg.tests import utils
sSourceDir = os.path.join(os.path.dirname(__file__),'..','..','code_examples','graphicsaccelerator')
dIndentMap = utils.read_indent_file()
lBresenhamer = utils.read_vhdlfile(os.path.join(sSourceDir,'Bresenhamer.vhd'))
oBresenhamer = vhdlFile.vhdlFile(lBresenhamer)
oBresenhamer.set_indent_map(dIndentMap)
lDebouncer = utils.read_vhdlfile(os.path.join(sSourceDir,'Debouncer.vhd'))
oDebouncer = vhdlFile.vhdlFile(lDebouncer)
oDebouncer.set_indent_map(dIndentMap)
lVgatop = utils.read_vhdlfile(os.path.join(sSourceDir,'VGA_Top.vhd'))
oVgatop = vhdlFile.vhdlFile(lVgatop)
oVgatop.set_indent_map(dIndentMap)
lPointer = utils.read_vhdlfile(os.path.join(sSourceDir,'Pointer.vhd'))
oPointer = vhdlFile.vhdlFile(lPointer)
oPointer.set_indent_map(dIndentMap)
lFreqDiv = utils.read_vhdlfile(os.path.join(sSourceDir,'FreqDiv.vhd'))
oFreqDiv = vhdlFile.vhdlFile(lFreqDiv)
oFreqDiv.set_indent_map(dIndentMap)
lSynchronizer = utils.read_vhdlfile(os.path.join(sSourceDir,'Synchronizer.vhd'))
oSynchronizer = vhdlFile.vhdlFile(lSynchronizer)
oSynchronizer.set_indent_map(dIndentMap)
lFrameBuffer = utils.read_vhdlfile(os.path.join(sSourceDir,'FrameBuffer2.vhd'))
oFrameBuffer = vhdlFile.vhdlFile(lFrameBuffer)
oFrameBuffer.set_indent_map(dIndentMap)
dLegacyConfig = utils.read_configuration(os.path.join(os.path.dirname(__file__),'..','..','..','..','styles', 'indent_only.yaml'))
dLegacyConfig['debug'] = False
oSeverityList = severity.create_list({})
class testCodeExample(unittest.TestCase):
def test_bresenhamer(self):

View File

@ -8,20 +8,27 @@ from vsg.tests import utils
sSourceCodeDir = os.path.join(os.path.dirname(__file__),'..','code_examples')
dIndentMap = utils.read_indent_file()
lTimestamp = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'timestamp.vhdl'))
oTimestamp = vhdlFile.vhdlFile(lTimestamp)
oTimestamp.set_indent_map(dIndentMap)
lSpiSlave = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'spi_slave.vhd'))
oSpiSlave = vhdlFile.vhdlFile(lSpiSlave)
oSpiSlave.set_indent_map(dIndentMap)
lSpiMaster = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'spi_master.vhd'))
oSpiMaster = vhdlFile.vhdlFile(lSpiMaster)
oSpiMaster.set_indent_map(dIndentMap)
lGrpDebouncer = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'grp_debouncer.vhd'))
oGrpDebouncer = vhdlFile.vhdlFile(lGrpDebouncer)
oGrpDebouncer.set_indent_map(dIndentMap)
lPIC = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'PIC.vhd'))
oPIC = vhdlFile.vhdlFile(lPIC)
oPIC.set_indent_map(dIndentMap)
dLegacyConfig = utils.read_configuration(os.path.join(os.path.dirname(__file__),'..','..','..','styles', 'indent_only.yaml'))
dLegacyConfig['debug'] = False

View File

@ -7,14 +7,18 @@ from vsg import rule_list
from vsg import severity
from vsg.tests import utils
dIndentMap = utils.read_indent_file()
lIteration = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','..','code_examples', 'turbocodes', 'iteration_synth.vhd'))
oIteration = vhdlFile.vhdlFile(lIteration)
oIteration.set_indent_map(dIndentMap)
dLegacyConfig = utils.read_configuration(os.path.join(os.path.dirname(__file__),'..','..','..','..','styles', 'indent_only.yaml'))
dLegacyConfig['debug'] = False
oSeverityList = severity.create_list({})
class testCodeExample(unittest.TestCase):
def test_iteration_synth(self):

View File

@ -9,18 +9,26 @@ from vsg.tests import utils
sSourceDir = os.path.join(os.path.dirname(__file__),'..','..','code_examples','c16')
dIndentMap = utils.read_indent_file()
lBaudGen = utils.read_vhdlfile(os.path.join(sSourceDir,'BaudGen.vhd'))
oBaudGen = vhdlFile.vhdlFile(lBaudGen)
oBaudGen.set_indent_map(dIndentMap)
lBoardCpu = utils.read_vhdlfile(os.path.join(sSourceDir,'Board_cpu.vhd'))
oBoardCpu = vhdlFile.vhdlFile(lBoardCpu)
oBoardCpu.set_indent_map(dIndentMap)
lDataCore = utils.read_vhdlfile(os.path.join(sSourceDir,'data_core.vhd'))
oDataCore = vhdlFile.vhdlFile(lDataCore)
oDataCore.set_indent_map(dIndentMap)
dConfig = utils.read_configuration(os.path.join(os.path.dirname(__file__),'..','..','..','..','styles', 'jcl.yaml'))
dConfig['debug'] = False
oSeverityList = severity.create_list({})
class testCodeExample(unittest.TestCase):
def test_baudgen(self):

View File

@ -9,20 +9,35 @@ from vsg.tests import utils
sSourceDir = os.path.join(os.path.dirname(__file__),'..','..','code_examples','graphicsaccelerator')
dIndentMap = utils.read_indent_file()
lBresenhamer = utils.read_vhdlfile(os.path.join(sSourceDir,'Bresenhamer.vhd'))
oBresenhamer = vhdlFile.vhdlFile(lBresenhamer)
oBresenhamer.set_indent_map(dIndentMap)
lDebouncer = utils.read_vhdlfile(os.path.join(sSourceDir,'Debouncer.vhd'))
oDebouncer = vhdlFile.vhdlFile(lDebouncer)
oDebouncer.set_indent_map(dIndentMap)
lVgatop = utils.read_vhdlfile(os.path.join(sSourceDir,'VGA_Top.vhd'))
oVgatop = vhdlFile.vhdlFile(lVgatop)
oVgatop.set_indent_map(dIndentMap)
lPointer = utils.read_vhdlfile(os.path.join(sSourceDir,'Pointer.vhd'))
oPointer = vhdlFile.vhdlFile(lPointer)
oPointer.set_indent_map(dIndentMap)
lFreqDiv = utils.read_vhdlfile(os.path.join(sSourceDir,'FreqDiv.vhd'))
oFreqDiv = vhdlFile.vhdlFile(lFreqDiv)
oFreqDiv.set_indent_map(dIndentMap)
lSynchronizer = utils.read_vhdlfile(os.path.join(sSourceDir,'Synchronizer.vhd'))
oSynchronizer = vhdlFile.vhdlFile(lSynchronizer)
oSynchronizer.set_indent_map(dIndentMap)
lFrameBuffer = utils.read_vhdlfile(os.path.join(sSourceDir,'FrameBuffer2.vhd'))
oFrameBuffer = vhdlFile.vhdlFile(lFrameBuffer)
oFrameBuffer.set_indent_map(dIndentMap)
dConfig = utils.read_configuration(os.path.join(os.path.dirname(__file__),'..','..','..','..','styles', 'jcl.yaml'))
dConfig['debug'] = False

View File

@ -10,20 +10,27 @@ from vsg.tests import utils
sSourceCodeDir = os.path.join(os.path.dirname(__file__),'..','code_examples')
dIndentMap = utils.read_indent_file()
lTimestamp = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'timestamp.vhdl'))
oTimestamp = vhdlFile.vhdlFile(lTimestamp)
oTimestamp.set_indent_map(dIndentMap)
lSpiSlave = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'spi_slave.vhd'))
oSpiSlave = vhdlFile.vhdlFile(lSpiSlave)
oSpiSlave.set_indent_map(dIndentMap)
lSpiMaster = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'spi_master.vhd'))
oSpiMaster = vhdlFile.vhdlFile(lSpiMaster)
oSpiMaster.set_indent_map(dIndentMap)
lGrpDebouncer = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'grp_debouncer.vhd'))
oGrpDebouncer = vhdlFile.vhdlFile(lGrpDebouncer)
oGrpDebouncer.set_indent_map(dIndentMap)
lPIC = utils.read_vhdlfile(os.path.join(sSourceCodeDir,'PIC.vhd'))
oPIC = vhdlFile.vhdlFile(lPIC)
oPIC.set_indent_map(dIndentMap)
dConfig = utils.read_configuration(os.path.join(os.path.dirname(__file__),'..','..','..','styles', 'jcl.yaml'))
dConfig['debug'] = False

View File

@ -7,14 +7,18 @@ from vsg import rule_list
from vsg import severity
from vsg.tests import utils
dIndentMap = utils.read_indent_file()
lIteration = utils.read_vhdlfile(os.path.join(os.path.dirname(__file__),'..','..','code_examples', 'turbocodes', 'iteration_synth.vhd'))
oIteration = vhdlFile.vhdlFile(lIteration)
oIteration.set_indent_map(dIndentMap)
dConfig = utils.read_configuration(os.path.join(os.path.dirname(__file__),'..','..','..','..','styles', 'jcl.yaml'))
dConfig['debug'] = False
oSeverityList = severity.create_list({})
class testCodeExample(unittest.TestCase):
def test_iteration_synth(self):

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_subtype_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = subtype.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_type_definition_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = type_definition.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_005_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_005_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_type_definition_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_005(self):
oRule = type_definition.rule_005()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_012_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_012_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_type_definition_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_012(self):
oRule = type_definition.rule_012()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_016_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_016_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_type_definition_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_016(self):
oRule = type_definition.rule_016()

View File

@ -46,6 +46,13 @@ def read_vhdlfile(sFileName):
return []
def read_indent_file():
sFileName = os.path.join('vsg', 'vhdlFile', 'indent', 'indent_config.yaml')
with open(sFileName) as yaml_file:
dFile = yaml.full_load(yaml_file)
return dFile
def add_violation(iLineNumber):
dViolation = {}
dViolation['lines'] = []

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_variable_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = variable.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_variable_assignment_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = variable_assignment.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_wait_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = wait.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_001_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_001_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_while_loop_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_001(self):
oRule = while_loop.rule_001()

View File

@ -10,6 +10,8 @@ sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_002_test_input.vhd'))
dIndentMap = utils.read_indent_file()
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_002_test_input.fixed.vhd'), lExpected)
@ -19,6 +21,7 @@ class test_while_loop_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.oFile.set_indent_map(dIndentMap)
def test_rule_002(self):
oRule = while_loop.rule_002()

View File

@ -0,0 +1,450 @@
indent:
tokens:
architecture_body:
architecture_keyword:
token : 0
after : 1
begin_keyword:
token : 0
after : 1
end_keyword:
token : 0
after : 0
assertion:
keyword:
token : current
after : '+1'
report_keyword:
token : current
after : current
severity_keyword:
token : current
after : current
assertion_statement:
label:
token : current
after : current
semicolon:
token : current
after : '-1'
association_element:
formal_part:
token : current
after : current
attribute_declaration:
attribute_keyword:
token : current
after : current
attribute_specification:
attribute_keyword:
token : current
after : current
block_statement:
block_label:
token : current
after : '+1'
begin_keyword:
token : '-1'
after : current
end_keyword:
token : '-1'
after : '-1'
case_generate_alternative:
when_keyword:
token : '-1'
after : current
case_generate_statement:
generate_label:
token : current
after : '+2'
end_keyword:
token : '-2'
after : '-2'
case_statement:
case_label:
token : current
after : current
case_keyword:
token : current
after : '+2'
end_keyword:
token : '-2'
after : '-2'
case_statement_alternative:
when_keyword:
token : '-1'
after : current
component_declaration:
component_keyword:
token : current
after : '+1'
end_keyword:
token : '-1'
after : '-1'
component_instantiation_statement:
instantiation_label:
token : current
after : '+1'
semicolon:
token : current
after : '-1'
concurrent_assertion_statement:
label_name:
token : current
after : current
semicolon:
token : '-1'
after : '-1'
concurrent_conditional_signal_assignment:
target:
token : current
after : current
concurrent_procedure_call_statement:
label_name:
token : current
after : current
postponed_keyword:
token : current
after : current
concurrent_selected_signal_assignment:
with_keyword:
token : current
after : current
concurrent_signal_assignment_statement:
label_name:
token : current
after : current
postponed_keyword:
token : current
after : current
concurrent_simple_signal_assignment:
target:
token : current
after : current
conditional_variable_assignment:
target:
token : current
after : current
context_declaration:
context_keyword:
token : 0
after : '+1'
end_keyword:
token : 0
after : 0
constant_declaration:
constant_keyword:
token : current
after : current
if_generate_statement:
generate_label:
token : current
after : '+1'
if_keyword:
token : '-1'
after : current
elsif_keyword:
token : '-1'
after : current
else_keyword:
token : '-1'
after : current
end_keyword:
token : '-1'
after : '-1'
entity_declaration:
entity_keyword:
token : 0
after : 1
end_keyword:
token : 0
after : 0
enumeration_type_definition:
open_parenthesis:
token : current
after : '+1'
enumeration_literal:
token : current
after : current
close_parenthesis:
token : '-1'
after : '-1'
file_declaration:
file_keyword:
token : current
after : current
file_open_information:
open_keyword:
token : '+1'
after : current
is_keyword:
token : '+1'
after : current
for_generate_statement:
generate_label:
token : current
after : '+1'
end_keyword:
token : '-1'
after : '-1'
full_type_declaration:
type_keyword:
token : current
after : current
function_specification:
pure_keyword:
token : current
after : current
impure_keyword:
token : current
after : current
function_keyword:
token : current
after : '+1'
close_parenthesis:
token : '-1'
after : current
generate_statement_body:
begin_keyword:
token : '-1'
after : current
end_keyword:
token : '-1'
after : current
generic_clause:
generic_keyword:
token : current
after : '+1'
close_parenthesis:
token : '-1'
after : '-1'
generic_map_aspect:
generic_keyword:
token : current
after : '+1'
close_parenthesis:
token : '-1'
after : '-1'
identifier_list:
identifier:
token : current
after : current
if_statement:
if_label:
token : current
after : current
if_keyword:
token : current
after : '+1'
elsif_keyword:
token : '-1'
after : current
else_keyword:
token : '-1'
after : current
end_keyword:
token : '-1'
after : '-1'
incomplete_type_declaration:
type_keyword:
token : current
after : current
interface_constant_declaration:
constant_keyword:
token : current
after : current
interface_file_declaration:
file_keyword:
token : current
after : current
interface_function_specification:
function_keyword:
token : current
after : current
interface_incomplete_type_declaration:
type_keyword:
token : current
after : current
interface_package_declaration:
package_keyword:
token : current
after : current
interface_procedure_specification:
procedure_keyword:
token : current
after : current
interface_signal_declaration:
signal_keyword:
token : current
after : current
interface_unknown_declaration:
identifier:
token : current
after : current
interface_variable_declaration:
variable_keyword:
token : current
after : current
iteration_scheme:
for_keyword:
token : current
after : '+1'
while_keyword:
token : current
after : '+1'
library_clause:
keyword:
token : current
after : current
loop_statement:
loop_label:
token : current
after : current
loop_keyword:
token : '-1'
after : current
end_keyword:
token : '-1'
after : '-1'
null_statement:
label:
token : current
after : current
null_keyword:
token : current
after : current
package_body:
package_keyword:
token : current
after : '+1'
end_keyword:
token : '-1'
after : '-1'
package_declaration:
package_keyword:
token : current
after : '+1'
end_keyword:
token : '-1'
after : '-1'
port_clause:
port_keyword:
token : current
after : '+1'
close_parenthesis:
token : '-1'
after : '-1'
port_map_aspect:
port_keyword:
token : current
after : '+1'
close_parenthesis:
token : '-1'
after : '-1'
procedure_call:
procedure_name:
token : current
after : current
procedure_call_statement:
label:
token : current
after : current
procedure_specification:
procedure_keyword:
token : current
after : '+1'
close_parenthesis:
token : '-1'
after : current
process_statement:
process_label:
token : current
after : current
postponed_keyword:
token : current
after : current
process_keyword:
token : current
after : '+1'
begin_keyword:
token : '-1'
after : current
end_keyword:
token : '-1'
after : '-1'
record_type_definition:
record_keyword:
token : current
after : '+1'
end_keyword:
token : current
after : '-1'
return_statement:
return_keyword:
token : current
after : current
selected_variable_assignment:
with_keyword:
token : current
after : current
signal_assignment_statement:
label:
token : current
after : current
signal_declaration:
signal_keyword:
token : current
after : current
simple_force_assignment:
target:
token : current
after : current
simple_release_assignment:
target:
token : current
after : current
simple_variable_assignment:
target:
token : current
after : current
simple_waveform_assignment:
target:
token : current
after : current
subprogram_body:
begin_keyword:
token : '-1'
after : current
end_keyword:
token : '-1'
after : current
semicolon:
token : current
after : '-1'
subprogram_declaration:
semicolon:
token : current
after : '-1'
subtype_declaration:
subtype_keyword:
token : current
after : current
variable_assignment_statement:
label:
token : current
after : current
variable_declaration:
shared_keyword:
token : current
after : current
variable_keyword:
token : current
after : current
wait_statement:
label:
token : current
after : current
wait_keyword:
token : current
after : current

View File

@ -2,34 +2,8 @@
from vsg import parser
from vsg import token
from vsg.vhdlFile.indent import loop_statement
from vsg.vhdlFile.indent import function_specification
from vsg.vhdlFile.indent import procedure_specification
from vsg.vhdlFile.indent import interface_element
from vsg.vhdlFile.indent import generate_statement
from vsg.vhdlFile.indent import generic_clause
from vsg.vhdlFile.indent import port_clause
from vsg.vhdlFile.indent import if_statement
from vsg.vhdlFile.indent import package_body
from vsg.vhdlFile.indent import package_declaration
from vsg.vhdlFile.indent import simple_signal_assignment
from vsg.vhdlFile.indent import signal_declaration
from vsg.vhdlFile.indent import subtype_declaration
from vsg.vhdlFile.indent import type_declaration
from vsg.vhdlFile.indent import variable_declaration
from vsg.vhdlFile.indent import variable_assignment_statement
from vsg.vhdlFile.indent import wait_statement
from vsg.vhdlFile.indent import component_instantiation_statement
from vsg.vhdlFile.indent import generic_map_aspect
from vsg.vhdlFile.indent import port_map_aspect
from vsg.vhdlFile.indent import association_element
from vsg.vhdlFile.indent import block_statement
from vsg.vhdlFile.indent import concurrent_procedure_call_statement
from vsg.vhdlFile.indent import procedure_call_statement
from vsg.vhdlFile.indent import procedure_call
def set_token_indent(lTokens):
def set_token_indent(dIndentMap, lTokens):
'''
Set the indent level of tokens.
'''
@ -41,29 +15,11 @@ def set_token_indent(lTokens):
dVars['insideConcurrentSignalAssignment'] = False
for oToken in lTokens:
if isinstance(oToken, parser.whitespace):
continue
if isinstance(oToken, parser.blank_line):
bLibraryFound = False
continue
if isinstance(oToken, parser.carriage_return):
continue
if isinstance(oToken, token.context_declaration.context_keyword):
oToken.set_indent(0)
iIndent += 1
continue
if isinstance(oToken, token.context_declaration.end_keyword):
oToken.set_indent(0)
iIndent -= 1
bLibraryFound = False
continue
if isinstance(oToken, token.library_clause.keyword):
oToken.set_indent(iIndent)
bLibraryFound = True
continue
@ -81,148 +37,14 @@ def set_token_indent(lTokens):
oToken.set_indent(iIndent)
continue
if isinstance(oToken, token.entity_declaration.entity_keyword):
oToken.set_indent(iIndent)
iIndent += 1
continue
if isinstance(oToken, token.entity_declaration.end_keyword):
iIndent -= 1
oToken.set_indent(iIndent)
continue
if isinstance(oToken, token.architecture_body.architecture_keyword):
oToken.set_indent(0)
iIndent = 1
bArchitectureFound = True
continue
if isinstance(oToken, token.architecture_body.begin_keyword):
oToken.set_indent(0)
iIndent = 1
continue
if isinstance(oToken, token.architecture_body.end_keyword):
oToken.set_indent(0)
iIndent = 0
continue
if isinstance(oToken, token.architecture_body.semicolon):
bArchitectureFound = False
continue
### Assertion statements
if isinstance(oToken, token.concurrent_assertion_statement.label_name):
oToken.set_indent(iIndent)
bLabelFound = True
iIndent += 1
continue
if isinstance(oToken, token.assertion_statement.label):
oToken.set_indent(iIndent)
bLabelFound = True
iIndent += 1
continue
if isinstance(oToken, token.assertion.keyword):
if not bLabelFound:
oToken.set_indent(iIndent)
iIndent += 1
bLabelFound = False
continue
if isinstance(oToken, token.assertion.report_keyword):
oToken.set_indent(iIndent)
continue
if isinstance(oToken, token.assertion.severity_keyword):
oToken.set_indent(iIndent)
continue
if isinstance(oToken, token.assertion_statement.semicolon):
iIndent -= 1
continue
if isinstance(oToken, token.concurrent_assertion_statement.semicolon):
iIndent -= 1
continue
### Attribute statements
if isinstance(oToken, token.attribute_declaration.attribute_keyword):
oToken.set_indent(iIndent)
continue
if isinstance(oToken, token.attribute_specification.attribute_keyword):
oToken.set_indent(iIndent)
continue
### case statements
if isinstance(oToken, token.case_statement.case_label):
oToken.set_indent(iIndent)
bLabelFound = True
iIndent += 1
continue
if isinstance(oToken, token.case_statement.case_keyword):
if not bLabelFound:
oToken.set_indent(iIndent)
iIndent += 2
bLabelFound = False
continue
if isinstance(oToken, token.case_statement_alternative.when_keyword):
oToken.set_indent(iIndent - 1)
continue
if isinstance(oToken, token.case_statement.end_keyword):
oToken.set_indent(iIndent - 2)
iIndent -= 2
continue
### process statements
if isinstance(oToken, token.process_statement.process_label):
oToken.set_indent(iIndent)
bLabelFound = True
iIndent += 1
continue
if isinstance(oToken, token.process_statement.postponed_keyword):
if not bLabelFound:
oToken.set_indent(iIndent)
iIndent += 1
bLabelFound = True
else:
oToken.set_indent(iIndent - 1)
continue
if isinstance(oToken, token.process_statement.process_keyword):
if not bLabelFound:
oToken.set_indent(iIndent)
iIndent += 1
else:
oToken.set_indent(iIndent - 1)
bLabelFound = False
continue
if isinstance(oToken, token.process_statement.begin_keyword):
oToken.set_indent(iIndent - 1)
continue
if isinstance(oToken, token.process_statement.end_keyword):
oToken.set_indent(iIndent - 1)
iIndent -= 1
continue
### Null statements
if isinstance(oToken, token.null_statement.label):
oToken.set_indent(iIndent)
continue
if isinstance(oToken, token.null_statement.null_keyword):
oToken.set_indent(iIndent)
continue
### Comments
if isinstance(oToken, parser.comment):
if bLibraryFound:
@ -231,40 +53,24 @@ def set_token_indent(lTokens):
oToken.set_indent(iIndent)
continue
### Components
if isinstance(oToken, token.component_declaration.component_keyword):
oToken.set_indent(iIndent)
iIndent += 1
continue
if isinstance(oToken, token.component_declaration.end_keyword):
iIndent -= 1
oToken.set_indent(iIndent)
continue
### Concurrent signal assignment
if isinstance(oToken, token.concurrent_signal_assignment_statement.label_name):
oToken.set_indent(iIndent)
dVars['insideConcurrentSignalAssignment'] = True
continue
if isinstance(oToken, token.concurrent_signal_assignment_statement.postponed_keyword):
oToken.set_indent(iIndent)
dVars['insideConcurrentSignalAssignment'] = True
continue
if isinstance(oToken, token.concurrent_simple_signal_assignment.target):
oToken.set_indent(iIndent)
dVars['insideConcurrentSignalAssignment'] = True
continue
if isinstance(oToken, token.concurrent_conditional_signal_assignment.target):
oToken.set_indent(iIndent)
dVars['insideConcurrentSignalAssignment'] = True
continue
if isinstance(oToken, token.concurrent_selected_signal_assignment.with_keyword):
oToken.set_indent(iIndent)
dVars['insideConcurrentSignalAssignment'] = True
continue
@ -280,51 +86,127 @@ def set_token_indent(lTokens):
dVars['insideConcurrentSignalAssignment'] = False
continue
### Constant declaration
if isinstance(oToken, token.constant_declaration.constant_keyword):
oToken.set_indent(iIndent)
def set_token_indent(dIndentMap, lTokens):
lTokenKeys, dIndents = process_indent_map(dIndentMap)
iIndent = 0
bLibraryFound = False
bArchitectureFound = False
dVars = {}
dVars['insideConcurrentSignalAssignment'] = False
for oToken in lTokens:
if isinstance(oToken, parser.whitespace):
continue
### Variable declaration
if isinstance(oToken, token.variable_declaration.variable_keyword):
oToken.set_indent(iIndent)
if isinstance(oToken, parser.blank_line):
bLibraryFound = False
continue
### File declaration
if isinstance(oToken, token.file_declaration.file_keyword):
oToken.set_indent(iIndent)
if isinstance(oToken, parser.carriage_return):
continue
if isinstance(oToken, token.file_open_information.open_keyword):
oToken.set_indent(iIndent + 1)
sUniqueId = oToken.get_unique_id(sJoin=':')
if sUniqueId in lTokenKeys:
token_key = dIndents[sUniqueId]['token']
after_key = dIndents[sUniqueId]['after']
iTokenIndent = update_indent_var(iIndent, token_key)
oToken.set_indent(iTokenIndent)
iIndent = update_indent_var(iIndent, after_key)
if isinstance(oToken, token.context_declaration.end_keyword):
bLibraryFound = False
continue
if isinstance(oToken, token.file_open_information.is_keyword):
oToken.set_indent(iIndent + 1)
if isinstance(oToken, token.library_clause.keyword):
bLibraryFound = True
continue
iIndent, bLabelFound = loop_statement.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = procedure_specification.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = function_specification.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = interface_element.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = generate_statement.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = generic_clause.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = port_clause.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = if_statement.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = package_body.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = package_declaration.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = simple_signal_assignment.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = signal_declaration.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = subtype_declaration.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = type_declaration.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = variable_declaration.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = variable_assignment_statement.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = wait_statement.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = component_instantiation_statement.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = generic_map_aspect.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = port_map_aspect.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = association_element.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = block_statement.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = concurrent_procedure_call_statement.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = procedure_call_statement.set_indent(iIndent, bLabelFound, oToken)
iIndent, bLabelFound = procedure_call.set_indent(iIndent, bLabelFound, oToken)
if isinstance(oToken, token.use_clause.keyword):
if not bArchitectureFound:
oToken.set_indent(iIndent + 1)
else:
oToken.set_indent(iIndent)
continue
if isinstance(oToken, token.context_reference.keyword):
if bLibraryFound:
oToken.set_indent(iIndent + 1)
else:
oToken.set_indent(iIndent)
continue
if isinstance(oToken, token.architecture_body.architecture_keyword):
bArchitectureFound = True
continue
if isinstance(oToken, token.architecture_body.semicolon):
bArchitectureFound = False
continue
### Comments
if isinstance(oToken, parser.comment):
if bLibraryFound:
oToken.set_indent(iIndent + 1)
elif not dVars['insideConcurrentSignalAssignment']:
oToken.set_indent(iIndent)
continue
### Concurrent signal assignment
if isinstance(oToken, token.concurrent_signal_assignment_statement.label_name):
dVars['insideConcurrentSignalAssignment'] = True
continue
if isinstance(oToken, token.concurrent_signal_assignment_statement.postponed_keyword):
dVars['insideConcurrentSignalAssignment'] = True
continue
if isinstance(oToken, token.concurrent_simple_signal_assignment.target):
dVars['insideConcurrentSignalAssignment'] = True
continue
if isinstance(oToken, token.concurrent_conditional_signal_assignment.target):
dVars['insideConcurrentSignalAssignment'] = True
continue
if isinstance(oToken, token.concurrent_selected_signal_assignment.with_keyword):
dVars['insideConcurrentSignalAssignment'] = True
continue
if isinstance(oToken, token.concurrent_simple_signal_assignment.semicolon):
dVars['insideConcurrentSignalAssignment'] = False
continue
if isinstance(oToken, token.concurrent_conditional_signal_assignment.semicolon):
dVars['insideConcurrentSignalAssignment'] = False
continue
if isinstance(oToken, token.concurrent_selected_signal_assignment.semicolon):
dVars['insideConcurrentSignalAssignment'] = False
continue
def update_indent_var(iIndent, update):
if str(update).startswith('+'):
return iIndent + int(update)
if str(update).startswith('-'):
return iIndent + int(update)
if update == 'current':
return iIndent
return update
def process_indent_map(dIndentMap):
dReturn = {}
lTopKeys = list(dIndentMap['indent']['tokens'].keys())
for sTopKey in lTopKeys:
lSubKeys = list(dIndentMap['indent']['tokens'][sTopKey].keys())
for sSubKey in lSubKeys:
sUniqueId = sTopKey + ':' + sSubKey
dReturn[sUniqueId] = dIndentMap['indent']['tokens'][sTopKey][sSubKey]
lReturn = list(dReturn.keys())
return lReturn, dReturn

View File

@ -51,6 +51,7 @@ class vhdlFile():
self.lAllObjects = []
self._processFile()
self.filename = None
self.dIndentMap = None
def _processFile(self):
@ -72,14 +73,8 @@ class vhdlFile():
design_file.tokenize(self.lAllObjects)
post_token_assignments(self.lAllObjects)
self.set_token_indent()
set_token_hierarchy_value(self.lAllObjects)
self.oTokenMap = process_tokens(self.lAllObjects)
# lIndex = self.oTokenMap.get_token_indexes(token.library_clause.keyword)
# print(lIndex)
# for iIndex in lIndex:
# print(self.oTokenMap.get_line_number_of_index(iIndex))
# exit()
def update(self, lUpdates):
if len(lUpdates) == 0:
@ -98,6 +93,13 @@ class vhdlFile():
if bUpdateMap:
self.oTokenMap = process_tokens(self.lAllObjects)
def set_indent_map(self, dIndentMap):
self.dIndentMap = dIndentMap
set_token_indent(self.dIndentMap, self.lAllObjects)
def get_indent_map(self):
return self.dIndentMap
def get_object_lines(self):
lReturn = []
lReturn.append('')
@ -122,7 +124,7 @@ class vhdlFile():
self.lAllObjects = utils.fix_blank_lines(self.lAllObjects)
def set_token_indent(self):
set_token_indent(self.lAllObjects)
set_token_indent(self.dIndentMap, self.lAllObjects)
def get_line_preceeding_line(self, iLine, iNumLines=1):
return extract.get_line_preceeding_line(iLine, self.lAllObjects, iNumLines, self.oTokenMap)