Пример #1
0
 /// <summary>
 /// Gets a cursor
 /// </summary>
 /// <param name="fileName">
 /// A <see cref="string"/>: the filename which a Translation Unit (probably containing the cursor) is associated with.
 /// </param>
 /// <param name="location">
 /// A <see cref="MonoDevelop.Ide.Editor.DocumentLocation"/>: the location in the document (named fileName)
 /// </param>
 /// <returns>
 /// A <see cref="CXCursor"/>: the cursor under the location
 /// </returns>
 public CXCursor GetCursor(string fileName, MonoDevelop.Ide.Editor.DocumentLocation location)
 {
     lock (SyncRoot) {
         CXTranslationUnit TU   = translationUnits [fileName];
         CXFile            file = clang.getFile(TU, fileName);
         CXSourceLocation  loc  = clang.getLocation(
             TU,
             file,
             (uint)(location.Line),
             (uint)(location.Column)
             );
         return(clang.getCursor(TU, loc));
     }
 }
Пример #2
0
        /// <summary>
        /// Inspects the C# abstract syntax tree for the provided document and finds the string SyntaxToken
        /// for the provided document location/
        /// </summary>
        /// <returns><c>true</c>, if syntax token was resolved, <c>false</c> otherwise.</returns>
        /// <param name="document">The document to inspect.</param>
        /// <param name="documentLocation">The document location in question.</param>
        /// <param name="token">The string SyntaxToken that was resolved</param>
        public static bool ResolveSyntaxToken(Document document, MonoDevelop.Ide.Editor.DocumentLocation documentLocation, out Microsoft.CodeAnalysis.SyntaxToken token)
        {
            var offset = document.Editor.LocationToOffset(documentLocation);

            return(ResolveSyntaxToken(document, offset, out token));
        }