Skip to content

Commit

Permalink
improved unused variable feature #24
Browse files Browse the repository at this point in the history
  • Loading branch information
pichillilorenzo committed Mar 11, 2018
1 parent 7bac4f0 commit 7c1d98b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/0.16.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ v0.16.0
- Improved extract method feature
- Improved completions detection from default_autocomplete.json
- Added flow warnings
- Improved unused variable feature

## Misc
- Changed gutter color (using other available sublime scopes) for errors and unused variable features.
Expand Down
5 changes: 4 additions & 1 deletion src/listeners/show_unused_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def on_modified_async_with_thread(self, recheck=True):

repetitions[variable_name] = [variable_region]

items = util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression", "JSXIdentifier", "ExportDefaultDeclaration", "JSXExpressionContainer", "NewExpression", "ReturnStatement", "SpreadProperty", "TemplateLiteral", "ObjectPattern"], body)
items = util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression", "JSXIdentifier", "ExportDefaultDeclaration", "JSXExpressionContainer", "NewExpression", "ReturnStatement", "SpreadProperty", "TemplateLiteral", "ObjectPattern", "ObjectExpression"], body)
for item in items:

if "exportKind" in item and "declaration" in item and isinstance(item["declaration"],dict) and "name" in item["declaration"] and item["declaration"]["type"] == "Identifier":
Expand Down Expand Up @@ -182,6 +182,9 @@ def on_modified_async_with_thread(self, recheck=True):
elif "expression" in item and isinstance(item["expression"],dict) and "name" in item["expression"] and item["expression"]["type"] == "Identifier":
item = item["expression"]

elif "expression" in item and isinstance(item["expression"],dict) and item["expression"]["type"] == "TaggedTemplateExpression" and "tag" in item["expression"]:
item = item["expression"]["tag"]

elif "argument" in item and isinstance(item["argument"],dict) and "name" in item["argument"] and item["argument"]["type"] == "Identifier":
item = item["argument"]

Expand Down

0 comments on commit 7c1d98b

Please sign in to comment.