klesun/deep-js-completion

TODO list

Opened this issue · 3 comments

Normal Priority

  • Should stop suggesting the var name from the following line as a key:
    image

  • Should provide property name completion in object destructuring assignment.

  • Should allow using different operation in local var jsdoc, like taking an element from array, not just calling it.

  • Should support typescript ReturnType<>

  • flatMap after flatMap - arg type not infered
    image

  • Should not suggest private class fields in typescript

  • When completing keys with special characters (like space) or numbers, should make it obj['some Key'] instead obj.Some Key. (webstorm does that for typescript keys)

  • Completion should work here: (flatMap() result; store.pricingBlockList[0]... does not seem to provide completion either, even though store.pricingBlockList.map(a => a)... does)
    image

  • Completion should work here: (result of function passed to a functiion)
    image

  • Make it possible to specify some directories to distinct modules with same names in jsdoc:

    * @param linearFare = require('Galileo/Pricing/LinearFareParser.js').parse()
    
  • Support and complete lodash get keys. Should suggest: bookingClass, segmentNumber here
    image
    and here as well
    image

  • Completion should work here: (lodash groupBy)
    image

  • Completion should work here: (again lodash map)
    image

  • Would be cool to be able to go to string by value in === expression like in php plugin.

  • It would be nice if current scope var completion worked as well, example: @param gdsData = parseCmdRs()

  • GoTo require() in the docs, pls

  • GoTo does not work here even though completion does:
    image
    image

  • Complete var names in @param a = at('SomeFile.js').someVar

  • Make @param a = at('File.js').varName support vars defined inside methods and anonymous functions (it currently only goes inside functions defined like var someVar = () => {...}).Also, please, exclude require() vars from completion options.

  • Completion still takes 800 ms even though there were just 300 expressions. I suspect that major part of CPU is spent on stuff like VarRes::findVarUsages. Should optimize it somehow if this is the case. I also have suspicion about JSScopeNamesCache.getOrCreateNamesForScope...
    Upd.: 300 ms gets taken by VarRes::findVarUsages. Could optimize that with reference search or some kind of caching like a hashmap per file or psi with var name as key.

  • When both this plugin and deep-assoc-completion are loaded, make /** @var hotel = DataFormats::getHotelById() */ provide completion using the type resolution from the other plugin.

  • Private func completion should work when you pass this function to .map(someFunc), .filter(someFunc), etc... by reference instead of directly calling it with .map(a => someFunc(a)).

  • Make it possible to specify return type as well in the docs like this: /** @return {Promise} makeSessionRecord() */

  • Replace hardcoded map, reduce, then, etc... completion logic with generics from built-in d.ts files.

  • Go To express route on Ctrl + B at string literal matching the route. Take that routes are defined in server.js or WebRoutes.js.

  • String value === completion.

  • Add inference from promise-sql SELECT * FROM {$tableName}

  • It would be nice to have path completion in the doc. Especially cool would be that when you type @param db = from('Db.es6') you got './backend/Utils/Db.es6' completion from all files with such name. Actually, this completion would be useful when you type real require('') as well

  • It would be handy, if in node project instead of import Db from "../Db.es6"; auto-import added const Db = require('../Db.es6');. Just an action that would convert them will be fine too.

Low Priority

  • When completing a method, should add parentheses in the end, since it's more often that you want to call a method, than to pass it somewhere.

  • When choosing what module to use in "Require by var name" intention - put @deprecated ones in the bottom of the list.

  • Guessed built-in completion options still corrupt the deep completion:
    image

  • I have a genius idea - when you Ctrl + B on a AMD define() module in func args, GoTo the path it corresponds to:

    define([
        'application',
        'abstract/dom_builder',
        'abstract/helper',
        'abstract/user',
        'page/common/constants',
    ], function(App, Dom, Helper, User, Constants) {

    Or maybe it's even possible to highlight them as references with Refernce Provider?

  • Should infer this.field type
    (Upd.: this would be rather troublesome since IDEA does not provide API to resolve all this usages in a class. Also, the completion would work here if you explicitly declared state as a cass field above the constructor)

    constructor () {
        this.state = {
            formData : {
                userOffices : [1, 5, 7],
                advancePurchase : {
                    units : "days",
                    amount : 0
                }
            }
            open : false
        };
    }
    
    render () {
        const {formData} = this.state;
        const {advancePurchase} = formData;
    
        console.log( formData.   <== zdesj suggest (advancePurchase, userOffices) );
    }

Resolved

  • Completion should work here: (possibly because it is es6 export) 8973690
    image

  • Should make implicit depth limit configurable. Possibly raise it by default after testing. 4d9704c

  • When resolving private func passed to map/filter/etc... as just var, rather than called in an arrow function, arg completion should still be inferred. a8194db

  • Completion from .d.ts file hangs indefinitely, possibly circular reference. 4fab7c5
    image

  • Should fix irrelevant then/catch/finally suggestions from vars infered from jsdoc. c19db40

  • Completion should work here: (array shift() not resolved, possibly related to 6ca0cee) 88db9de
    image

  • Require by name intention should require node modules without relative path: 6c56af4
    Is:
    image
    Should:
    image

  • Should suggest: fareType, gds, pcc, etc... here: (... in function object argument, would be cool to even filter out itinerary from suggested fields) 4621f2a
    image

  • Completion is rather slow here: (it would be faster to type the key myself than wait these 1.26 seconds, and it feels more like 2 seconds) f8dc39d
    image

  • Should also suggest: 'pcc', 'recordLocator', etc... here 58dcbeb
    image

  • Completion should work here: (generic type passed to dts interface) a0d202f
    image

  • Completion should work here: (lodash map - should support generics in the definition) 6cf404d
    image
    image

  • Completion should work here: (Array.every() arg) 6e9c685
    image

  • Completion should work here: (onDemand() wrapper func) 7fc9b62
    image

  • Instead of *|*|* show the PSI associated with the property in the value preview. For a in {a: dStuff()} it should be doStuff(), for b in obj.b = doOtherStuff() it should be doOtherStuff(), for c in static c(arg) {} it should be (arg) => {} and so on... 52d5107

  • Completion should work here (suggest: cmd, output, type, etc...)
    image
    (failing test case demonstrating the cause of the issue: 1a89334) fixed in 03a1a34

  • Should implement somehow when you click Alt + Enter on an undeclared variable, if it matches some file name, that it would suggest adding require statement with the path to this module (if the file is a CJS module). 8b757b8

  • Should not suggest fields returned in an async function, as it actually returns a Promise: 0a8cff1
    image
    Another relevant example:
    image

  • image no completion of segment fields here - should fix. 7e33808

  • Completion should work here: 7e33808
    image

  • Completion should work here: b998e2b
    image

  • Coompletion should work from npm module index file exports.someField = .... (defined in main field of package.json) b5b68a4
    image

  • Completion should work here: b5b68a4
    image

  • Wrong suggestion: pricingPart (I suspect assignment resolution treats processed.pricingPart.parsed.pricingList[0] as assignment destination)
    image
    51f2700

  • Completion should work here (probably plugin does not look for private func usages because it's a class) 63d9e57
    image

  • Completion should work here: 75dabd0
    image

  • Object class properties should not be suggested here, and it should not hang for several seconds, and cmd/type/data should be suggested: 8ac6a3c
    image

  • image - something conflicts with something. If you remove TRAVELPORT and AMADEUS, you get completion in SABRE, otherwise you only get completion in TRAVELPORT. 45d5eba

  • When async function returns a promise, you have to type await twice in order to reference the wrapped value: image. It should work with just one await. ba264fe

  • Completion and GoTo still take many seconds in some places (Component.observe() in CMS). bb59247

  • Complete property names in @param a = require('SomeModule.js').someField 589bae3
    Upd.: damn webstorm does not show completion in the doc when caret follows a (, a " or '. Should investigate and look for workarounds like making text followed by an = a code injection.

  • Complete file name in @param a = at('SomeFile.js') and require('SomeFile.js') (probably should put files from current directory and it's sub-directories first, the from it's parent, then from it's parent, etc... so that stuff like node_modules was at the very end (maybe even exclude it altogether)) 3a0ccf5

  • Support Promise.all ac20986

  • Should resolve the d.ts type definitions even without the help of the built-in typing so that Ctrl + B on properties defined there worked. 55ce922

  • Should eventually return resolved types in an iterator same way as in the php plugin, since there are already some places that take something near a second to complete. See klesun/deep-assoc-completion#47 3c8dfb7

  • Completion sometimes takes 4 seconds - it should not. image Another example: image Should at least, if resolution takes more than, let's say 0.2 s, show built-in completions before proceeding with the resolution. Some investigation and optimisation would be nice too, maybe this is already time to move to iterators... 3c8dfb7

  • Completion should work here: image (the issue is possibly that this is used inside, and we ignore built-in type of member access) c09772e

  • Should support new and class methods. VERY NEEDED. Probably related to the issue below. 55ce922

  • Allow to specify = type in @member, @type, @var, etc... jsdoc-s, not just @param 0377be6

  • Completion should work here: image - should have suggested: id, logId, createdMs, context, sessionData. Possibly it does not work because Promise.all() does not get resolved completely. ac20986

  • Prototype object properties should not show in the top of the list: image This happens because I use built-in type resolution here from d.ts file, which probably lists inherited properties before own properties... a3447b8

  • Add for (let [k, v] of Object.entries(obj)) support (and any other function obviously). 5e997ed

  • Invent the doc format that would allow referencing unexposed functions in other files. Something like /** @param segment = {date: in('/app/parsers/common.js').parseDate()} */.
    Or maybe from('/app/parsers/common.js').in('init').in('makeDefaultParams').var('fareTypeCodes') 0aa883b

  • Support tuple destructuring assignment and args. 6153271

  • Gosh, I really want to stop using the method resolution by built-in resolver: image - it gives you any function named that way ignoring the object type altogether. Maybe there is a parameter at least to tell it not to fallback to anything somewhere? Actually, can make things simpler - do not use built in resolution when it's a reference expression with a qualifier (we'll still use built-in to resolve the qualifier anyway, so no useful type info will be lost). 6ef91dd

  • It would be nice if completion worked here: (just the name of file without path in require and a property on it is accessed and invoked) image 71700cb

  • A bug: (completion should not be suggested on a var name - it should be only property name (l guess this happens because both property access and var access are a JSReferenceExpression)) image
    Another one:
    image 79c4e3e

  • A bug: Promise.resolve(A).then(A => B) gets resolved as Promise<A> if B is an empty object.
    image
    image
    82f337f

  • IMPORTANT: infer type of rq and rs in:

    let app = express();
    app.use((rq, rs, next) => {});
    app.get('/some/route', (rq, rs) => {});
    app.post('/some/route', (rq, rs) => {});

    24dccfd

  • Should infer element type from for loop:
    image
    Suggested keys should be: key, value, enabled (the key is probably suggested because it is referenced in an assignment, what is wrong by the way). c0dbf2f

  • Wrong completion:
    image
    It should be id and stuff. 6830feb

  • In [].reduce((sum, next) => sum..., []); sum must have completion of the lambda return type, not the same completion as next.

  • Completion should work here: 42abf5e
    image

  • Completion from property access currently suggests stuff as if accessed property name was undefined:
    image
    The then is taken from Dom.showMessageDialog, the s, trigger and with are taken from Dom.wrap. Rest is already suggested by IDEA. Should fix. Probably caused by some IDEA string index types without actual string value being mixed with deep types. bf10eff
    And generally, plugin should be disabled when inside a typescrypt file: there is nothing to improve there.

  • Go To Definition. IDEA navigates you to all properties with same name in the project. Would be good to at least put correct (read "mine") options first. 8f13375 (Upd.: looks like idea does not suggest anything with same name when I provide at least one GoTo option)

  • Doc completion like @param denis = Denis() does not work with top-level vars, it only works if var is defined in the scope of a function. 56be76f

  • Apply some optimisation. Currently getting completion in GdsSessionController.runInputCmd result takes 1.614... seconds, most likely because of how reference search in VarRes is implemented (scanning whole file each time). 13cf3e1

  • Add inference on function arg based on what is passed to this function. 64f5cd3 97942e4

  • Resolve new Promise((resolve) => ... resolve(value) ...). 19a05e4

  • Infer array type from push and index assignment: 57a801b

let flatTracks = [];
flatTracks.push({trackNum: i, chan: ownChan, events: ownEvents});
flatTracks[i] = {trackNum: i, chan: ownChan, events: ownEvents};
flatTracks.map(a => a.); // should suggest [trackNum, chan, events]
  • Completion from promises VERY NEEDED 47fd2b3

  • Go To key key definition when Ctrl + B on a key in let {range, opt} = lib; 0269932

  • Support let {range, opt} = lib; assignment 7449f03

  • Infer type of modules required like this: c811edb

var klesun = Klesun();
klesun.requires('./Tls.js').then = (Tls) =>
klesun.requires('./MidiUtil.js').then = (MidiUtil ) =>
klesun.whenLoaded = () => {

    let {range, mkDom, opt, promise, deepCopy} = Tls();
    let {ticksToMillis, isNoteOn, isNoteOff} = MidiUtil();
    let $$ = (s, root) => [...(root || document).querySelectorAll(s)];
  • Infer type of binary expression arrow function: 5465738
let collectParams = () => 1 && {
    ticksToTempo: dict($$(':scope > *', tempoList).map(block => [
        +$$('input.start-at', block)[0].value,
        +$$('input.tempo', block)[0].value,
    ])),
    tempo: tempoInput.style.display !== 'none' ? tempoInput.value : null,
    scaleRegions: $$(':scope > *', regionListCont).map(collectRegion),
    sentences: $$(':scope > *', sentenceListCont).map(collectSentence),
    configTracks: $$(':scope > tr.real', trackList).map((t,i) => 1 && {
        trackNum: i,
        instrument: opt($$('select.instrument', t)[0]).map(sel => sel.value || null),
        velocityFactor: $$('.holder.original-volume', t)[0].innerHTML <= 0 ? 1 :
            $$('input.track-volume', t)[0].value /
            $$('.holder.original-volume', t)[0].innerHTML,
    }),
};

collectParams().; // should suggest [ticksToTempo, tempo, scaleRegions, sentences, configTracks]

  • ~~Add inference in map, forEach, filter, etc...~ cadcb8e

  • When Only type-based completion in settings is set, behave as is - add completions only if no such option from built-in completion. If the flag is not set however, built-in suggestions should be skipped instead if got same prop name, and plugin completions should be in the top of the list. 3c15780

  • Completion does not work in phpstorm for some reason. Should investigate: a7593d6
    image

  • Would be nice to have completion and refactoring here: (like php does) ba569ba
    image

Great list. Let me know if you need a testing job!

Got it. Your reports are a great help, thanks a lot!