c# - Access other files in VS Language Service (Visual Studio Extensibility) -
i'm writing custom language service described in https://msdn.microsoft.com/en-us/library/bb166533.aspx
now i'm writing code authoringscope (https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.package.authoringscope.aspx) problem in getdeclarations method.
i have access text of current file via parserequest.text property. allows me list methods , variables in file how can access other files content? need access other file content building ast tree of file don't know how can this.
personally find mpf "helper" classes (like authoringscope
) bit restrictive, , implement manually (which, admit, take more time, lot more flexible in end).
in case, sounds language (like most!) has dependencies between files @ semantic parsing level. means you'll either have to:
a) reparse lot of text time, slow in large projects
or b) maintain global aggregate parse of project's files, , update dynamically when files (or project's properties) change
b) lot harder, best way it. general outline discover projects after solution opened via envdte, parse them (discover files in each project, again via envdte), , store in sort of indexable data structure can fast queries against (for semantic syntax highlighting, go definition, etc.). need listen changes everywhere , reparse appropriately -- you'll need check solution open/close (ivssolutionevents
), projects being added/removed/renamed/unloaded/loaded (ivssolutionevents
/ivssolutionevents4
), files being added/removed/renamed (ivshierarchyevents
), files being edited (ivstextviewcreationlistener
+ itextbuffer.changed
), , project configurations changing (ivsupdatesolutionevents
, ivshierarchyevents
).
whether choose a) or b), still need able check if file opened in editor (potentially unsaved changes) or not. can check if file open in running document table (but don't forget normalize path first using path.getfullpath()
) via ivsrunningdocumenttable
service, return intptr
document data, can coaxed yielding itextbuffer
file, contains text (and entire buffer history!) of file. of course, if it's not open you'll have read disk.
Comments
Post a Comment