Get referenced files

Topics: General
Mar 16, 2013 at 5:52 PM
Not sure this is the right place to ask, but does anyone know how to get the referenced files using the language service API.

I thought I figured it out, but the following code always returns an empty array:
    languageService.getScriptAST(script.name).referencedFiles
Any help would be greatly appreciated.

P.S The languageService works fine for other methods, so I expected the above to also work but I guess I'm overlooking something.
Mar 17, 2013 at 10:58 AM
Last time I checked, the languageService did not do any import/reference resolution. For my own https://github.com/clausreinke/typescript-tools , I copied the relevant code out of the batch compiler and called it resolver.ts (we can't just import the code, see http://typescript.codeplex.com/workitem/521 ).

It has been a while, but if you follow the call chain from the batch compiler, you can see when the referencedFiles get filled.
Mar 17, 2013 at 7:21 PM
When using the batch compiler like approach I got some issues since some of that code relies on an IO host being present which in my application in not the case. But I just found out that the following also works:

var refs = TypeScript.getReferencedFiles(new TypeScript.StringSourceText(script.content));
Not the most efficient way since it will compile the source code again, but at least it returns a list of referenced files.




On Sun, Mar 17, 2013 at 10:58 AM, clausreinke <notifications@codeplex.com> wrote:

From: clausreinke

Last time I checked, the languageService did not do any import/reference resolution. For my own https://github.com/clausreinke/typescript-tools , I copied the relevant code out of the batch compiler and called it resolver.ts (we can't just import the code, see http://typescript.codeplex.com/workitem/521 ).

It has been a while, but if you follow the call chain from the batch compiler, you can see when the referencedFiles get filled.

Read the full discussion online.

To add a post to this discussion, reply to this email (typescript@discussions.codeplex.com)

To start a new discussion for this project, email typescript@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com