void ResolveButtonClick(object sender, EventArgs e)
        {
            IProjectContent project        = new CSharpProjectContent();
            var             unresolvedFile = syntaxTree.ToTypeSystem();

            project = project.AddOrUpdateFiles(unresolvedFile);
            //project = project.AddAssemblyReferences(builtInLibs.Value);

            ICompilation compilation = project.CreateCompilation();

            ResolveResult result;

            if (csharpTreeView.SelectedNode != null)
            {
                var selectedNode           = (AstNode)csharpTreeView.SelectedNode.Tag;
                CSharpAstResolver resolver = new CSharpAstResolver(compilation, syntaxTree, unresolvedFile);
                result = resolver.Resolve(selectedNode);
                // CSharpAstResolver.Resolve() never returns null
            }
            else
            {
                TextLocation location = GetTextLocation(csharpCodeTextBox, csharpCodeTextBox.SelectionStart);
                result = ResolveAtLocation.Resolve(compilation, unresolvedFile, syntaxTree, location);
                if (result == null)
                {
                    MessageBox.Show("Could not find a resolvable node at the caret location.");
                    return;
                }
            }
            using (var dlg = new SemanticTreeDialog(result))
                dlg.ShowDialog();
        }
Beispiel #2
0
		void ResolveButtonClick(object sender, EventArgs e)
		{
			IProjectContent project = new CSharpProjectContent();
			var unresolvedFile = syntaxTree.ToTypeSystem();
			project = project.AddOrUpdateFiles(unresolvedFile);
			project = project.AddAssemblyReferences(builtInLibs.Value);
			
			ICompilation compilation = project.CreateCompilation();
			
			ResolveResult result;
			if (csharpTreeView.SelectedNode != null) {
				var selectedNode = (AstNode)csharpTreeView.SelectedNode.Tag;
				CSharpAstResolver resolver = new CSharpAstResolver(compilation, syntaxTree, unresolvedFile);
				result = resolver.Resolve(selectedNode);
				// CSharpAstResolver.Resolve() never returns null
			} else {
				TextLocation location = GetTextLocation(csharpCodeTextBox, csharpCodeTextBox.SelectionStart);
				result = ResolveAtLocation.Resolve(compilation, unresolvedFile, syntaxTree, location);
				if (result == null) {
					MessageBox.Show("Could not find a resolvable node at the caret location.");
					return;
				}
			}
			using (var dlg = new SemanticTreeDialog(result))
				dlg.ShowDialog();
		}