Skip to content

Commit f42af12

Browse files
code refactoring, fixed an issue about go-to-definition, added flow warnings
1 parent 012dcd9 commit f42af12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1010
-1353
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ before_install:
2121
install:
2222
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
2323
brew update;
24-
brew upgrade python;
24+
brew install python || brew upgrade python;
2525
fi
2626
- sh travis.sh bootstrap
2727
- sh travis.sh install_color_scheme_unit
@@ -35,6 +35,4 @@ after_success:
3535
- codecov
3636

3737
notifications:
38-
email:
39-
on_success: change
40-
on_failure: change
38+
email: false

Default.sublime-keymap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
{
2121
"keys": ["super+alt+g"],
22-
"command": "javascript_enhancements_go_to_def"
22+
"command": "javascript_enhancements_go_to_definition"
2323
},
2424
{
2525
"keys": ["super+alt+s"],

LICENSE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Lorenzo Pichilli
3+
Copyright (c) 2017-2018 Lorenzo Pichilli
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ If you want use this plugin, you may want **uninstall/disable** the **JavaScript
4747
In order to work properly, this plugin has some dependencies:
4848

4949
- **Sublime Text 3** (build **3124** or newer)
50-
- **Node.js** and **npm** ([nodejs.org](https://nodejs.org) or [nvm](https://github.com/creationix/nvm))
50+
- **Node.js** (6 or upper) and **npm** ([nodejs.org](https://nodejs.org) or [nvm](https://github.com/creationix/nvm))
5151
- **TerminalView** (only for _Linux_ and _Mac OS X_) sublime text plugin ([TerminalView](https://github.com/Wramberg/TerminalView))
5252

5353
**Not required**, but **useful** for typescript files (Flow wont work on this type of files):

changelog/0.16.0.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ v0.16.0
1111
## Improvements
1212

1313
- Complete code plugin refactoring
14-
- Improved completions performance
14+
- Improved completions performance using 'flow ide' command
1515
- Added "code screenshot" feature using [carbon](https://carbon.now.sh/)
1616
- updated flow-bin to 0.66.0
1717
- Added initial support for Vue.js
1818
- Improved extract method feature
1919
- Improved completions detection from default_autocomplete.json
20+
- Added flow warnings
2021

2122

2223
=================================================================

main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import os, platform, shutil, tempfile, json, re, sys
33
from subprocess import Popen, PIPE
44
from .src.libs.global_vars import *
5-
from .src.libs.flow import *
65
from .src.libs import util
76
from .src.libs import *
87
from .src.commands import *
98
from .src.listeners import *
9+
from .tests import *
1010

1111
keymaps = util.open_json(os.path.join(PACKAGE_PATH, 'Default.sublime-keymap'))
1212
for keymap in keymaps:
@@ -87,6 +87,8 @@ def start():
8787
shutil.rmtree(node_modules_path)
8888
sublime.error_message("Error during installation: can't install npm dependencies for JavaScript Enhancements plugin.\n\nThe error COULD be caused by the npm permission access (EACCES error), so in this case you need to repair/install node.js and npm in a way that doesn't require \"sudo\" command.\n\nFor example you could use a Node Version Manager, such as \"nvm\" or \"nodenv\".\n\nTry to run \"npm install\" inside the package of this plugin to see what you get.")
8989
return
90+
91+
Hook.apply('plugin_ready')
9092

9193
sublime.set_timeout_async(lambda: util.overwrite_default_javascript_snippet())
9294

src/commands/bookmarks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,4 @@ def is_visible(self):
238238
return util.is_javascript_project()
239239

240240
class JavascriptEnhancementsNavigateProjectBookmarksCommand(JavascriptEnhancementsNavigateRegionsCommand, sublime_plugin.TextCommand):
241-
region_key = "javascript_enhancements_region_bookmarks"
241+
region_keys = ["javascript_enhancements_region_bookmarks"]

src/commands/can_i_use/can_i_use_data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/commands/go_to_definition.py

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
from ..libs import NodeJS
44
from ..libs import util
5-
from ..libs import flow
5+
from ..libs import FlowCLI
66

77
class JavascriptEnhancementsGoToDefinitionCommand(sublime_plugin.TextCommand):
88
def run(self, edit, **args):
@@ -26,50 +26,16 @@ def go_to_def(self, view, point):
2626
def find_def(self, view, point) :
2727
view.sel().add(point)
2828

29-
flow_cli = "flow"
30-
is_from_bin = True
31-
chdir = ""
32-
use_node = True
33-
bin_path = ""
34-
35-
settings = util.get_project_settings()
36-
if settings and settings["project_settings"]["flow_cli_custom_path"]:
37-
flow_cli = os.path.basename(settings["project_settings"]["flow_cli_custom_path"])
38-
bin_path = os.path.dirname(settings["project_settings"]["flow_cli_custom_path"])
39-
is_from_bin = False
40-
chdir = settings["project_dir_name"]
41-
use_node = False
42-
43-
deps = flow.parse_cli_dependencies(view)
44-
45-
node = NodeJS(check_local=True)
46-
47-
result = node.execute_check_output(
48-
flow_cli,
49-
[
50-
'get-def',
51-
'--from', 'sublime_text',
52-
'--root', deps.project_root,
53-
'--json',
54-
':temp_file',
55-
str(deps.row + 1), str(deps.col + 1)
56-
],
57-
is_from_bin=is_from_bin,
58-
use_fp_temp=True,
59-
fp_temp_contents=deps.contents,
60-
is_output_json=True,
61-
use_only_filename_view_flow=True,
62-
chdir=chdir,
63-
bin_path=bin_path,
64-
use_node=use_node
65-
)
29+
flow_cli = FlowCLI(view)
30+
result = flow_cli.get_def()
6631

6732
if result[0] :
6833
row = result[1]["line"] - 1
6934
col = result[1]["start"] - 1
70-
if result[1]["path"] != "-" and os.path.isfile(result[1]["path"]) :
71-
view = sublime.active_window().open_file(result[1]["path"])
72-
util.go_to_centered(view, row, col)
35+
if row >= 0:
36+
if result[1]["path"] != "-" and os.path.isfile(result[1]["path"]) :
37+
view = sublime.active_window().open_file(result[1]["path"])
38+
util.go_to_centered(view, row, col)
7339

7440
def is_enabled(self, **args):
7541
view = self.view

src/commands/navigate_flow_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .navigate_regions import JavascriptEnhancementsNavigateRegionsCommand
33

44
class JavascriptEnhancementsNavigateFlowErrorsCommand(JavascriptEnhancementsNavigateRegionsCommand, sublime_plugin.TextCommand):
5-
region_key = "javascript_enhancements_flow_error"
5+
region_keys = ["javascript_enhancements_flow_error", "javascript_enhancements_flow_warning"]

0 commit comments

Comments
 (0)