Skip to content

Commit 2d9608f

Browse files
fix #20, added a message in the status bar in case of a subprocess.CalledProcessError error
1 parent 31cfb40 commit 2d9608f

File tree

7 files changed

+141
-12
lines changed

7 files changed

+141
-12
lines changed

_generated_2018_01_22_at_20_28_21.py renamed to _generated_2018_01_23_at_00_15_41.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from shutil import copyfile
44
from threading import Timer
55

6-
PLUGIN_VERSION = "0.13.12"
6+
PLUGIN_VERSION = "0.13.13"
77

88
PACKAGE_PATH = os.path.abspath(os.path.dirname(__file__))
99
PACKAGE_NAME = os.path.basename(PACKAGE_PATH)
@@ -231,7 +231,7 @@ def execute_check_output(self, command, command_args, is_from_bin=False, use_fp_
231231

232232
# update the PATH environment variable
233233
os.environ.update(new_env)
234-
234+
235235
try:
236236
output = None
237237
result = None
@@ -272,7 +272,7 @@ def execute_check_output(self, command, command_args, is_from_bin=False, use_fp_
272272
# out[0] = out[0].replace("Started a new flow server: -", "")
273273
# out = "\n".join(out)
274274
# result = json.loads(out) if is_output_json else out
275-
out = out[ len(out) - 1 ]
275+
out = out[-1]
276276
if '{"flowVersion":"' in out :
277277
index = out.index('{"flowVersion":"')
278278
out = out[index:]
@@ -289,10 +289,19 @@ def execute_check_output(self, command, command_args, is_from_bin=False, use_fp_
289289

290290
if use_fp_temp :
291291
fp.close()
292+
292293
return [True, result]
293294
except subprocess.CalledProcessError as e:
294295
print(traceback.format_exc())
295296

297+
if e.output:
298+
output_error_message = e.output.decode("utf-8", "ignore").strip()
299+
output_error_message = output_error_message.split("\n")
300+
output_error_message = "\n".join(output_error_message[:-2]) if '{"flowVersion":"' in output_error_message[-1] else "\n".join(output_error_message)
301+
302+
print(e.output)
303+
sublime.active_window().status_message(output_error_message)
304+
296305
# reset the PATH environment variable
297306
os.environ.update(old_env)
298307

@@ -5538,6 +5547,7 @@ def on_modified_async_with_thread(self, recheck=True):
55385547
repetitions = dict()
55395548

55405549
if result[0]:
5550+
55415551
if "body" in result[1]:
55425552
body = result[1]["body"]
55435553
items = Util.nested_lookup("type", ["VariableDeclarator", "FunctionDeclaration", "ClassDeclaration", "ImportDefaultSpecifier", "ImportNamespaceSpecifier", "ImportSpecifier", "ArrayPattern", "ObjectPattern"], body)
@@ -5584,10 +5594,13 @@ def on_modified_async_with_thread(self, recheck=True):
55845594

55855595
repetitions[variableName] = [variableRegion]
55865596

5587-
items = Util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression"], body)
5597+
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"], body)
55885598
for item in items:
55895599

5590-
if "object" in item :
5600+
if "exportKind" in item and "declaration" in item and isinstance(item["declaration"],dict) and "name" in item["declaration"] and item["declaration"]["type"] == "Identifier":
5601+
item = item["declaration"]
5602+
5603+
elif "object" in item :
55915604
if "property" in item and isinstance(item["property"],dict) and "name" in item["property"] and item["property"]["type"] == "Identifier":
55925605
items += [item["property"]]
55935606
if "object" in item and isinstance(item["object"],dict) and "name" in item["object"] and item["object"]["type"] == "Identifier":

changelog/0.13.13.txt

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
v0.13.13
2+
3+
## Fixes
4+
5+
- Fixed "Unused variable shows up in React project" #20
6+
7+
## Improvements
8+
9+
- Added a message in the status bar in case of a subprocess.CalledProcessError error. For example, it could be caused by a malformed .flowconfig in a project.
10+
11+
12+
13+
=================================================================
14+
** THIS PLUGIN IS IN BETA! Thanks for your support in advance! **
15+
=================================================================
16+
17+
If you like it, remember to star it ⭐ on GitHub: https://github.com/pichillilorenzo/JavaScriptEnhancements
18+
19+
** USAGE **
20+
===========
21+
22+
See how it works on the Wiki: 👉👉 https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki 👈👈
23+
24+
25+
** WHAT IS THIS? **
26+
===================
27+
28+
This plugin uses Flow (javascript static type checker from Facebook) under the hood.
29+
30+
It offers better javascript autocomplete and a lot of features about creating,
31+
developing and managing javascript projects, such as:
32+
33+
- Cordova projects (run cordova emulate, build, compile, serve, etc. directly from Sublime Text!)
34+
- Ionic v1 and v2 projects (same as Cordova projects!)
35+
- Angular v1 and v2 projects
36+
- React projects (only about the creation at this moment)
37+
- React Native projects (only about the creation at this moment. I will add also NativeScript support)
38+
- Express projects (only about the creation at this moment)
39+
- Yeoman generators
40+
- Local bookmarks project
41+
- JavaScript real-time errors
42+
- etc.
43+
44+
You could use it also in existing projects (see the Wiki - https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki/Using-it-with-an-existing-project)!
45+
46+
It turns Sublime Text into a JavaScript IDE like!
47+
48+
This project is based on my other Sublime Text plugin JavaScript Completions (https://github.com/pichillilorenzo/JavaScript-Completions)
49+
50+
** NOTE **
51+
If you want use this plugin, you may want uninstall/disable the JavaScript Completions plugin, if installed.
52+
53+
** OS SUPPORTED NOW **
54+
======================
55+
56+
👉 Linux (64-bit)
57+
👉 Mac OS X
58+
👉 Windows (64-bit): released without the use of TerminalView plugin. For each feature (like also creating a project) will be used the cmd.exe shell (so during the creation of a project don't close it until it finishes!). Unfortunately the TerminalView plugin supports only Linux-based OS 😞. Has someone any advice or idea about that? Is there something similar to the TerminalView plugin for Windows?? Thanks!
59+
60+
❗❗ Dependencies ❗❗
61+
=======================
62+
63+
In order to work properly, this plugin has some dependencies:
64+
65+
👉 Sublime Text 3 (build 3124 or newer)
66+
👉 Node.js and npm (https://nodejs.org or nvm (https://github.com/creationix/nvm))
67+
👉 TerminalView (only for Linux and Mac OS X) sublime text plugin (https://github.com/Wramberg/TerminalView)
68+
69+
Not required, but useful for typescript files (Flow wont work on this type of files):
70+
71+
👉 TypeScript sublime text plugin (https://github.com/Microsoft/TypeScript-Sublime-Plugin)
72+
73+
** Flow Requirements **
74+
=======================
75+
76+
It use [Flow](https://github.com/facebook/flow) for type checking and auto-completions.
77+
78+
👉 Mac OS X
79+
👉 Linux (64-bit)
80+
👉 Windows (64-bit)
81+
82+
Email me for any questions or doubts about this new project on: pichillilorenzo@gmail.com
83+
84+
** Donation **
85+
==============
86+
87+
If this project help you reduce time to develop and also you like it, please support it with a donation 😄👍. Thanks!
88+
89+
Open Collective: https://opencollective.com/javascriptenhancements/donate
90+
PayPal: https://www.paypal.me/LorenzoPichilli
91+
92+
Thanks anyway for your support! 😄😄
93+
94+
MIT License

changelog/install.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ It use [Flow](https://github.com/facebook/flow) for type checking and auto-compl
6969

7070
Email me for any questions or doubts about this new project on: pichillilorenzo@gmail.com
7171

72-
Thanks for your support! 😄😄
72+
** Donation **
73+
==============
74+
75+
If this project help you reduce time to develop and also you like it, please support it with a donation 😄👍. Thanks!
76+
77+
Open Collective: https://opencollective.com/javascriptenhancements/donate
78+
PayPal: https://www.paypal.me/LorenzoPichilli
79+
80+
Thanks anyway for your support! 😄😄
7381

7482
MIT License

helper/node/main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def execute_check_output(self, command, command_args, is_from_bin=False, use_fp_
100100

101101
# update the PATH environment variable
102102
os.environ.update(new_env)
103-
103+
104104
try:
105105
output = None
106106
result = None
@@ -141,7 +141,7 @@ def execute_check_output(self, command, command_args, is_from_bin=False, use_fp_
141141
# out[0] = out[0].replace("Started a new flow server: -", "")
142142
# out = "\n".join(out)
143143
# result = json.loads(out) if is_output_json else out
144-
out = out[ len(out) - 1 ]
144+
out = out[-1]
145145
if '{"flowVersion":"' in out :
146146
index = out.index('{"flowVersion":"')
147147
out = out[index:]
@@ -158,10 +158,19 @@ def execute_check_output(self, command, command_args, is_from_bin=False, use_fp_
158158

159159
if use_fp_temp :
160160
fp.close()
161+
161162
return [True, result]
162163
except subprocess.CalledProcessError as e:
163164
print(traceback.format_exc())
164165

166+
if e.output:
167+
output_error_message = e.output.decode("utf-8", "ignore").strip()
168+
output_error_message = output_error_message.split("\n")
169+
output_error_message = "\n".join(output_error_message[:-2]) if '{"flowVersion":"' in output_error_message[-1] else "\n".join(output_error_message)
170+
171+
print(e.output)
172+
sublime.active_window().status_message(output_error_message)
173+
165174
# reset the PATH environment variable
166175
os.environ.update(old_env)
167176

helper/unused_variables_view_event_listener.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def on_modified_async_with_thread(self, recheck=True):
9595
repetitions = dict()
9696

9797
if result[0]:
98+
9899
if "body" in result[1]:
99100
body = result[1]["body"]
100101
items = Util.nested_lookup("type", ["VariableDeclarator", "FunctionDeclaration", "ClassDeclaration", "ImportDefaultSpecifier", "ImportNamespaceSpecifier", "ImportSpecifier", "ArrayPattern", "ObjectPattern"], body)
@@ -141,10 +142,13 @@ def on_modified_async_with_thread(self, recheck=True):
141142

142143
repetitions[variableName] = [variableRegion]
143144

144-
items = Util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression"], body)
145+
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"], body)
145146
for item in items:
146147

147-
if "object" in item :
148+
if "exportKind" in item and "declaration" in item and isinstance(item["declaration"],dict) and "name" in item["declaration"] and item["declaration"]["type"] == "Identifier":
149+
item = item["declaration"]
150+
151+
elif "object" in item :
148152
if "property" in item and isinstance(item["property"],dict) and "name" in item["property"] and item["property"]["type"] == "Identifier":
149153
items += [item["property"]]
150154
if "object" in item and isinstance(item["object"],dict) and "name" in item["object"] and item["object"]["type"] == "Identifier":

make/_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from shutil import copyfile
44
from threading import Timer
55

6-
PLUGIN_VERSION = "0.13.12"
6+
PLUGIN_VERSION = "0.13.13"
77

88
PACKAGE_PATH = os.path.abspath(os.path.dirname(__file__))
99
PACKAGE_NAME = os.path.basename(PACKAGE_PATH)

messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"0.13.0": "changelog/0.13.0.txt",
1313
"0.13.1": "changelog/0.13.1.txt",
1414
"0.13.11": "changelog/0.13.11.txt",
15-
"0.13.12": "changelog/0.13.12.txt"
15+
"0.13.12": "changelog/0.13.12.txt",
16+
"0.13.13": "changelog/0.13.13.txt"
1617
}

0 commit comments

Comments
 (0)