[REVIEW ONLY] Bare async provider implementation.#6375
[REVIEW ONLY] Bare async provider implementation.#6375busykai wants to merge 1 commit intoadobe:irichter/code-inspection-improvementsfrom
Conversation
Not working due to an issue in code inspection implementation (html template is displayed before it's rendered).
|
Like I said on IRC, the problem here is the fact than an inspector could take too much times before resolving or rejecting the promise returned by
(sorry for my horrible english) |
|
Wrt to the timing and consecutive calls to define(function (require, exports, module) {
var results;
function getResults(text) {
// get results
...
.then(function (myResults) {
results = myResults;
}
}
function scanFileAsync(text, fullPath) {
...
getResults(text)
.then(function() {
promise.resolve(results);
}
}
}It is plainly the problem of the provider implementation (specifically it is a problem of using module-wide variable to pass data between the functions). If the function Independently, of this "reentrance" issue, a limit should be put on execution time of each scan. Wrt the same name of the function, I don't see how approach implemented in CodeHintManager.js is any good. Especially, taking into account that linting providers are much more popular (as extensions) compared to code hinting. It is reflected in the comment to this PR too. Having separate function will help to document it and requirements to the implementation (such as the one you brought up) separately. Let's see, however, what core team (@peterflynn, particularly) will have to say. |
|
By the way, here is an example of JSHint extension ported to this new implementation: busykai/brackets-jshint@df15fb33d . It has significantly simplified the implementation: busykai/brackets-jshint@master...use-async-run |
|
I do like the the conceptual clarity seperating the snych and asynch variants of the scanning function. Also performing the scan in parallel makes sense to me. |
@peterflynn, @ingorichter, @fdecampredon please take at this implementation draft. It introduces an optional
scanFileAsyncfunction in the provider interface which when implemented will be used instead of syncscanFileto get the code inspection results. I chose to introduce a separate function since I, personally, don't like multi-semantic functions (e.g. the samescanFilewhich may return an array or a promise). If there's a compelling argument to overload semantics ofscanFile, let me know.Not working due to an issue in code inspection implementation (html template is displayed before it's rendered). See this comment to #5935. If you want to try it out, just move rendering into the same block where
htmlis prepared (into.thenhandler).This is just to get a general agreement on the proposal/approach, a lot of work is missing on the documentation etc. A mergeable PR will be prepared when #5935 is landed in master.