ScreepsAutocomplete icon indicating copy to clipboard operation
ScreepsAutocomplete copied to clipboard

Visual Studio Integration

Open zackman0010 opened this issue 8 years ago • 9 comments

image I'm getting the above error when attempting to integrate the ScreepsAutocomplete into Visual Studio 2015. The only thing that is successfully being autocompleted is Game. I followed the instructions and added the _references.js file correctly. I also followed instructions from another site that makes Intellisense recognize the _references.js as a proper reference file.

zackman0010 avatar Oct 05 '16 04:10 zackman0010

On further testing in VS, I found that it's simply not treating the result of Game.spawns['Spawn1'] as a Spawn object. Using the code 'var testspawn = new Spawn(); testspawn.' will show the autocomplete functions correctly.

zackman0010 avatar Oct 05 '16 20:10 zackman0010

I can confirm this issue. It's weird because Game.spawns is clearly labeled as @type {Array<string, Spawn>}

Tim-Pohlmann avatar Dec 11 '16 16:12 Tim-Pohlmann

Stuff like room.storage is not recognized as StructureStorage either =/

Tim-Pohlmann avatar Dec 12 '16 20:12 Tim-Pohlmann

I found the issue. For VS IntelliSense to work you need to use comments of this stlye: https://msdn.microsoft.com/en-us/library/bb514138.aspx

If I replace the comment for Room.storage like this, it works:

/// <field name='storage' type='StructureStorage'>The engine's hefwforsepower.</field>
storage: null,

using 'undefined|StructureStorage' doesn't seem to work, however.

Tim-Pohlmann avatar Dec 12 '16 20:12 Tim-Pohlmann

Ok there is a better way: The issue seems to be that for class properties the @type comment is used instead of @property.

So if you replace this:

/**
 * The Controller structure of this room, if present, otherwise undefined.
 *
 * @see {@link http://support.screeps.com/hc/en-us/articles/203079011-Room#controller}
 *
 * @type {undefined|StructureController}
 */

with this:

/**
 * @see {@link http://support.screeps.com/hc/en-us/articles/203079011-Room#controller}
 *
 * @property {StructureController|undefined} controller The Controller structure of this room, if present, otherwise undefined.
 */

It works. I replaced @type with @prototype, swapped undefined and StructureController, added the property name controller and move the comment in the same line.

Tim-Pohlmann avatar Dec 12 '16 21:12 Tim-Pohlmann

had some problems finding out what to change. give me a list of files to update, and some info on what parts and i will fix

IotaBlack avatar Dec 14 '16 08:12 IotaBlack

@kriso02 Well...all the files. For all properties the @type comments have to be replaced by @property comments as demonstrated in my last comment.

Tim-Pohlmann avatar Dec 14 '16 21:12 Tim-Pohlmann

so all "@type"?

IotaBlack avatar Dec 14 '16 21:12 IotaBlack

what is the difference

IotaBlack avatar Dec 14 '16 21:12 IotaBlack