This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Provide code completion for properties based on web service that returns JSON | ||
---|---|---|---|
Product: | web | Reporter: | Petr Jiricka <pjiricka> |
Component: | AngularJS | Assignee: | Petr Pisl <ppisl> |
Status: | NEW --- | ||
Severity: | normal | CC: | dkonecny, mfukala, mkuchtiak, ppisl |
Priority: | P2 | ||
Version: | 7.4 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: | |
Bug Depends on: | |||
Bug Blocks: | 234990 |
Description
Petr Jiricka
2013-06-26 20:44:58 UTC
I can imagine few solutions. #1) An AngularJS specific solution would be to hook into AngularJS in runtime when page is executed and inspect AngularJS Scopes. If you install "AngularJS Batarang" plugin to Chrome and run this app in CDT you will get to see hierarchy of AngularJS scopes and what they contain. The IDE could grab the snapshot and persist it (and always keep last page execution snapshot in userdir mapped to an HTML) and then use the data hierarchy in code completion. This could be fairly accurate with occasional mistakes when runtime snapshot is outdated and does not contain the latest code changes. #2) A generic (and more heuristic and more error prone) solution would be to take a snapshot of all data structures fetched from network during rendering of a single page. This would happen again in runtime when page is opened in browser and would provide following information: "these data structures are used during rendering of this page". (and snaphost would be again persisted in the userdir and mapped to an HTML) And code completion on this HTML (and its dependencies) would offer all names collected from the data structure snaphost. It may sound lame but in practice I can imagine it could work fairly well. For example in Petr's /partials/contributors-list.html after user wrote {{contributors.data.length}} and {{contributor.login}} we are positive which datastructure corresponds to {{contributors}}. And even without that just offering in code completion names of JSON datafields would still help. Any other ideas?? Comments? Thanks David. With #1, to clarify are you suggesting that we use the "AngularJS Batarang" plugin itself and require the user to install it, or that we use a similar approach that this plugin is using? It seems like we can't rely on this plugin, as it requires CDT, which of course is a conflict with our connector. Today I also filed another AngularJS-specific enhancement (issue 231924), which I assume could also be addressed by approaches #1 and #2. But that enhancement may also be solvable by directly analyzing the code. The disadvantage of both #1 and #2 is that first you need to run the page to get the runtime data and initialize the code completion, but: - I think that's still fine, most of the time you are tweaking existing code rather than writing new. - I don't see any way to do that without information from the runtime > "or that we use a similar approach that this plugin is using"
This is what I meant. The plugin was just an example of what can be extracted from the AngularJS in runtime.
|