Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 569 - IDEs services: Find References - haxe #569

Closed
issuesbot opened this issue May 28, 2013 · 16 comments
Closed

Issue 569 - IDEs services: Find References - haxe #569

issuesbot opened this issue May 28, 2013 · 16 comments
Assignees
Labels
feature-ide IDE / Editor support

Comments

@issuesbot
Copy link

[Google Issue #569 : https://code.google.com/p/haxe/issues/detail?id=569]
by philippe...@gmail.com, at 13/11/2011, 20:39:51
IDEs need a Find References service to offer many code-related features like:

  • Find References
  • Refactoring

How it would work:

  • user moves the cursor over a text token,
  • editor locates the end of the word
  • editor calls haxe compiler with a special switch like --display
  • haxe resolves this token and returns the file:line:column where it is declared
    and all the file:line:column where it is called.

Obviously it should work for local vars and function parameters.

@issuesbot
Copy link
Author

[comment from ncanna...@gmail.com, published at 11/03/2012, 11:34:41]
Note for local vars and function parameters : this is a bit hard to do since we don't have the accurate infos of their position within the source file. We could add it but that would be a significant amount of memory overhead.

I guess that Find-Reference is much more useful for class fields than for locals, is it ?

@issuesbot
Copy link
Author

[comment from ncanna...@gmail.com, published at 11/03/2012, 11:36:25]
Issue 568 has been merged into this issue.

@issuesbot
Copy link
Author

[comment from ncanna...@gmail.com, published at 11/03/2012, 11:51:54]
Issue 570 has been merged into this issue.

@issuesbot
Copy link
Author

[comment from philippe...@gmail.com, published at 11/03/2012, 12:27:42]
I suppose it's not a big problem if local vars are missing. At least not
for FlashDevelop.
Le 11 mars 2012 12:35, <haxe@ googlecode.com> a �crit :

@issuesbot
Copy link
Author

[comment from back2dos@gmail.com, published at 11/03/2012, 13:44:09]
I don't think the information needs to be stored, but it can be retrieved just in time.

For variables, take the position of the variable declaration statement (which is known already), extract the corresponding string and therein just do a backward string search for the identifier (var x = 5, x = "foo" is valid haXe code). This can be done with function arguments similarly, with a background string search from the beginning of the function body to the beginning of the member declaration.

Of course this can just as easily be accomplished by every IDE, but it's a rather cheap enhancement and including this in the IDE services would provide better separation of concerns IMHO.

@issuesbot
Copy link
Author

[comment from ncanna...@gmail.com, published at 17/11/2012, 00:47:12]

@issuesbot
Copy link
Author

[comment from si...@haxe.org, published at 31/01/2013, 19:51:12]
Some thoughts:

Goto: This one is really easy and works exactly like field completion, just with different output.

Metadata: Likewise.

References: That's quite different. We don't even want to enter display mode here, but instead type normally and mark the subject field. Then a small post-process iteration over the typed AST can easily detect usage. This will be slower than the other display modes, but that is to be expected.

All this seems easy to implement, the only thing stopping me from doing so right now is the parser. Without a unique token for completion, we would have to do position checks after each identifier, which seems quite sub-optimal. Would it be viable to require IDEs to insert such a token?

@issuesbot
Copy link
Author

[comment from philippe...@gmail.com, published at 31/01/2013, 20:04:41]
I didn't understand what you want IDEs to provide.

@issuesbot
Copy link
Author

[comment from si...@haxe.org, published at 31/01/2013, 20:18:38]
I was thinking that inserting a special character after the identifier you want information for would be the easiest for both sides, like:
foo.bar with the letting the parser know that we want completion (of some kind) for foo.bar.

If you have to make a temp save of the file anyway (I think you do?) then this seems reasonable, no?

Unless of course Nicolas had something entirely different in mind for this.

@issuesbot
Copy link
Author

[comment from philippe...@gmail.com, published at 31/01/2013, 20:23:22]
I think modifying the source is pretty much out of question.

If the problem is about Find References, then we can workaround that by calling the Goto feature from the IDE for each occurrence of the searched token. That's what FD does in AS3 for instance.

@issuesbot
Copy link
Author

[comment from si...@haxe.org, published at 24/02/2013, 17:12:14]

@issuesbot
Copy link
Author

[comment from ncanna...@gmail.com, published at 11/05/2013, 19:27:19]
Issue 1807 has been merged into this issue.

@issuesbot
Copy link
Author

[comment from si...@haxe.org, published at 11/05/2013, 19:29:14]
Issue 1807 has been merged into this issue.

@issuesbot
Copy link
Author

[comment from si...@haxe.org, published at 11/05/2013, 19:30:49]
Issue 1807 has been merged into this issue.

@issuesbot
Copy link
Author

[comment from si...@haxe.org, published at 12/05/2013, 17:49:38]
I found a quick hack to support local usage detection. I originally thought we should wait for TMeta for a cleaner solution, but I don't think that would actually help as we have to mark the variable itself and not its expression.

By the way, I never mentioned this here but -D display-mode=usage|position|metadata is already supported for class fields, although we still need to hook it into the parser.

@issuesbot
Copy link
Author

[comment from si...@haxe.org, published at 12/05/2013, 20:41:12]
I just realized that this works fine:

haxe -D display-mode=usage --macro addMetadata('@ :usage','Array','push') --macro include('haxe',false) -dce no

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-ide IDE / Editor support
Projects
None yet
Development

No branches or pull requests

2 participants