Ejemplo n.º 1
0
		internal static Task<MDRefactoringContext> Create (Document document, TextLocation loc, CancellationToken cancellationToken = default (CancellationToken))
		{
			var shared = document.GetSharedResolver ();
			if (shared == null) {
				var tcs = new TaskCompletionSource<MDRefactoringContext> ();
				tcs.SetResult (null);
				return tcs.Task;
			}

			return shared.ContinueWith (t => {
				var sharedResolver = t.Result;
				if (sharedResolver == null)
					return null;
				return new MDRefactoringContext (document, sharedResolver, loc, cancellationToken);
				// Do not add TaskContinuationOptions.ExecuteSynchronously
				// https://bugzilla.xamarin.com/show_bug.cgi?id=25065
				// adding ExecuteSynchronously appears to create a deadlock situtation in TypeSystemParser.Parse()
			});
		}
Ejemplo n.º 2
0
		internal static MDRefactoringContext Create (Document document, TextLocation loc, CancellationToken cancellationToken = default (CancellationToken)) 
		{
			var shared = document.GetSharedResolver ();
			if (shared == null)
				return null;
			var sharedResolver = shared.Result;
			if (sharedResolver == null)
				return null;
			return new MDRefactoringContext (document, sharedResolver, loc, cancellationToken);
		}
Ejemplo n.º 3
0
		internal static Task<MDRefactoringContext> Create (Document document, TextLocation loc, CancellationToken cancellationToken = default (CancellationToken))
		{
			var shared = document.GetSharedResolver ();
			if (shared == null) {
				var tcs = new TaskCompletionSource<MDRefactoringContext> ();
				tcs.SetResult (null);
				return tcs.Task;
			}

			return shared.ContinueWith (t => {
				var sharedResolver = t.Result;
				if (sharedResolver == null)
					return null;
				return new MDRefactoringContext (document, sharedResolver, loc, cancellationToken);
			}, TaskContinuationOptions.ExecuteSynchronously);
		}
Ejemplo n.º 4
0
		public MDRefactoringContext (Document document, TextLocation loc, CancellationToken cancellationToken = default (CancellationToken)) : base (document.GetSharedResolver ().Result, cancellationToken)
		{
			if (document == null)
				throw new ArgumentNullException ("document");
			this.TextEditor = document.Editor;
			this.ParsedDocument = document.ParsedDocument;
			this.Project = document.Project as DotNetProject;
			this.formattingOptions = document.GetFormattingOptions ();
			this.location = RefactoringService.GetCorrectResolveLocation (document, loc);
			var policy = document.HasProject ? Project.Policies.Get<NameConventionPolicy> () : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<NameConventionPolicy> ();
			Services.AddService (typeof(NamingConventionService), policy.CreateNRefactoryService ());
		}