Skip to content

Commit 1f4b344

Browse files
Changed gutter color (using other available sublime scopes) for errors and unused variable features, added new test, updated .travis.yml and CONTRIBUTING.md, updated flow_cli.py, vue projects can now choose template
1 parent 8f9e147 commit 1f4b344

File tree

14 files changed

+112
-29
lines changed

14 files changed

+112
-29
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ install:
2525
fi
2626
- sh travis.sh bootstrap
2727
- sh travis.sh install_color_scheme_unit
28+
- sh travis.sh install_keypress
2829
- sh travis.sh install_terminal_view_package
2930

3031
script:

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Working on your first Pull Request? You can learn how from this *free* series, [
1616

1717
## Submitting code
1818

19-
Any code change should be submitted as a pull request. Please, before submit it, run the tests using the [UnitTesting](https://github.com/SublimeText/UnitTesting) Sublime Text package. The description should explain what the code does and give steps to execute it. If necessary, the description should also contain screenshots showing up the new behaviour. The pull request should also contain tests.
19+
Any code change should be submitted as a pull request. Please, before submit it, run the tests using the [UnitTesting](https://github.com/SublimeText/UnitTesting) Sublime Text package (in this case you need to install manually also this package: [Keypress](https://github.com/randy3k/Keypress)). The description should explain what the code does and give steps to execute it. If necessary, the description should also contain screenshots showing up the new behaviour. The pull request should also contain tests.
2020
When you are changing the code of this plugin, I recommend to use [AutomaticPackageReloader](https://github.com/randy3k/AutomaticPackageReloader) to test quickly the new changes. It automatically reload submodules while developing a Sublime Text package without the need of reopening the editor.
2121

2222
## Code review process

changelog/0.16.0.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ v0.16.0
1919
- Improved completions detection from default_autocomplete.json
2020
- Added flow warnings
2121

22+
## Misc
23+
- Changed gutter color (using other available sublime scopes) for errors and unused variable features.
2224

2325
=================================================================
2426
** THIS PLUGIN IS IN BETA! Thanks for your support in advance! **

main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ def plugin_unloaded():
164164
global fixPathSettings
165165
fixPathSettings.clear_on_change('fixpath-reload')
166166

167-
node = NodeJS(check_local=True)
168-
sublime.set_timeout_async(lambda: node.execute("flow", ["stop"], is_from_bin=True, chdir=FLOW_DEFAULT_CONFIG_PATH))
169-
167+
flow_ide_clients_copy = flow_ide_clients.copy()
168+
for root, client in flow_ide_clients_copy.items():
169+
flow_ide_clients[root].stop()
170+
flow_cli = FlowCLI(None)
171+
flow_cli.stop(root=root)
170172

171173
def plugin_loaded():
172174

src/commands/project/vue/main.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
from ....libs import Hook
88

99
def vue_ask_custom_path(project_path, type):
10-
sublime.active_window().show_input_panel("Vue CLI custom path", "vue", lambda vue_custom_path: vue_prepare_project(project_path, vue_custom_path) if type == "create_new_project" or type == "add_project_type" else add_vue_settings(project_path, vue_custom_path), None, None)
10+
11+
def vue_ask_project_template(project_path, vue_custom_path):
12+
sublime.active_window().show_input_panel("Vue project template", "webpack", lambda vue_project_template: vue_prepare_project(project_path, vue_custom_path, vue_project_template), None, None)
13+
14+
sublime.active_window().show_input_panel("Vue CLI custom path", "vue", lambda vue_custom_path: vue_ask_project_template(project_path, vue_custom_path) if type == "create_new_project" or type == "add_project_type" else add_vue_settings(project_path, vue_custom_path), None, None)
1115

1216
def add_vue_settings(working_directory, vue_custom_path):
1317
project_path = working_directory
@@ -44,16 +48,16 @@ def add_vue_settings(working_directory, vue_custom_path):
4448
with open(vue_settings, 'w+', encoding="utf-8") as file:
4549
file.write(json.dumps(default_config, indent=2))
4650

47-
def vue_prepare_project(project_path, vue_custom_path):
51+
def vue_prepare_project(project_path, vue_custom_path, vue_project_template):
4852

4953
terminal = Terminal(cwd=project_path)
5054

5155
if sublime.platform() != "windows":
5256
open_project = ["&&", shlex.quote(util.sublime_executable_path()), shlex.quote(util.get_project_settings(project_path)["project_file_name"])] if not util.is_project_open(util.get_project_settings(project_path)["project_file_name"]) else []
53-
terminal.run([shlex.quote(vue_custom_path), "init", "webpack", "."] + open_project)
57+
terminal.run([shlex.quote(vue_custom_path), "init", vue_project_template, "."] + open_project)
5458
else:
5559
open_project = [util.sublime_executable_path(), util.get_project_settings(project_path)["project_file_name"], "&&", "exit"] if not util.is_project_open(util.get_project_settings(project_path)["project_file_name"]) else []
56-
terminal.run([vue_custom_path, "init", "webpack", "."])
60+
terminal.run([vue_custom_path, "init", vue_project_template, "."])
5761
if open_project:
5862
terminal.run(open_project)
5963

src/commands/refactor/safe_delete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sublime, sublime_plugin
2-
import os, shutil, traceback, json
2+
import os, traceback, json
33
from ...libs import util
44
from ...libs import window_view_manager
55
from ...libs import FlowCLI

src/libs/flow/flow_cli.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,45 @@ def get_imports(self, files=[], options=[], **kwargs):
246246

247247
return result
248248

249+
def stop(self, root=FLOW_DEFAULT_CONFIG_PATH, options=[], **kwargs):
250+
251+
self.flow_cli = "flow"
252+
self.is_from_bin = True
253+
self.chdir = root
254+
self.use_node = True
255+
self.bin_path = ""
256+
257+
settings = util.get_project_settings(project_dir_name=root)
258+
if settings and settings["project_settings"]["flow_cli_custom_path"]:
259+
self.flow_cli = os.path.basename(settings["project_settings"]["flow_cli_custom_path"])
260+
self.bin_path = os.path.dirname(settings["project_settings"]["flow_cli_custom_path"])
261+
self.is_from_bin = False
262+
self.chdir = settings["project_dir_name"]
263+
self.use_node = False
264+
265+
node = NodeJS(check_local=True)
266+
267+
result = node.execute(
268+
self.flow_cli,
269+
[
270+
'stop',
271+
'--from', 'sublime_text',
272+
'./'
273+
] + options,
274+
is_from_bin=self.is_from_bin,
275+
chdir=self.chdir,
276+
bin_path=self.bin_path,
277+
use_node=self.use_node
278+
)
279+
280+
return result
281+
249282
@staticmethod
250283
def parse_cli_dependencies(view, **kwargs):
284+
251285
filename = view.file_name()
252-
253286
project_settings = util.get_project_settings()
287+
254288
if project_settings:
255289
project_root = project_settings["project_dir_name"]
256290
else:

src/libs/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def execute(self, command, command_args, is_from_bin=False, chdir="", wait_termi
5353
args = ([self.node_js_path] if use_node else []) + [os.path.join( (bin_path or NODE_MODULES_BIN_PATH), command)] + command_args
5454
else :
5555
args = ([self.node_js_path] if use_node else []) + [os.path.join( (bin_path or NODE_MODULES_BIN_PATH), command)] + command_args
56-
56+
5757
return util.execute(args[0], args[1:], chdir=chdir, wait_terminate=wait_terminate, func_stdout=func_stdout, args_func_stdout=args_func_stdout)
5858

5959
def execute_check_output(self, command, command_args, is_from_bin=False, use_fp_temp=False, use_only_filename_view_flow=False, fp_temp_contents="", is_output_json=False, chdir="", clean_output_flow=False, bin_path="", use_node=True, command_arg_escape=True) :
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"id": "tools", "children": [{"id": "npm_scripts", "children": [], "caption": "Npm/Yarn Scripts"}], "caption": "Tools"}]
1+
[{"id": "tools", "caption": "Tools", "children": [{"id": "npm_scripts", "caption": "Npm/Yarn Scripts", "children": []}]}]

src/listeners/show_flow_errors.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
class JavascriptEnhancementsShowFlowErrorsViewEventListener(JavascriptEnhancementsWaitModifiedAsyncViewEventListener, sublime_plugin.ViewEventListener):
1515

16-
description_by_row = {}
1716
description_by_row_column = {}
1817
diagnostics = {
1918
"error": [],
@@ -23,6 +22,10 @@ class JavascriptEnhancementsShowFlowErrorsViewEventListener(JavascriptEnhancemen
2322
"error": [],
2423
"warning": []
2524
}
25+
diagnostic_scope = {
26+
"error": "storage",
27+
"warning": "keyword"
28+
}
2629
callback_setted_use_flow_checker_on_current_view = False
2730
prefix_thread_name = "javascript_enhancements_show_flow_errors_view_event_listener"
2831
wait_time = .15
@@ -128,7 +131,6 @@ def on_modified_async_with_thread(self, recheck=True):
128131
"error": [],
129132
"warning": []
130133
}
131-
self.description_by_row = {}
132134
self.description_by_row_column = {}
133135

134136
if result[0] and len(result[1]['errors']) > 0:
@@ -166,15 +168,6 @@ def on_modified_async_with_thread(self, recheck=True):
166168
description += " " + message['descr']
167169

168170
if row >= 0 :
169-
row_description = self.description_by_row.get(row)
170-
if not row_description:
171-
self.description_by_row[row] = {
172-
"col": col,
173-
"description": description
174-
}
175-
if row_description and description not in row_description:
176-
self.description_by_row[row]["description"] += '; ' + description
177-
178171
self.description_by_row_column[str(row)+":"+str(endrow)+":"+str(col)+":"+str(endcol)+":"+error_level] = description
179172

180173
if not self.modified :
@@ -186,7 +179,7 @@ def on_modified_async_with_thread(self, recheck=True):
186179

187180
if value:
188181

189-
view.add_regions( 'javascript_enhancements_flow_' + key, value, 'keyword', 'dot', sublime.DRAW_SQUIGGLY_UNDERLINE | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE )
182+
view.add_regions( 'javascript_enhancements_flow_' + key, value, self.diagnostic_scope[key], 'dot', sublime.DRAW_SQUIGGLY_UNDERLINE | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE )
190183

191184
if not need_update_sublime_status:
192185
need_update_sublime_status = True

0 commit comments

Comments
 (0)