Giter Site home page Giter Site logo

vshaxe / vshaxe Goto Github PK

View Code? Open in Web Editor NEW
323.0 22.0 54.0 4.34 MB

Haxe Support for Visual Studio Code

Home Page: https://marketplace.visualstudio.com/items?itemName=nadako.vshaxe

License: MIT License

Haxe 99.87% JavaScript 0.13%
haxe vscode language-server vscode-extension

vshaxe's Introduction

Haxe Support for Visual Studio Code

This is an extension for Visual Studio Code that adds support for the Haxe language, leveraging the Haxe Language Server. It works best with the latest Haxe 4 release, but supports any Haxe version starting from 3.4.0.

demo

Some framework-specific extensions exist to extend the functionality further:

Features

This is just a brief overview of the supported features. For more details, check out our extensive documentation.

Building

For instructions on building/installing from source, please see the dedicated wiki page.

vshaxe's People

Contributors

alexhaxe avatar dependabot[bot] avatar dpomier avatar filt3rek avatar gama11 avatar haxiomic avatar jonathantylercombs avatar joshtynjala avatar kallekro avatar klabz avatar nadako avatar nuclearcookie avatar rblsb avatar romamik avatar simn avatar tobil4sk avatar waneck avatar wiggin77 avatar yuxiaomao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vshaxe's Issues

Highlight "is" as a keyword

The new is "keyword" in 3.3.0 should be highlighted, but only in places where it's valid (i.e. surrounded by the mandatory parens):

// should not be highlighted
var is:Int;
// should be highlighted
trace((5 is Int));

"Initialize VS Code project..." generates invalid json with only one hxml

If there's only one build.hxml, the command generates this:

{
    // These are configurations used for haxe completion.
    //
    // Each configuration is an array of arguments that will be passed to the Haxe completion server,
    // they should only contain arguments and/or hxml files that are needed for completion,
    // such as -cp, -lib, target output settings and defines.
    "haxe.displayConfigurations": [
        ["build.hxml"], // if a hxml file is safe to use, we can just pass it as argument
        // you can add more than one configuration and switch between them
        //["build-cpp.hxml"]
    ]
}

Notice the trailing comma after ["build.hxml"]. This leads to a "Value expected" error when viewing the file in VSCode.

If there are two .hxml files, the generated json is valid:

{
    // These are configurations used for haxe completion.
    //
    // Each configuration is an array of arguments that will be passed to the Haxe completion server,
    // they should only contain arguments and/or hxml files that are needed for completion,
    // such as -cp, -lib, target output settings and defines.
    "haxe.displayConfigurations": [
        ["build.hxml"], // if a hxml file is safe to use, we can just pass it as argument
        // you can add more than one configuration and switch between them
        ["build.1.hxml"]
    ]
}

"Change to" messes up selection

Usually, you'd want to continue typing after the "change to ..." action, but you need to clear the selection first / move the caret, because otherwise this happens:

Completion requests queued up

Copied from Gitter:

on vscode haxe, do the completion requests queue up? I mean when I am typing, the IDE should be sending requests to the completion server continuously, will the server discard the old one when it receive a new one, or they just queue up? My problem is that the haxe process used up 100% CPU for like a few minutes even I stopped typing anything. (and completion just won’t work during that period)

"Remove all unused imports" quick fix

Right now, it's a bit tedious to apply the quick fix to each unused individually if there are multiple in a file.

I guess ideally, there'd be a context menu here with an entry for that, so you could do it for all warnings in a file at once (sort of works like that in IntelliJ IDEA for Java):

But I suspect VSCode does not support that? I guess an easy solution would be to just have it as an additonal quick fix entry on the current file.

Add highlighting for untyped functions (__js__, __java__, etc)

Some of these are documented in the manual, but there's actually a lot more than the ones that are documented:

https://haxe.org/manual/target-javascript-untyped.html
https://haxe.org/manual/target-php-untyped.html

The best option to get a comprehensive list seems to be searching the std lib for __[\w]+__ and manually filtering out false positives.

It would be nice if the highlighting isn't global and only takes effect after the untyped keyword (they seem to be valid Haxe variable names for instance).

Error messages not visible when hovering

I don't know why, but sometimes when I hover my mouse to a red underlined codes,
I got no error message at all. It just shows me the type info.
But with obvious error like using undefined variable in that line, it underlines again to that word and shows me the error message.
When I try same code at try.haxe.org, it actually shows me right error message.

What would be the problem?

+I think this occurs when the error is related to generics

Pluggable display argument providers

A lot of frameworks have their own project files and an option to generate display arguments from those files. It would probably be nice to support those as an alternative to haxe.displayConfigurations. To make it generic, I thought we could maybe support pluggable "display arguments provider" system", where haxe.displayConfigurations config is just one of them, but there's also others, like the one for openfl/lime that would be watching project.xml and re-read display arguments with lime display <platform>. I think we don't even need to touch language server for that.

While this isn't implemented, we should steal/adapt the "framework notes" table from vscode-haxe:
https://github.com/jcward/vscode-haxe#framework-notes

.hxml: show argument docs on hover

Seems like it'd be a really handy feature - should show the documentation text you get with haxe --help for that arg.

Potentially even docs for specific -D values based on --help-defines?

Nice to have error message

I have un-installed Haxe to update it to the developers branch via brew.
(I have filed an issue here: HaxeFoundation/homebrew-haxe#1)

After deletion, I started VSCode and got this message

The Haxe server crashed 5 times in the last 3 minutes. The server will not be restarted.

A nice-to-have would be to have a message mentioning that Haxe is not installed and how to install the latest and greatest.

Organize our marketplace offerings?

Hey @nadako and @Simn -

Are you interested in coordinating the VSCode marketplace offerings? I think there's a few oddities with the current state:

  • There are two Haxe extensions currently titled haxe and Haxe Support.
  • One publisher is haxedevs and the other is nadako.

It seems a bit scattered and unofficial.

I think a nice arrangement would be to have the publisher be Haxe Foundation, with both a Haxe extension (vshaxe) and something like Legacy Haxe 3.2.1 extension (vscode-haxe). I don't mind vscode-haxe being labelled legacy as I don't plan on putting more effort into it, and it looks like you guys are actively developing vshaxe with the latest compiler features. Maybe one day we'd remove the legacy plugin entirely.

However, I'm not sure whether we can technically change the names of either the plugins or the publishers (I got stuck on lowercase haxe because of that.) We'd have to look into that - maybe email support? If we had to remove and publish new extensions, that wouldn't be ideal as 1) we'd lose our download counts (which imply Haxe's popularity is higher than dart πŸ˜„ ), and 2) current users wouldn't get auto-update notifications.

If we can keep our plugins and download counts and change names, I'd be happy to send my publishing keys to the Haxe Foundation.

Thoughts?

Does not work..

I have just installed it, I am on openFL project, but it seems that the extension is not working, no completion, no goto definition..

Any idea what to check?

Deprecated function

Calling a deprecated function shows no indication/warning.

For instance trace(Sys.executablePath()); on hover should show the meta content "Warning: Use programPath instead" just like when compiling.

Run diagnostics more often than just on save?

It feels a little counter-intuitive to me that the import quick-fix only shows up after a save - at first I thought it wasn't working. Could we detect if there's a pause during typing and run diagnostics then?

The delay after typing stops could be made configurable (also to turn it off completely I guess), since the behavior might potentially annoy some people.

Display config in status bar only shows after the first opened .hx file

How to reproduce:

  • open a vscode workspace without any tabs open
  • open a .hx file - no status bar UI shows up yet
  • open a second .hx file - now the UI is here, and it stays even when switching to the other file

The UI should be visible right away for the first .hx file that is opened.

Haxe process was killed

On a fresh installation of vscode with the vshaxe extension on multiple different computers, I keep getting the message "Restarting Haxe completion server: Haxe process was killed"

I'm using Windows 10 64 and 32-bit versions, though previously I had the same issue on my Windows 7 64-bit desktop. Any assistance would be greatly appreciated.
(I'm also using 0.1.3 of vshaxe)

Progress indicator for global diagnostics runs

It would be really nice if there was some sort of progress bar or something that indicates the plugin is still working in the background... As is, you're never sure if there was some error running diagnostics, or if it's just taking a while (and it does take a bit with larg-ish projects like Flixel).

There's this blue progess slider thing that sometimes appears (during completion requests mostly) right under the tabs, maybe we can use that somehow via the API?

How to execute the resulted file?

I need to execute the file (swf file) that is a result of a successful compilation, but I have no idea how to do so.

What I know is the full path of the file, so I need to run a command like double click on the file after compilation.. any idea?

HXML language server

Just some ideas for IDE services for the HXML files:

  • haxe argument completion (-cp/-lib/etc), obviously
  • -D completion (from --help-defines and potentionally from HaxeFoundation/haxelib#262)
  • -D hover help (same as above)
  • -cp and --cwd completion (filesystem, why not?)
  • -lib completion (ideally we'd use haxelib as a library, but some ad-hoc solution would also work for now)
  • --macro completion (most probably hard to get right)
  • diagnostics: wrong -cp/--cwd, not-installed -lib, invalid --macro

Running global diagnostics right away takes two attempts

When using global diagnostics as an "acivation event" (use it as the first Haxe command after opening the VSCode window, before the extension has started up, see 0c558bb), it takes two attempts to work.

The first time, there's an empty response:

Haxe language server started
Processing Arguments [-version]
> 3.3.0 (git build development @ a847ec8)
Cached 0 modules
Stats = 0 files, 0 classes, 0 methods, 0 macros
Time spent : 0.000s

Only the second time, there are proper "parsed" messages and a completion response.

'Find all references' feature

Hi.

To start, let me thank you and congratulate you again for the great work you provided one more time to the community. This IDE plugin is really promising.

I was just wondering if 'Find all references' feature was on your todo list and if it is a tricky one to implement.

Thanks again for all.

Completion for unimported static extension functions?

It would be quite cool to have potential static extension functions appear in completion, even if there's not a using for them yet. If selected from completion, the using would then be added to the file automatically. Example - would be cool if StringTools functions appeared here:

This is done like I described in ReSharper for C#. Unfortunately, they have it a bit easier than Haxe - static extension methods need an explicit this keyword. In Haxe, any static method with at least one argument could theoretically be used (unless @:noUsing).

Maybe there could be an optional metadata that enables static extension methods to appear in completion? @:usingCompletion?


Btw, here's an example from ReSharper:

As you can see, static extension methods use a different icon that indicates "pull this from somehwere that's not imported yet" with the arrow.

Generate imports

This is a related, but different feature than discussed in #2. It should be much easier to actually implement.

haxe-sublime-bundle has a neat feature that allows you to type a fully qualified type path, then press a key combo and have an import statement generated at the top of the file:

It does simple text processing trying to guess what to actually import, it supports simple module and type imports and can have a number of false positives, but it's still very useful.

It would be cool to have the same in vshaxe, but to get it right, I'm afraid we need some compiler support. In Haxe we might want to:

  • import a while module
  • import a type from a module
  • import a static from a class
  • import everything from a package or all statics from a class (though these use cases are more rare)

To determine what options do we have and what to actually import (e.g. "is this a main module type? a type within a module? a static field of a class?") we need a display query that tries to resolve a given dot-path and gives us info about it.

Weird error display

Haxe outputs this:

> src/hxparse/RuleBuilder.hx:19: lines 19-69 : Array<haxe.macro.Field> should be haxe.macro.Expr

Which is displayed like this on hovering:

should be haxe.macro.Expr
src/hxparse/RuleBuilder.hx:19: lines 19-69 : Array

Project-wide diagnostics run

I'd imagine a common use case for diagnostics is having them run on an entire project so you can fix all the issues at once. This is similar to what haxe-checkstyle is usually used for.

My use case is that I'd like to get rid of unused imports in Flixel code, but I don't really want to go through each file manually for that (which would be necessary right now).

Of course, this would also be helpful for debugging this feature.

vscode haxe.json snippets file in case you're interested

pick whatever you want
I also plan on making some shortcuts for (mohxa or buddy) unit testing.

{
/*
     // Place your snippets for Haxe here. Each snippet is defined under a snippet name and has a prefix, body and 
     // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
     // $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
     // Example:
     "Print to console": {
        "prefix": "log",
        "body": [
            "console.log('$1');",
            "$2"
        ],
        "description": "Log output to console"
    }
*/

/*

"Name": {
    "prefix": "...",
    "body": [
        "",
        "",
        "",
        ""
    ]
},
*/

"Constructor": {
    "prefix": "ctor",
    "body": [
          "public function new() { }"

    ],
    "description": "default constructor in haxe"
    },


"main fn": {
    "prefix": "main",
    "body": [
            "static public function main():Void",
            "{",
            "   var args = Sys.args();",
            "}" ],
    "description": "main function"
    },


"static Function": {
    "prefix": "stfn",
    "body":[
        "static function ${1:fn} (${3:arg} ${4: :Type} ${5:, arg2:...} ) : ${ret:retType}",
        "{",
        "   var result:${ret:retType};",
        "   $6",
        "",
        "   return result;",
        "}" 
    ],
    "description": "static function"

},



"sfn": {
"description": "simple static fn",
    "prefix": "sfn",
"body":[
    "static function ${1:func_name} : ${ret:return_type}",
"{",
    "   var result:${ret};",
    "   ${body}",
    "",
    "   return result;",
    "}" 
]
},
"trace": {
"description": "trace",
    "prefix": "t",
"body":[
    "trace(${var});"
    ]
},

"fn": {
"description": "simple fn",
    "prefix": "fn",
"body":[
    "function ${1:func_name} : ${ret:return_type}",
    "{",
    "   var result:${ret};",
    "   ${body}",
    "   ",
    "   return result;",
    "}"
]
}   ,

"enum flags": {
"description": "enum flags, shamelessly copied from http://blog.stroep.nl/2015/08/biwise-operations-made-easy-with-haxe/ ",
    "prefix": "flags",
"body":[
    "// enum flags. taken from http://blog.stroep.nl/2015/08/biwise-operations-made-easy-with-haxe/ ",
    "@:enum abstract ${1:name}(Int) from Int to Int\n\t{\n\t\tvar None = 0;\n\t\tvar ${2:A} = value(0);\n\t\tvar B = value(1);\n\t\tvar C = value(2);\n\n",
    "static inline function value(index:Int) return 1 << index;",
    "inline public static function add(bits:Int, mask:Int):Int  return bits | mask;",
    "inline public static function remove (bits:Int, mask:Int):Int  return bits & ~mask;",
    "inline public static function contains (bits :Int, mask :Int):Bool return bits & mask != 0;",
    "inline function new(v:Int) this = v;",
    "inline function toInt():Int    return this;",
    "}"


]
}


}

"Workspace must be empty to set up a Haxe project"

When trying to "Haxe: Initialize VS Code project" with some existing files, but no hxml file at the root, I get the above error message. I think that could be misunderstood as refusing to initialize unless the whole workspace was empty, which wouldn't be the nicest requirement of course :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.