Пример #1
0
        TypeSystemAstBuilder CreateBuilder(ITypeDefinition currentTypeDef = null)
        {
            UsingScope usingScope = currentTypeDef != null?unresolvedFile.GetUsingScope(currentTypeDef.Region.Begin) : unresolvedFile.RootUsingScope;

            return(new TypeSystemAstBuilder(new CSharpResolver(
                                                new CSharpTypeResolveContext(compilation.MainAssembly, usingScope.Resolve(compilation), currentTypeDef))));
        }
Пример #2
0
        List <string> GetUsedNamespaces()
        {
            var scope  = CSharpUnresolvedFile.GetUsingScope(document.Editor.Caret.Location);
            var result = new List <string> ();

            while (scope != null)
            {
                result.Add(scope.NamespaceName);
                var ctx = CSharpUnresolvedFile.GetResolver(Document.Compilation, scope.Region.Begin);
                foreach (var u in scope.Usings)
                {
                    var ns = u.ResolveNamespace(ctx);
                    if (ns == null)
                    {
                        continue;
                    }
                    result.Add(ns.FullName);
                }
                scope = scope.Parent;
            }
            return(result);
        }