dungpa/fantomas — pull request #67 by jaredpar (2013-07-06 00:48:45+00:00)
Title: Fixed querying of ITextDocument

The IsSignatureFile method was incorrectly querying for the
ITextDocument related to a given ITextBuffer. The main problem is there
is no guarantee that an ITextBuffer has an associated ITextDocument
value. For the most part ITextDocument represents physical files on the
disk while ITextBuffer represents something being editted in Visual
Studio. Most things being edited in Visual Studio have a backing
physical file but not everything. When this method was called on such a
file it would result in an exception.

A secondary minor issue is the proper way to query for ITextDocument is
to use ITextDocumentFactoryService.TryGetTextDocument. Even though they
are very unlikely to ever change this, the use of typeof(ITextDocument)
as the key to the property bag is not a supported operation.
TryGetTextDocument also handles some extreme corner cases (like a
disposed ITextDocument). It's just a safer API to use.