Sublime Plugin Refactoring : Feedback required

596 views
Skip to first unread message

Heinz Hölzer

unread,
Jun 23, 2013, 8:14:20 AM6/23/13
to haxe...@googlegroups.com
Hey guys,

i'm currently working with Clément on the refactoring branch of the sublime text haxe plugin. It's still alpha, but for me it's working fine. It would be nice to get some feedback from testers with different kind of projects.

Some of the new features:
  • Async completion (no ui-freezing anymore)
  • Multi project Support, in Sublime Text 3 you can now open multiple projects at the same time and work on them parallel. This feature is working but buggy in ST2 because of some missing API-functions.
  • Jump to declaration, jump to the declaration of the symbol under the cursor (uses the haxe compiler and it's type inference to find it)
  • Show documentation, show the documentation of the symbol under the cursor (uses the haxe compiler and it's type inference to extract the docs)
  • Show type of expression, show the type of the expression under the cursor (uses the haxe compiler and it's type inference to get the type)
The last 3 features are currently only working with projects using the haxe 3.0 compiler. However the related haxe files (which are working but really dirty at the moment ;)) can be improvement with some conditional compilation.

It was a major refactoring of large parts of the plugin, so it is possible that some features of the current plugin are still missing. Please fill some issues if you have problems or miss some of features.

You can find the refactoring branch here:


just click on download zip and replace it with your current plugin in the Sublime Text packages folder.

If you want to contribute or have questions regarding the new structure (still a lot of cleanup needed) please let us now or send pull requests ;).

best,
h



Heinz Hölzer

unread,
Jun 23, 2013, 9:40:15 AM6/23/13
to haxe...@googlegroups.com
one minor extra feature is if you type CTRL+Shift+H and then CTRL+Shift+D on an Enum type like in the following class ( | represents the cursor) you get the info for this type and a sample switch statement in the slide panel.

class X {
  public static function main () {
     haxe.ds.Opt|ion
  }

}

----------------------- slide panel info -----------------------------------

enum haxe.ds.Option<Unknown<0>>

---------------
switch (x) {
case None: 
case Some(v): 
}
---------------

An Option is a wrapper type which can either have a value (Some) or not a
value (None).

Alexander Kuzmenko

unread,
Jun 23, 2013, 10:33:42 AM6/23/13
to haxe...@googlegroups.com
I use Sublime Text2 for Haxe.
I have to say, autocompletion rarely (almost never) works for me even with master branch of haxe plugin.
I've checked out refactoring branch. None of new features works. 

When i press CTRL+SHIFT+H -> CTRL+SHIFT+D, line under cursor is duplicated. I've disabled CTRL+SHIFT+D hotkey in default key bindings of the sublime, now CTRL+SHIFT+H -> CTRL+SHIFT+D does nothing
CTRL+SHIFT+H -> CTRL+SHIFT+F opens "find and replace" dialog
CTRL+SHIFT+H -> CTRL+SHIFT+Z does nothing.

However creating new types with hotkeys works as intended.

I experience these problems in Ubuntu 12.04 on different machines (32bit and 64bit systems)

воскресенье, 23 июня 2013 г., 16:14:20 UTC+4 пользователь Heinz Hölzer написал:

Alexander Kuzmenko

unread,
Jun 23, 2013, 10:46:23 AM6/23/13
to haxe...@googlegroups.com
If there is anything i can do to help you, please, tell me. Unfortunately i know nothing about python and sublime plugins, but i can test anything you want :)


воскресенье, 23 июня 2013 г., 16:14:20 UTC+4 пользователь Heinz Hölzer написал:
Hey guys,

Heinz Hölzer

unread,
Jun 23, 2013, 10:59:30 AM6/23/13
to haxe...@googlegroups.com
Hi Alexander,

thx for your feedback, first of all you need to create a sublime project file inside of your root project to get most of the stuff working (should be documented, we need an example project). if you have opened the project and it's still not working add the  option "haxe_use_debug_panel" to this file, it could look like this:

{
"folders":
[
{
"path": "."
}
        ],
"settings":
{
"haxe_use_debug_panel": true
}
}

restart sublime to make sure it is taken into account. After running of commands with shortcuts you should have a panel with some debug stuff in it. Copy and paste it here. Also open the console "View->Show Console" and paste the output here.

best,
h

Heinz Hölzer

unread,
Jun 23, 2013, 11:01:34 AM6/23/13
to haxe...@googlegroups.com
could you please tell me what happened if you press CTRL+SHIFT+B to select a build? And where is your build file located, how does it look like?

Alexander Kuzmenko

unread,
Jun 23, 2013, 11:27:26 AM6/23/13
to haxe...@googlegroups.com
Created a project file with haxe_use_debug_panel, but nothing changed. No debug panel appears when i use hotkeys. Console also stays clear.
Build system works fine: i can select any target and build with CTRL+B

I've attached my test project.

воскресенье, 23 июня 2013 г., 19:01:34 UTC+4 пользователь Heinz Hölzer написал:
ST2Test.zip

Heinz Hölzer

unread,
Jun 23, 2013, 12:26:50 PM6/23/13
to haxe...@googlegroups.com
thx, i updated the plugin. but be careful when using nme or openfl you have to build the project first for the selected target (CTRL+Enter). After the first build everything should work fine. I will also try to improve this behaviour and give a proper error message when a build is needed.
And by the way documentation is only shown if it's inside of /** my docs **/, normal comments are ignored.

Heinz Hölzer

unread,
Jun 23, 2013, 12:38:51 PM6/23/13
to haxe...@googlegroups.com
I also added an error message in the latest revision if a build is required.

Alexander Kuzmenko

unread,
Jun 23, 2013, 12:42:12 PM6/23/13
to haxe...@googlegroups.com
Now if i try to build i get this message:

Running Command: haxelib run openfl build /home/alex/Work/HaXe/tests/st2/ST2Test/project.xml flash -debug
Standard library not found
[Finished in 0.0s with exit code 1]

But at least i got "debug panel" :)
If i write this code:

var s = new Sprite();
s.|

Then content of debug panel looks like this: http://pastebin.com/MTPfJgpg 
 
 

воскресенье, 23 июня 2013 г., 20:26:50 UTC+4 пользователь Heinz Hölzer написал:

Alexander Kuzmenko

unread,
Jun 23, 2013, 12:50:56 PM6/23/13
to haxe...@googlegroups.com
I've fixed build error by removing "haxe_library_path" from config (my environment is set properly).
Here is debug panel content for that sprite code now: http://pastebin.com/SgcheC5D

воскресенье, 23 июня 2013 г., 20:42:12 UTC+4 пользователь Alexander Kuzmenko написал:

Simon Krajewski

unread,
Jun 23, 2013, 12:59:52 PM6/23/13
to haxe...@googlegroups.com
Am 23.06.2013 14:14, schrieb Heinz Hölzer:
  • Jump to declaration, jump to the declaration of the symbol under the cursor (uses the haxe compiler and it's type inference to find it)

How did you implement that?

Simon

Heinz Hölzer

unread,
Jun 23, 2013, 1:13:35 PM6/23/13
to haxe...@googlegroups.com
strange, what happens if you run the same command from the root folder in a terminal?

Heinz Hölzer

unread,
Jun 23, 2013, 1:23:45 PM6/23/13
to haxe...@googlegroups.com
I hacked it together with macros ;).

in sublime text i search the start and the end of the current expression and i wrap a macro call around it, followed by a ".", which is also the display position. The completion is triggered and the macro is executed just before the display stuff is printed to the console (which gets simple ignored). Inside of the macro i try to find the type with multiple methods and i print the resulting json file to sysout. something like ||||||{ "file":"MyFile.jx", pos: 0}||||||. In sublime i grab this json and jump to the resulting position.

You can find the really really dirty macro here (bad naming too): https://github.com/clemos/haxe-sublime-bundle/blob/refactoring/haxetools/hxsublime/FindDeclaration.hx.

I also needed to work around the problem that Context.typeof can blow up when display is defined. That's why i run the completion multiple times with different entry points (id parameter of the macro).

best,
h

Heinz Hölzer

unread,
Jun 23, 2013, 1:38:51 PM6/23/13
to haxe...@googlegroups.com
ok, i did some changes, you could checkout the latest revision and try again?

Franco Ponticelli

unread,
Jun 23, 2013, 2:02:36 PM6/23/13
to haxe...@googlegroups.com
Hi Heinz,
I am trying on ST3 ... here are the issues I am experiencing:

1. CTRL+Enter triggers the save dialog window and when I ESC it shows me the error "Standard library not found"
2. When I put a "." after a valid instance nothing happens (CTRL+SHIFT+B works fine)
3. CTRL+SHIFT+H + ... the creational ones work fine, the others do not work on any of the test I made (not totally unexpected).

Thank you for the effort, it is very much appreciated.

Franco


--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Heinz Hölzer

unread,
Jun 23, 2013, 2:13:45 PM6/23/13
to haxe...@googlegroups.com
Did you use the latest version (34 minutes ago, revision: c763f45ff3fa8b8c1b9a111ab0075be519a45add)?
And what is your os?

Alexander Kuzmenko

unread,
Jun 23, 2013, 2:25:30 PM6/23/13
to haxe...@googlegroups.com
Updated from github. Still getting messages "err:Error: Standard library not found" in debug panel.

воскресенье, 23 июня 2013 г., 22:13:45 UTC+4 пользователь Heinz Hölzer написал:

Franco Ponticelli

unread,
Jun 23, 2013, 2:21:53 PM6/23/13
to haxe...@googlegroups.com
Yes, that is the version I am using.

Franco

Alexander Kuzmenko

unread,
Jun 23, 2013, 2:35:57 PM6/23/13
to haxe...@googlegroups.com
Got some progress: If i hit CTRL+SHIFT+D hotkey on t.wtfField in my test project (attached to one of my previous messages), i get this in console: "Cannot find declaration for expression t.wtfField".
At least hotkey is working now :)

воскресенье, 23 июня 2013 г., 22:25:30 UTC+4 пользователь Alexander Kuzmenko написал:

Heinz Hölzer

unread,
Jun 23, 2013, 2:37:34 PM6/23/13
to haxe...@googlegroups.com
ok, thx it seems you are not the only one with this problem ;). I have some questions:

1. Where is your haxe compiler installed and where is your std library located?

2. What haxe specific environment variables have you set?

best,
h

Franco Ponticelli

unread,
Jun 23, 2013, 2:41:45 PM6/23/13
to haxe...@googlegroups.com
Some feedback that might help:

1. disabling the server mode doesn't seem to really disable it
2. I copy pasted the generated haxe command and I am noticing:
  a. libs are NOT included
  b. --connect is always present

Alexander Kuzmenko

unread,
Jun 23, 2013, 2:44:58 PM6/23/13
to haxe...@googlegroups.com
I installed haxe from sources with "make && make install" and did not set any variables manually. My haxe compiller is located in /usr/bin/haxe (symlink to /usr/lib/haxe/haxe). Std library is located in /usr/lib/haxe/std

воскресенье, 23 июня 2013 г., 22:37:34 UTC+4 пользователь Heinz Hölzer написал:

Heinz Hölzer

unread,
Jun 23, 2013, 3:03:29 PM6/23/13
to haxe...@googlegroups.com
strange i cannot reproduce this, are you using the latest svn version? if yes does anyone know if something has changed regarding std path behaviour?

Heinz Hölzer

unread,
Jun 23, 2013, 3:04:29 PM6/23/13
to haxe...@googlegroups.com
thx that's a documentation bug, i need to update it ;)

Heinz Hölzer

unread,
Jun 23, 2013, 3:06:37 PM6/23/13
to haxe...@googlegroups.com
how did you disable it??

Alexander Kuzmenko

unread,
Jun 23, 2013, 3:07:50 PM6/23/13
to haxe...@googlegroups.com
I use "vanilla" 3.0.0 version.

воскресенье, 23 июня 2013 г., 23:03:29 UTC+4 пользователь Heinz Hölzer написал:

Alexander Kuzmenko

unread,
Jun 23, 2013, 3:08:33 PM6/23/13
to haxe...@googlegroups.com
Where is your std lib located?

воскресенье, 23 июня 2013 г., 23:03:29 UTC+4 пользователь Heinz Hölzer написал:

Heinz Hölzer

unread,
Jun 23, 2013, 3:10:35 PM6/23/13
to haxe...@googlegroups.com
same location as yours and no env variables set, that's the strange thing ;)

Heinz Hölzer

unread,
Jun 23, 2013, 3:12:44 PM6/23/13
to haxe...@googlegroups.com
what's your output if you enter: 

haxe -v --no-output -main Nothing

in the console?

mine is:

Classpath : /usr/lib/haxe/std/;/usr/local/lib/haxe/std/;/usr/lib/haxe/extraLibs/;/usr/local/lib/haxe/extraLibs/;;/
Defines : true;sys;haxe_ver;haxe_release;haxe3;dce;cross
Parsed /usr/lib/haxe/std/StdTypes.hx
Parsed /usr/lib/haxe/std/String.hx
Parsed /usr/lib/haxe/std/Array.hx
Parsed /usr/lib/haxe/std/haxe/EnumTools.hx
Parsed /usr/lib/haxe/std/Std.hx
Class not found : Nothing

Alexander Kuzmenko

unread,
Jun 23, 2013, 3:15:23 PM6/23/13
to haxe...@googlegroups.com
$ haxe -v --no-output -main Nothing
Classpath : /usr/lib/haxe/std/;/usr/local/lib/haxe/std/;/usr/lib/haxe/extraLibs/;/usr/local/lib/haxe/extraLibs/;;/
Defines : true;sys;haxe_ver;haxe_release;haxe3;dce;cross
Parsed /usr/lib/haxe/std/StdTypes.hx
Parsed /usr/lib/haxe/std/String.hx
Parsed /usr/lib/haxe/std/Array.hx
Parsed /usr/lib/haxe/std/haxe/EnumTools.hx
Parsed /usr/lib/haxe/std/Std.hx
Class not found : Nothing


воскресенье, 23 июня 2013 г., 23:12:44 UTC+4 пользователь Heinz Hölzer написал:

Heinz Hölzer

unread,
Jun 23, 2013, 3:33:41 PM6/23/13
to haxe...@googlegroups.com
same as mine, really strange. As a workaround can you add the following settings in your project file and try again:

"haxe_exec" : "path/to/haxe_sdk/haxe",
"haxe_library_path" : "path/to/haxe_sdk/std",
"haxelib_exec" : "path/to/haxe_sdk/haxelib"

best,
h

Heinz Hölzer

unread,
Jun 23, 2013, 3:34:30 PM6/23/13
to haxe...@googlegroups.com
sorry it should be:

"haxe_exec" : "path/to/haxe_sdk/haxe",
"haxe_library_path" : "path/to/haxe_sdk/std",
"haxe_haxelib_exec" : "path/to/haxe_sdk/haxelib"

Heinz Hölzer

unread,
Jun 23, 2013, 4:27:53 PM6/23/13
to haxe...@googlegroups.com
ok, that is fixed, the setting is taken into account now.

Heinz Hölzer

unread,
Jun 23, 2013, 4:48:56 PM6/23/13
to haxe...@googlegroups.com
Could you update to latest revision and add the following settings to your project file:

"haxe_exec" : "path/to/haxe_sdk/haxe",
"haxe_library_path" : "path/to/haxe_sdk/std",
"haxe_haxelib_exec" : "path/to/haxe_sdk/haxelib"



Heinz Hölzer

unread,
Jun 23, 2013, 4:56:16 PM6/23/13
to haxe...@googlegroups.com
have anybody successfully used the new features?

Alexander Kuzmenko

unread,
Jun 23, 2013, 4:58:54 PM6/23/13
to haxe...@googlegroups.com
Progress! Now  autocompletion works and CTRL+SHIFT+F opens String.hx from standart library. But it is opened for any field instead of finding declaration :)

Heinz Hölzer

unread,
Jun 23, 2013, 5:23:45 PM6/23/13
to haxe...@googlegroups.com
nice, can you show me your file and the location of your cursor. you have to know that this kind of find declaration only works inside of a function and only on expressions. There is currently no way to jump to a type which is defined in a function signature. It's limited but in some cases very useful. The reason is, that this feature relies on compiler features and does not implement the logic itself.

"".sub|str // should jump to String.substr

[].pu|sh should jump to Array.push

it works for using too:

using StringTools;

"".ends|With // should jump to StringTools.endsWith

Iterator| // should jump to the Iterator definition

There are still some problems if you have comments in your file, but this should be fixed in the next couple of days.

best,
h

Franco Ponticelli

unread,
Jun 23, 2013, 5:38:31 PM6/23/13
to haxe...@googlegroups.com
I see a lot of improvements but my project it is still not compiling ... in the compilation command I don't see the -lib options at all ... and now reverting to the haxe server doesn't seem to add the switch (the server is indeed running).

Heinz Hölzer

unread,
Jun 23, 2013, 5:49:49 PM6/23/13
to haxe...@googlegroups.com
can you show me your hxml files or send me a sample project where this problem occurs? Do you see any errors in the console (View -> Show Console) or in the debug panel (can be enabled with "haxe_use_debug_panel" : true in your project settings)? Can you put the content of these panels in a gist?

Heinz Hölzer

unread,
Jun 23, 2013, 8:57:39 PM6/23/13
to haxe...@googlegroups.com
i fixed the problem with haxelib libraries ;). The other issue with the library path can be solved with setting a environment variable HAXE_STD_PATH or by setting the haxelib_library_path in the project settings. There is also another option, open the syntax specifix user settings and add the setting "plugin_haxe_library_path" there. All settings in this file (prefixed with "plugin_" are like a fall back, when there is no project specific setting available. It also a useful place to tweak the customize the default behaviour of the plugin. Note: this is not a sublime feature, it's only implemented in this plugin because normally syntax specific options override project specific options (that's also the reason for the prefix). you can also add plattform specific options, with suffixes ("_osx", "_linux", "_windows") which override the default options.

here is the full order for these settings:

1. project: haxe_library_path_linux
2. project: haxe_library_path
3. syntax: plugin_haxe_library_path_linux
4. syntax: plugin_haxe_library_path

best,
h

Heinz Hölzer

unread,
Jun 23, 2013, 8:59:40 PM6/23/13
to haxe...@googlegroups.com
hey alexander,

please update to the latest revision and take a look at my discussion with franco in this thread, that should hopefully solve your problems ;)

Franco Ponticelli

unread,
Jun 23, 2013, 10:03:08 PM6/23/13
to haxe...@googlegroups.com
So, I tried the haxe server thing and I noticed that when the server is automatically started from ST3 I get the std error but if I kill it and start it from the terminal it works just fine. So I think that HAXE_STD_PATH is not set properly before starting the server?

Franco Ponticelli

unread,
Jun 23, 2013, 10:08:45 PM6/23/13
to haxe...@googlegroups.com
Another thing, the haxe server instance is not killed when you quit ST3 ... is this intentional?

Alexander Kuzmenko

unread,
Jun 24, 2013, 12:53:43 AM6/24/13
to haxe...@googlegroups.com
Now refactoring hotkeys work, but only for class fields declared in the current module. If i try any field from another module, String.hx is opened and cursor is placed on "substr" method :)

Heinz Hölzer

unread,
Jun 24, 2013, 2:20:35 AM6/24/13
to haxe...@googlegroups.com
Can you send me an example project and tell me where this happens? And can you show me your console log?

Heinz Hölzer

unread,
Jun 24, 2013, 2:38:00 AM6/24/13
to haxe...@googlegroups.com
can you try again with latest revision, i also included logging. You should get something like server env: .... in your console.

Heinz Hölzer

unread,
Jun 24, 2013, 2:46:57 AM6/24/13
to haxe...@googlegroups.com
yes and no, there is a problem that i can't kill it properly from sublime, because i have no proper exit callback. I have a workaround for this, but it's experimental:


just add:

"haxe_use_servermode_wrapper" : true

to your settings, it adds a small wrapper around the compiler, which kills the compiler if sublime was killed. Maybe it works for you.

best,
h

Alexander Kuzmenko

unread,
Jun 24, 2013, 10:59:51 AM6/24/13
to haxe...@googlegroups.com
Now everything works fine (find declaration, show doc, etc). 
But in a project where some classes are generated by macros (does not physically exists in files) this error in console, whatever i try to do:
18:40:59 Class not found : LevelGuiBase
18:40:59 Error: /home/alex/Work/HaXe/Maze/source/maze/ui/LevelGui.hx:14: characters 0-5: Class not found : LevelGuiBase
In this case only build system works. Any other functionality does not work (autocomplition, refactoring features, etc)

понедельник, 24 июня 2013 г., 10:38:00 UTC+4 пользователь Heinz Hölzer написал:

Heinz Hölzer

unread,
Jun 24, 2013, 11:35:35 AM6/24/13
to haxe...@googlegroups.com
sounds great, you can send/upload a minimal example of such a project and post what you expected and what fails?

Alexander Kuzmenko

unread,
Jun 24, 2013, 11:46:26 AM6/24/13
to haxe...@googlegroups.com
I'll create simple macro project later today.

Now i noticied another "glitch": if i declare local variable like this:
/** var doc **/
var someVar : SomeType = new SomeType();
som|eVar.prop = 10; 
Then "goto declaration" opens SomeType definition instead of going to var declaration position. Also "show doc" shows doc for SomeType instead of var doc.

понедельник, 24 июня 2013 г., 19:35:35 UTC+4 пользователь Heinz Hölzer написал:

Alexander Kuzmenko

unread,
Jun 24, 2013, 3:24:06 PM6/24/13
to haxe...@googlegroups.com
Everything works like a charm now except single glitch described in comments of example project (attached to this message)
But for my real openfl project nothing works :) Even build system does not work now. No error messages in console, and debug panel does not open.

понедельник, 24 июня 2013 г., 19:35:35 UTC+4 пользователь Heinz Hölzer написал:
ST2Test.zip

Heinz Hölzer

unread,
Jun 24, 2013, 5:56:31 PM6/24/13
to haxe...@googlegroups.com
it's hard to tell what's going wrong, if you could provide a minified example we could investigate the problem. Do you have any suspicious lines in your console log? could you post that after something went wrong?

Heinz Hölzer

unread,
Jun 24, 2013, 6:04:42 PM6/24/13
to haxe...@googlegroups.com
yes this behaviour is known, the problem is that we rely on the compiler macro features at this point, there is no build in method to get the position of a local var (hopefully this changes soon ;)). If you have some macro experiences and could provide us a macro that solves the following problem we are happy to integrate this feature:

// src class
class Test {  
  public static function test () {
    var x = 5;
    //... some other code
    x|
  }
}

is translated in 

// src class
class Test {  
  public static function test () {
    var x = 5;
    //... some other code
    hxsublime.FindDeclaration.findPos(x);
  }
}

if we have a reliable implementation that returns us the position of x based on the expression x we can implement that feature easily.

this should also work:

class Test {  
  public static function test (x:Int) {
    //... some other code
    hxsublime.FindDeclaration.findPos(x);
  }
}

best,
h

Heinz Hölzer

unread,
Jun 24, 2013, 7:54:39 PM6/24/13
to haxe...@googlegroups.com
You should change the way you define your compile time classes ;)

change your function defineClass to the following definition:

macro static public function defineCompileTimeClasses() : Void 
    {
        
        var pos = Context.currentPos();
        // var pos = Context.currentPos();

        //create new class definition
        var clazz:TypeDefinition  = {
            pos      : pos,
            fields   : [ //add "testSprite" public field
                {
                    pos    : pos,
                    name   : "testSprite",
                    meta   : [],
                    kind   : FVar(TPath({
                        sub    : null,
                        params : [],
                        name   : "Sprite",
                        pack   : ["flash", "display"],
                    })),
                    doc    : "Hey! I'm a sprite!",
                    access : [APublic]
                }
            ],
            params   : [],
            pack     : ["com", "example"],
            name     : "Generated",
            meta     : [  ],
            isExtern : false,
            kind     : TDClass( { name : "Sprite", pack : ["flash", "display"], params :[] } ),
        };
        
       

        Context.onTypeNotFound(function (s) {
            if (s == "com.example.Generated") return clazz;
            return null;
        });
        
    }

and to make sure this function is your compile time classes are available when referenced add this argument to the command line:

--macro Macro.defineCompileTimeClasses()

instead of calling it in Main

then completion works as expected ;)

Heinz Hölzer

unread,
Jun 24, 2013, 8:01:15 PM6/24/13
to haxe...@googlegroups.com
and make sure to update the plugin (minor bugfix)

Achmad Aulia Noorhakim

unread,
Jun 25, 2013, 8:34:47 AM6/25/13
to haxe...@googlegroups.com
Hi sorry if my question is not about the refactoring branch, but how do I add <return> to insert the completion list? It really threw me off when using haxe bundle with Sublime, in any other IDE/Editor I can pick one entry and press <return> and it will be inserted and the cursor is put after the entry. In Sublime Haxe Bundle it moved the cursor down.

Alexander Kuzmenko

unread,
Jun 28, 2013, 11:10:20 AM6/28/13
to haxe...@googlegroups.com
Sorry for late answer.
I updated plugin several minutes ago from "refactoring" branch, and now everything works fine even in my "real" complex projects!
Thanks for your hard work!

вторник, 25 июня 2013 г., 4:01:15 UTC+4 пользователь Heinz Hölzer написал:

Heinz Hölzer

unread,
Jun 30, 2013, 10:41:15 AM6/30/13
to haxe...@googlegroups.com
<return> selects the next entry in your completion list?? It seems like a configuration issue, i only use <return> to insert a completion entry into the current file.

Heinz Hölzer

unread,
Jun 30, 2013, 10:43:18 AM6/30/13
to haxe...@googlegroups.com
thx for your reply, that sounds great ;) And please report ideas and especially everything that's really annoying when working with the plugin ;)

Alexander Kuzmenko

unread,
Jun 30, 2013, 2:39:38 PM6/30/13
to haxe...@googlegroups.com
Is it possible to make it work "my" way? :)
I can build my app without any problems, so code completion for such generated classes should work (i hope).

вторник, 25 июня 2013 г., 3:54:39 UTC+4 пользователь Heinz Hölzer написал:

Heinz Hölzer

unread,
Jun 30, 2013, 3:07:19 PM6/30/13
to haxe...@googlegroups.com
the problem is that "your" doesn't play well with the haxe completion server which doesn't execute your Main function (where you call your macro that creates your type). And we rely on the completion server for completion. However there is an alternative way how you can achieve what you need, take a look at this example code:


package ;

#if macro

import haxe.macro.Context;
import haxe.macro.Expr.FieldType.FVar;
import haxe.macro.Expr.TypeDefinition;

#end
class MyMacro {

macro public static function getClass():haxe.macro.Type
{
var pos = Context.currentPos();
var cl:TypeDefinition = {
            pos      : pos,
            fields   : [ 
                {
                    pos    : pos,
                    name   : "test",
                    meta   : [],
                    kind   : FVar(null,macro "x"),
                    doc    : "Hey! I'm a sprite!",

                    access : [APublic, AStatic]
                }
            ],
            params   : [],
            pack     : ["foo"],
            name     : "Generated",
            meta     : [],
            isExtern : false,
            kind     : TDClass()
        };
        
        Context.defineType(cl); // i get an error here if display is defined
        return Context.getType("foo.Generated");
}
}



#if !macro

typedef X = haxe.macro.MacroType<[MyMacro.getClass()]>;

class Test {

public static function main () {
trace(X.test);

}

}

#end

Achmad Aulia Noorhakim

unread,
Jun 30, 2013, 10:43:03 PM6/30/13
to haxe...@googlegroups.com
Yes that is what I meant, <return> *insert* the selected entry on the completion list in to the file. I'm sorry if my wording was confusing. I'm using the stable branch though, so it might be already done in the refactoring branch. Since I'm not planning on jumping into the refactoring branch anytime soon, where do I look, in the configuration file(s), in order to achieve this? Currently if I select on of the completion entry, and then press <return> the cursor and the completion list move down forming a new line instead of inserting my selection.

postite

unread,
Jul 1, 2013, 5:07:33 AM7/1/13
to haxe...@googlegroups.com
installed this morning !
works great at first sight!
completion is way better... \o/

i will send feedback as things goes on!

thanks a lot.

Norbert Melzer

unread,
Jul 1, 2013, 10:24:18 AM7/1/13
to haxe...@googlegroups.com

Is this plugin refactoring ST3 only or is it supposed to do is job with ST2 also?

Even if there is a public preview of ST3 available for a few days now, I don't want to update, because it can't be installed in parallel with ST2 on my Ubuntu system without difficulties.

Heinz Hölzer

unread,
Jul 1, 2013, 10:56:09 AM7/1/13
to haxe...@googlegroups.com
Is this plugin refactoring ST3 only or is it supposed to do is job with ST2 also?

yes it works in st2, too.


Even if there is a public preview of ST3 available for a few days now, I don't want to update, because it can't be installed in parallel with ST2 on my Ubuntu system without difficulties.
i don't have problems running them alongside on ubuntu, make sure that you use the tarball versions for that purpose.

best,
h

Stephane Le Dorze

unread,
Jul 1, 2013, 4:34:51 PM7/1/13
to haxe...@googlegroups.com, heinz....@googlemail.com
Believe it was ST3 only,
just tried,
impressed,
thanks

Rui Zhang

unread,
Jul 1, 2013, 5:38:48 PM7/1/13
to haxe...@googlegroups.com, heinz....@googlemail.com

Tried with ST2 on Mac, so far it seems working fine.

Ctrl-Enter work for openfl mac/ios build.    Anyway I can do build and run?

Also tried find declaration, works fine. It is great feature.

How can I do show documentation and show type? Did not find it from super+shift+p.

This is great progress, and thanks for the effort!

ps, one issue, when I try to input "trace(",  it give msg "14:36:24 No classes found in trace ( are you referencing a variable that doesn't exist?)" in console.

Rui

Heinz Hölzer

unread,
Jul 1, 2013, 5:54:23 PM7/1/13
to haxe...@googlegroups.com, heinz....@googlemail.com
Hey Rui,

thx for testing the current state!
 
Ctrl-Enter work for openfl mac/ios build.    Anyway I can do build and run?

The shortcuts are listed here (build + run should be ctrl+shift+enter):

How can I do show documentation and show type? Did not find it from super+shift+p.

just take a look at the the docs above.

ps, one issue, when I try to input "trace(",  it give msg "14:36:24 No classes found in trace ( are you referencing a variable that doesn't exist?)" in console.

will take a look at this one.

 This is great progress, and thanks for the effort!

thx a lot ;)

best,
h
 
On Monday, July 1, 2013 11:38:48 PM UTC+2, Rui Zhang wrote:

Tried with ST2 on Mac, so far it seems working fine.


Jason O'Neil

unread,
Jul 2, 2013, 12:14:58 AM7/2/13
to haxe...@googlegroups.com
Just updated... overall it is looking much improved, and in my simpler projects the completion is so much better, especially if I have multiple directories with different build files in a single project.  The function parameter hints are really nice also.

However on some more complex projects, I'm getting a string of errors whenever it tries to do completion:

12:12:38 #Reflect has no field compare
12:12:38 Error: /usr/lib/haxe/std/haxe/ds/BalancedTree.hx:201: characters 9-24: #Reflect has no field compare
12:12:38 Error: /usr/lib/haxe/std/haxe/ds/EnumValueMap.hx:46: characters 15-34: #Reflect has no field isEnumValue
12:12:38 Error: /usr/lib/haxe/std/haxe/ds/EnumValueMap.hx:46: characters 42-61: #Reflect has no field isEnumValue
12:12:38 Error: /usr/lib/haxe/std/haxe/ds/EnumValueMap.hx:47: characters 8-23: #Reflect has no field compare
12:12:38 Error: /usr/lib/haxe/std/haxe/ds/BalancedTree.hx:233: characters 58-61: #Std has no field string
12:12:38 Error: /usr/lib/haxe/std/haxe/ds/BalancedTree.hx:233: characters 63-68: #Std has no field string
12:12:38 Error: /home/jason/workspace/forks/thx/src/Arrays.hx:300: characters 71-86: #Dynamics has no field format
12:12:38 Error: /home/jason/workspace/forks/thx/src/Arrays.hx:302: characters 49-64: #Dynamics has no field format
12:12:38 Error: /home/jason/workspace/forks/thx/src/Arrays.hx:305: characters 12-24: #Ints has no field formatf
12:12:38 Error: /home/jason/workspace/forks/thx/src/Strings.hx:141: characters 12-28: #Dynamics has no field formatf

Or in another place:

12:13:51 { } has no field length
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:55: characters 12-22: { } has no field length
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:57: characters 30-33: { } should be String
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:57: characters 30-33: For function argument 's'
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:61: characters 32-42: { } has no field substr
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:64: characters 34-37: { } should be String
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:64: characters 34-37: For function argument 's'
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:69: characters 36-39: { } should be String
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:69: characters 36-39: For function argument 's'
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:80: characters 15-25: { } has no field substr
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:87: characters 36-39: { } should be String
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:87: characters 36-39: For function argument 's'
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:94: characters 16-26: { } has no field substr
12:13:51 Error: /usr/lib/haxe/std/haxe/macro/Format.hx:107: characters 31-41: { } has no field substr
12:13:51 Error: /usr/lib/haxe/lib/tink_macro/0,0,0-alpha/tink/macro/tools/TypeTools.hx:118: characters 12-19: { } should be haxe.macro.FieldType
12:13:51 Error: /usr/lib/haxe/lib/tink_macro/0,0,0-alpha/tink/macro/tools/TypeTools.hx:104: characters 10-17: Void should be haxe.macro.FieldType
12:13:51 Error: /usr/lib/haxe/lib/tink_macro/0,0,0-alpha/tink/macro/tools/TypeTools.hx:134: characters 4-11: { } should be Null<tink.core.types.Outcome<Array<haxe.macro.ClassField>, Unknown<0>>>
12:13:51 Error: /usr/lib/haxe/lib/tink_macro/0,0,0-alpha/tink/macro/tools/TypeTools.hx:134: characters 4-11: { } should be tink.core.types.Outcome<Array<haxe.macro.ClassField>, Unknown<0>>

Is it possible there is some kind of dead code elimination, or some weird behaviour between using --display, and Macros to help --display, and macros in the actual code base?

Overall though it is looking extremely promising.  Well done!

Jason
 

Heinz Hölzer

unread,
Jul 2, 2013, 4:53:03 AM7/2/13
to haxe...@googlegroups.com
Do you have this completion behaviour regardless of the syntax, if yes, it seems that something with your configuration is wrong.

Alexander Kuzmenko

unread,
Jul 2, 2013, 4:57:06 AM7/2/13
to haxe...@googlegroups.com
I have same issues as Jason and Rui sometimes in complex projects.

вторник, 2 июля 2013 г., 12:53:03 UTC+4 пользователь Heinz Hölzer написал:

Heinz Hölzer

unread,
Jul 2, 2013, 5:09:40 AM7/2/13
to haxe...@googlegroups.com
do you get the completion running at the same position in other ide's that use server-completion? I'm not sure if this is a bug in the server mode or in the plugin. It could also be that tink does stuff that is incompatible with server mode. You can also try to disable the server mode with "haxe_use_servermode" in your project file.

Heinz Hölzer

unread,
Jul 2, 2013, 6:13:10 AM7/2/13
to haxe...@googlegroups.com
ok, i can reproduce this behaviour, will try to fix it.


On Tuesday, July 2, 2013 6:14:58 AM UTC+2, Jason O'Neil wrote:

Heinz Hölzer

unread,
Jul 2, 2013, 5:40:55 PM7/2/13
to haxe...@googlegroups.com
 i commited a fix that should fix this problem and i hope that i don't introduced other problems with this change. In my tests it seems to work fine this way.

In particular i changed the display position for the -display compiler flag from {byteoffset} to 0 and in the temporary source file i add the | char. It seems that this works more reliable in some special cases like this. I already opened a post on haxedev to get feedback from the compiler team on this strange behaviour. I thought that both triggers would do exactly the same.

Could everyone try the latest version and check if there are regressions? Did this impact the speed of completion for someone? 


On Tuesday, July 2, 2013 6:14:58 AM UTC+2, Jason O'Neil wrote:

Atul Kumar

unread,
Jul 4, 2013, 9:57:04 AM7/4/13
to haxe...@googlegroups.com
If I have a class in a file which goes:

package;
class Foo {
public function bar(): Void {
}
}


And then in my main class:

package;
class Test {
public static function main() {
var foo: Foo = new Foo();
}
}


and I type "foo." the completion popup comes up saving "Dynamic - No Completion". However, when I write "foo.bar()" myself, and then execute "Goto Definition" it jumps to the right location.

Is that normal? Or a bug? I am on osx, using the latest Sublime 3 beta and Haxe3


Cheers

Atul Kumar

unread,
Jul 4, 2013, 10:03:40 AM7/4/13
to haxe...@googlegroups.com
Just find the answer to my question:

I have to put the constructor in to class foo (public function new(): Void {}). Then it works fine.

Heinz Hölzer

unread,
Jul 4, 2013, 3:53:16 PM7/4/13
to haxe...@googlegroups.com
Hey Jason,

it would be awesome if you could try to create a minimal example where errors of this kind occurs. I've got the same problem in some cases, but i can't reproduce it.

best,
h

Jason O'Neil

unread,
Jul 4, 2013, 7:39:31 PM7/4/13
to haxe...@googlegroups.com

Hi Heinz

I'll add it to the todo list but tracing it down to a minimal example could take quite some time and I'm not sure when I'll get to it.

When I do I'll l let you know. Thanks for your work on this.

Jason

Heinz Hölzer

unread,
Jul 4, 2013, 9:14:12 PM7/4/13
to haxe...@googlegroups.com
Small update, i added a quickpanel to jump to any type of the current build. Just press ALT+P to get a list of all types in the current build, the quickpanel is initially filtered by the current selection or the word under the cursor. You can also jump to all types defined in your referenced haxelib libraries.

have fun,
h


On Sunday, June 23, 2013 2:14:20 PM UTC+2, Heinz Hölzer wrote:

Jason O'Neil

unread,
Jul 4, 2013, 10:41:44 PM7/4/13
to haxe...@googlegroups.com
That is incredibly useful... especially for jumping to private types, types that are within a different module or types that you don't have included in your sublime project.

Thanks!  All this work has really taken sublime from an "okay" haxe editor to one with some really great features.


Jason O'Neil

unread,
Jul 4, 2013, 10:52:57 PM7/4/13
to haxe...@googlegroups.com
Hi Heinz

The errors I was receiving are due to my project not playing nice with the completion server - so no fault on your end, sorry for misleading you.  When I disable the completion server (by adding ```"haxe_use_servermode": false``` to my project file) everything works like a charm.  (It's slow, but at least it's async now :P)

I think the issue is to do with Context.defineType() that we mentioned in another thread, and that is similar to Alex's problem also.  I may try refactor my code to use onTypeNotFound() instead, or submit an issue and try get Nicolas to look at it.

Jason

Dan Korostelev

unread,
Jul 5, 2013, 2:30:11 AM7/5/13
to haxe...@googlegroups.com
Thanks, this feature is great and much needed. I think it would be cool if "jump to declaration" feature would work for types automatically though.

пятница, 5 июля 2013 г., 5:14:12 UTC+4 пользователь Heinz Hölzer написал:

Chris D

unread,
Jul 5, 2013, 3:04:15 AM7/5/13
to haxe...@googlegroups.com
Yeah working great on Mountain Lion :)
Compiles openfl, selects openfl targets, jumptodeclaration is that the same in the api as goto_definition?

I put this in to get it to work with mouse ctrl click, I think its a good default.

// file Default.sublime-mousemap
[
{

"button": "button1", "count": 1, "modifiers": ["ctrl"],"press_command": "goto_definition"

}
]

I cant see "Show Documentation" working should this work with most things in the Std library?
Also I remember seeing a preview of method paramaters in Sublime when you do new Type"(" and on every "," is this working for you?

Also I am quite fresh to spending time in Sublime, whats the best way to setup an openfl project?
Right now to get the apis available to browse I drop everything as a folder like this, is this the intended workflow?

{
"folders":
[
{
"follow_symlinks": true,
"path": "/Users/omni/projects/repos/public/flixel-samples/Collisions"
},
{
"follow_symlinks": true,
"path": "/usr/lib/haxe/std"
},
{
"follow_symlinks": true,
"path": "/usr/lib/haxe/lib/flixel/2,0,0-alpha,3"
},
{
"follow_symlinks": true,
"path": "/usr/lib/haxe/lib/openfl/1,0,4"
}
],
"settings":
{
"haxe_exec": "/usr/lib/haxe",
"haxe_library_path": "/usr/lib/haxe/std",
"haxe_use_debug_panel": true,
"haxelib_exec": "/usr/lib/haxe/haxelib"
}
}

Cheers for your efforts, unfortunately IDE support is often the strongest "criticism" against using Haxe.

Heinz Hölzer

unread,
Jul 5, 2013, 7:08:13 AM7/5/13
to haxe...@googlegroups.com
Hi Jason,

Yes you have to be really careful especially when creating/storing state inside of macros this can easily lead to problems with the completion server. Btw. Context.defineType is fine to use (i opened the thread, but it seems that my assumption was wrong). But it's important to use it in combination with MacroType to have an alias for the defined type. But yes, onTypeNotFound is also an alternative.

best,
h

Heinz Hölzer

unread,
Jul 5, 2013, 7:18:56 AM7/5/13
to haxe...@googlegroups.com
no it's not the same api, jumptodeclaration used the compiler to jump to a declaration, which is exact when its working in the current context (it depends on macro helper functions, so there are limitations). The jump to type command uses the same logic that is used for toplevel completion. It collect all types from all classpaths in your build file and filters these types depending on your target. This is far from perfect (just regexp based) and you get also types listed that you can't use in your project (conditional compilation), but apart from this imperfection it works very good in most cases ;). 

I cant see "Show Documentation" working should this work with most things in the Std library?
Also I remember seeing a preview of method paramaters in Sublime when you do new Type"(" and on every "," is this working for you?

 did you get some error like "Cannot find declaration for expression type" in your output panel? Make sure you have a build selected (CTRL + SHIFT + P)

best,
h

Heinz Hölzer

unread,
Jul 5, 2013, 7:19:29 AM7/5/13
to haxe...@googlegroups.com
sorry it should be CTRL + SHIFT + B

Heinz Hölzer

unread,
Jul 5, 2013, 7:22:30 AM7/5/13
to haxe...@googlegroups.com
The problem is that it is not reliable, we don't have the required AST Information to get the exact type under your cursor. Hopefully there will be compiler support which would allow such things.

Heinz Hölzer

unread,
Jul 5, 2013, 6:02:08 PM7/5/13
to haxe...@googlegroups.com
i added a new feature ;)

jump to field, like jump to type but it let's you jump to any defined field based on the classpaths in your build. (Shortcut ALT+M).
all available commands can also be found in the command palette (i added the missing ones).

Please let me know (or post issues) if you have other ideas (not too difficult ones ;) ) which would improve the general workflow with sublime.

best,

Chris D

unread,
Jul 5, 2013, 10:59:15 PM7/5/13
to haxe...@googlegroups.com
Thanks for spelling that out no kidding its not the same its hell more useful, my mouse map has been upgraded :)

[
    {
        "button": "button1", "count": 1, "modifiers": ["super"],"press_command": "haxe_find_declaration",
    },
    {
        "button": "button1", "count": 1, "modifiers": ["option"],"press_command": "goto_definition",
    },
    {
        "button": "button1", "count": 1, "modifiers": ["ctrl"],"press_command": "haxe_goto_build_fields",
    },
    {
        "button": "button1", "count": 1, "modifiers": ["shift"],"press_command": "haxe_goto_build_types",
    }
]

Show documentation is working now when available, maybe I was doing something wrong, I'll report it if I can reproduce it.

Ideas? Not easy, but I saw this refactoring lib written in haxe https://code.google.com/p/hxrefactor/ looks like it was updated recently.
Enjoying using your work here, Cheers.
Reply all
Reply to author
Forward
0 new messages