WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Dev Tools (https://www.wowinterface.com/forums/forumdisplay.php?f=41)
-   -   WoWDevelopment Sublime Package (https://www.wowinterface.com/forums/showthread.php?t=55457)

myrroddin 06-17-17 05:57 PM

Are there any plans to include major libraries written by the community, such as Ace3, LibStub, CBH, LDB, etc?

Resike 06-18-17 02:42 AM

Quote:

Originally Posted by myrroddin (Post 323874)
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.

Layback_ 06-18-17 03:10 AM

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 :)

Resike 06-18-17 03:30 AM

Quote:

Originally Posted by Gethe (Post 323872)
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.

Resike 06-18-17 03:31 AM

Quote:

Originally Posted by Layback_ (Post 323881)
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.

Resike 06-18-17 04:48 AM

Quote:

Originally Posted by Resike (Post 323883)
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.

Layback_ 06-18-17 05:16 AM

Quote:

Originally Posted by Resike (Post 323885)
Looks good, you only missed one function (EJ_GetTierInfo), gonna add em.

Sweet :)!!

Resike 06-18-17 10:55 AM

Quote:

Originally Posted by Resike (Post 323882)
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.

p3lim 06-18-17 11:09 AM

Quote:

Originally Posted by p3lim (Post 323867)
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))

Gethe 06-18-17 12:32 PM

Quote:

Originally Posted by Resike (Post 323887)
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.

Resike 06-18-17 01:24 PM

Quote:

Originally Posted by Gethe (Post 323890)
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.

Resike 06-19-17 06:31 PM

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:


Layback_ 06-21-17 03:15 AM

Done for "J" to "L" :)

https://pastebin.com/1ZGqGtz8

Please review them!

Resike 07-26-17 07:45 AM

Quote:

Originally Posted by Layback_ (Post 323927)
Done for "J" to "L" :)

https://pastebin.com/1ZGqGtz8

Please review them!

Added it. 10char

Resike 07-26-17 07:49 AM

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.

Ketho 07-26-17 08:20 AM

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

Resike 07-26-17 08:30 AM

Quote:

Originally Posted by Ketho (Post 324363)
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.

Layback_ 07-26-17 06:46 PM

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!

Resike 07-29-17 03:42 AM

Quote:

Originally Posted by Layback_ (Post 324373)
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.

Kkthnx 08-02-17 02:27 AM

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.


All times are GMT -6. The time now is 04:45 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI