Thread Tools Display Modes
06-17-17, 05:57 PM   #21
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Are there any plans to include major libraries written by the community, such as Ace3, LibStub, CBH, LDB, etc?
  Reply With Quote
06-18-17, 02:42 AM   #22
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by myrroddin View Post
Are there any plans to include major libraries written by the community, such as Ace3, LibStub, CBH, LDB, etc?
Sure, the Ace3 would take more time tho.
  Reply With Quote
06-18-17, 03:10 AM   #23
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Completed functions starting with 'E'!

https://pastebin.com/JCwH55hn

As you've said, I've ignored those functions belong to Blizzard frame.

I've tested them all, but will need some review

Last edited by Layback_ : 06-18-17 at 04:11 AM.
  Reply With Quote
06-18-17, 03:30 AM   #24
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Gethe View Post
SublimeLinter and associated plugins are installed via the Sublime Text package manager, like most other ST packages.

The actual luacheck binary can be installed in a few ways, all of which are in the GitHub README. Two of these methods will require you to install a lua interpreter, but they also have a windows .exe that bundles everything needed.


That said, my original main point was that how locals and globals are highlighted should be determined by the user and not a static part of the syntax.
I've managed to make this work (partly).

One question tho, how the hell do i filter what to highlight, since it cries for every little stuff like line length, upvalue and whatever. If you can filter this for only (accessing undefinied variable) that would probably cover the globals, however you still don't know if it's a fucntion or not.
  Reply With Quote
06-18-17, 03:31 AM   #25
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Layback_ View Post
Completed functions starting with 'E'!

https://pastebin.com/JCwH55hn

As you've said, I've ignored those functions that belongs to Blizzard frame.

I've tested them all, but will need some review
Nice i'll look into it. I'm soon to finish the "A" myself.
  Reply With Quote
06-18-17, 04:48 AM   #26
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Resike View Post
Nice i'll look into it. I'm soon to finish the "A" myself.
Looks good, you only missed one function (EJ_GetTierInfo), gonna add em.
  Reply With Quote
06-18-17, 05:16 AM   #27
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by Resike View Post
Looks good, you only missed one function (EJ_GetTierInfo), gonna add em.
Sweet !!
  Reply With Quote
06-18-17, 10:55 AM   #28
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Resike View Post
I've managed to make this work (partly).

One question tho, how the hell do i filter what to highlight, since it cries for every little stuff like line length, upvalue and whatever. If you can filter this for only (accessing undefinied variable) that would probably cover the globals, however you still don't know if it's a fucntion or not.
Okay i managed to make it work:

Code:
cmd = 'luacheck - --formatter=plain --no-unused --no-redefined --no-unused-args --no-unused-secondaries --no-self --no-max-line-length --no-max-code-line-length --no-max-string-line-length --no-max-comment-line-length --codes --ranges --filename @'


However things that i don't like:

- It's sooo slow, i'm not sure why, but it doesn't fit into the Sublime "policy" where everything is lightning fast.
- You can't change colors, you have 1 color for errors and 1 for warnings and thats it. Would be nice to have a separate color for global functions.

But besides that it's nice. I still think a standalone python script would be better or at least faster, also we could have more control over everything of course.
  Reply With Quote
06-18-17, 11:09 AM   #29
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by p3lim View Post
Resike asked me on IRC to make something for highlighting globals, could look like this:

(Yes, io and arg should be highlighted, this was just an example while I work out the kinks)

The only downside is that you'd have to have Lua installed (it don't run Lua scripts, but it requires the Lua compilator to find the globals properly).
Here's the source code for that plugin, I'm discontinuing it for two reasons.

Reason 1: It has a tendency to slow/crash sublime because the Lua compiler can be slow or return errors.
It could be handled, but it's not preferred.

Reason 2: The current method can't match the same global multiple times on one line, which could of course be improved.

Just dumping the code here in public domain in case anyone wants to use it.

Python Code:
  1. import sublime
  2. import sublime_plugin
  3.  
  4. import re
  5. from subprocess import Popen, PIPE
  6.  
  7. def get_luac(contents):
  8.     try:
  9.         process = Popen('luac -p -l -- -', stdin=PIPE, stderr=PIPE, stdout=PIPE, shell=True)
  10.         return process.communicate(input=contents.encode())[0].decode()
  11.     except BrokenPipeError as e:
  12.         return None
  13.  
  14. def get_regions(view):
  15.     regions = []
  16.  
  17.     # get view as a region
  18.     viewContents = sublime.Region(0, view.size())
  19.     # get every line region from the region
  20.     lineRegions = view.lines(viewContents)
  21.     # get every line content from the regions
  22.     lineContents = view.substr(viewContents).split('\n')
  23.  
  24.     # get globals from the current content
  25.     output = get_luac(view.substr(viewContents))
  26.     if not output:
  27.         return regions
  28.  
  29.     # parse each line from luac
  30.     for line in output.split('\n'):
  31.         # clean up the line
  32.         line = ' '.join(line.split())
  33.  
  34.         # match global references
  35.         match = re.match(r'\d+ \[(\d+)\] GETGLOBAL -?\d+ -?\d+ ; (.*)', line)
  36.         if match:
  37.             lineNumber, globalValue = match.groups()
  38.             lineNumber = int(lineNumber) - 1
  39.  
  40.             # sadly, luac doesn't tell us the character
  41.             # positions, so we'll have to grab that ourselves
  42.             region = lineRegions[lineNumber]
  43.             contents = view.substr(region)
  44.             print(contents, '---', globalValue)
  45.  
  46.             # grab the start character point
  47.             start = contents.find(globalValue)
  48.  
  49.             if start != -1:
  50.                 # grab the end character point
  51.                 end = start + len(globalValue)
  52.  
  53.                 # create a new region for the value
  54.                 valueRegion = sublime.Region(region.a + start, region.a + end)
  55.  
  56.                 # add the region to the output
  57.                 regions.append(valueRegion)
  58.  
  59.                 # TODO: now we have to remove the value so we don't
  60.                 # match it again (multiple of same globals on one line)
  61.  
  62.     return regions
  63.  
  64. def highlight_globals(view):
  65.     if view.settings().get('syntax').encode() == 'Packages/Lua/Lua.sublime-syntax'.encode():
  66.         # only execute in Lua files
  67.  
  68.         view.add_regions('HighlightLuaGlobals', get_regions(view),
  69.             'comment', '', sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE | sublime.HIDE_ON_MINIMAP)
  70.  
  71. class HighlightLuaGlobals(sublime_plugin.EventListener):
  72.     def on_modified_async(self, view):
  73.         highlight_globals(view)
  74.  
  75.     def on_activated_async(self, view):
  76.         highlight_globals(view)
  77.  
  78.     def on_load_async(self, view):
  79.         highlight_globals(view)
  80.  
  81. def plugin_loaded():
  82.     for window in sublime.windows():
  83.         for view in window.views():
  84.             view.settings().add_on_change('HighlightLuaGlobals', lambda: highlight_globals(view))
  Reply With Quote
06-18-17, 12:32 PM   #30
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 942
Originally Posted by Resike View Post
Okay i managed to make it work:

Code:
cmd = 'luacheck - --formatter=plain --no-unused --no-redefined --no-unused-args --no-unused-secondaries --no-self --no-max-line-length --no-max-code-line-length --no-max-string-line-length --no-max-comment-line-length --codes --ranges --filename @'
<snip img>

However things that i don't like:

- It's sooo slow, i'm not sure why, but it doesn't fit into the Sublime "policy" where everything is lightning fast.
- You can't change colors, you have 1 color for errors and 1 for warnings and thats it. Would be nice to have a separate color for global functions.

But besides that it's nice. I still think a standalone python script would be better or at least faster, also we could have more control over everything of course.
You can actually change the error and warning colors. They are in the settings for SublimeLinter

Serious question though, why do you want a separate indicator for global functions? If a variable is global, it has the same implications regardless of it's type.
__________________
Knowledge = Power; Be OP

  Reply With Quote
06-18-17, 01:24 PM   #31
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Gethe View Post
You can actually change the error and warning colors. They are in the settings for SublimeLinter

Serious question though, why do you want a separate indicator for global functions? If a variable is global, it has the same implications regardless of it's type.
I guess it would be nice for the rookie authors (and Blizzard employees) to stop population the global namespace with swarms of global functions.
  Reply With Quote
06-19-17, 06:31 PM   #32
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Added the highlighing with Sublime Linter and luacheck:
  • Install the package Sublime Linter.
  • Add the path to luacheck.exe to your system PATH table, or to the paths/windows setting in the Sublime Linter settings:
    "c:\Users\UserName\AppData\Roaming\Sublime Text 3\Packages\WoWDevelopment\WoW Global Finder\"
  • Add "wow lua": "lua", to the syntax_map in the Sublime Linter settings.
  • Restart Sublime.

The globals found by the global finder should match the errors found by luachecker now:


Last edited by Resike : 06-20-17 at 07:53 AM.
  Reply With Quote
06-21-17, 03:15 AM   #33
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Done for "J" to "L"

https://pastebin.com/1ZGqGtz8

Please review them!
  Reply With Quote
07-26-17, 07:45 AM   #34
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Layback_ View Post
Done for "J" to "L"

https://pastebin.com/1ZGqGtz8

Please review them!
Added it. 10char
  Reply With Quote
07-26-17, 07:49 AM   #35
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
I still need more volunteers guys, i'm not gonna go through 40 KLOC by myself, and i also have a lot more other stuff to do in the proejct. Any yet only Layback helped.

Currently i'm adding the complete widget API, i have a cool feature where you select lets say the _Texture help autocomplete it prints out every info from that widget type handlers/scripts/inherits in a formatted lua table.
  Reply With Quote
07-26-17, 08:20 AM   #36
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Would adding the console variables be useful for the package?
They are just strings so I'm not sure if it would be bloat rather than helpful
  Reply With Quote
07-26-17, 08:30 AM   #37
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Ketho View Post
Would adding the console variables be useful for the package?
They are just strings so I'm not sure if it would be bloat rather than helpful
Hmm i guess, however i can write a script to automate that based on the page you linked.
  Reply With Quote
07-26-17, 06:46 PM   #38
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
It's been a while since the last commit(?)

Here's an API list for "F"

https://pastebin.com/mZajXEBr

Please review them.

Thank you!
  Reply With Quote
07-29-17, 03:42 AM   #39
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Layback_ View Post
It's been a while since the last commit(?)

Here's an API list for "F"

https://pastebin.com/mZajXEBr

Please review them.

Thank you!
Added them.
  Reply With Quote
08-02-17, 02:27 AM   #40
Kkthnx
A Cobalt Mageweaver
 
Kkthnx's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2011
Posts: 247
I am not sure if this has been discussed before though I read through the 2 pages here and didn't see anything about it. Is it at all possible to set this so when we run something like this it will quit highlighting/reporting a global?

For example

Lua Code:
  1. if (not KkthnxUIConfig) then
  2.     print(L["KkthnxUI config not found!"])
  3.     return
  4. end

Obviously, it is going to call KkthnxUIConfig and print

Now want I am wanting to happen is if I were to call this up at the top of my file like so it will quit highlighting/reporting them so in theory s I know I have covered them.

Lua Code:
  1. local print = print

of even in that case as I handle it

Lua Code:
  1. local _G = _G
  2.  
  3. local print = _G.print

Code:
-- Global variables that we don't need to cache, list them here
-- GLOBALS: KkthnxUIConfig
Once we declare them here it will stop reporting them to us. If my post makes no sense I apologize as it is 4:26 am as of writing this.
__________________
Success isn't what you've done compared to others. Success is what you've done compared to what you were made to do.

Last edited by Kkthnx : 08-02-17 at 02:35 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Dev Tools » WoWDevelopment Sublime Package

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off