Beispiel #1
0
        /// <summary>
        /// Gets the workspace corresponding to the text buffer.
        /// </summary>
        public static Workspace GetWorkspace(this ITextBuffer buffer)
        {
            var container = buffer.AsTextContainer();
            if (Workspace.TryGetWorkspace(container, out var workspace))
            {
                return workspace;
            }

            return null;
        }
Beispiel #2
0
 /// <summary>
 /// Gets the <see cref="Document"/>s from the corresponding <see cref="Workspace.CurrentSolution"/> that are associated with the <see cref="ITextBuffer"/>.
 /// There may be multiple <see cref="Document"/>s associated with the buffer if it is linked into multiple projects or is part of a Shared Project. 
 /// </summary>
 public static IEnumerable<Document> GetRelatedDocuments(this ITextBuffer buffer)
 {
     return buffer.AsTextContainer().GetRelatedDocuments();
 }
Beispiel #3
0
 internal static bool CanApplyChangeDocumentToWorkspace(this ITextBuffer buffer)
 {
     Workspace workspace;
     if (Workspace.TryGetWorkspace(buffer.AsTextContainer(), out workspace))
     {
         return workspace.CanApplyChange(ApplyChangesKind.ChangeDocument);
     }
     else
     {
         return false;
     }
 }
Beispiel #4
0
		/// <summary>
		/// Returns the workspace or null
		/// </summary>
		/// <param name="buffer">Text buffer</param>
		/// <returns></returns>
		public static Workspace TryGetWorkspace(this ITextBuffer buffer) {
			Workspace ws;
			Workspace.TryGetWorkspace(buffer.AsTextContainer(), out ws);
			return ws;
		}