Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open fileless source code document in code editor from VS 2010 extension

I am creating a Visual Studio 2010 extension using the VS 2010 SDK SP1 that will open source code files in the code editor. The extension is a ToolWindow that is docked where the Solution Explorer is located.

The extension consumes a WCF service where it retrieves the source code files and displays the hierarchy in a TreeView. When the code file is double clicked, it should load the associated source into the code editor window much like the Solution Explorer does.

I have been reading about VS extension and DTE automation for a while now and have made very little progress. It seems that I am able to access already opened or active WpfTextViews without a problem, but I do not understand how to open a new TextView into the document area of the IDE. Keep in mind that these are not actual source code files saved on the disk, but rather they are retrieved from the WCF service and stored in memory.

Could anyone provide an example or give me some guidance on how to implement this please? Thank you.

like image 771
Paccc Avatar asked Jul 06 '11 22:07

Paccc


People also ask

How do I use Windows code editor?

You can click on the Class View tab at the bottom of the window to view your code organized by classes. You can search and replace text in single or multiple files. For more information, see Find and replace text. You can use regular expressions to find and replace text.


2 Answers

How about creating a temporary file, filling it with the source code and load that temp file? (Or creating new temp file, adding it to the IDE and then insert your source code there...)

Maybe that's not exactly what you wanted but it'll do the trick...

(If you create a new file in VS (File -> New...), VS will create a temp file as well and ask for the "correct" location when you want to save the file for the first time.)

like image 191
Stephan Bauer Avatar answered Oct 16 '22 04:10

Stephan Bauer


Why not create a cache of the whole source tree on the local drive and then just load the solution from file instead of from memory?

like image 1
JasonRazz Avatar answered Oct 16 '22 05:10

JasonRazz