public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.ImportBindings imbBind)
            : base(gen)
        {
            this.impBind = imbBind;
        }
        public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.Import imp)
            : base(gen)
        {
            this.imp = imp;
        }
Exemplo n.º 3
0
        ImportStatement ImportDeclaration()
        {
            Expect(Import);

            var importStatement = new ImportStatement { Location=t.Location };

            ApplyAttributes(importStatement);

            var imp = _Import();

            while (laKind == Comma)
            {
                importStatement.Imports.Add(imp);

                Step();

                imp = _Import();
            }

            if (laKind == Colon)
            {
                Step();
                importStatement.ImportBinding = ImportBindings(imp);
            }
            else
                importStatement.Imports.Add(imp); // Don't forget to add the last import

            if (Expect(Semicolon))
                LastParsedObject = null;

            CheckForPostSemicolonComment();

            importStatement.EndLocation = t.EndLocation;

            // Prepare for resolving external items
            importStatement.CreatePseudoAliases();

            return importStatement;
        }
Exemplo n.º 4
0
 public void Visit(ImportStatement importStatement)
 {
 }
Exemplo n.º 5
0
        ImportStatement ImportDeclaration(IBlockNode scope)
        {
            // In DMD 2.060, the static keyword must be written exactly before the import token
            bool isStatic = t!= null && t.Kind == Static;
            bool isPublic = Modifier.ContainsAttribute(DeclarationAttributes, Public) ||
                            Modifier.ContainsAttribute(BlockAttributes,Public);

            Expect(Import);

            var importStatement = new ImportStatement { Attributes = GetCurrentAttributeSet_Array(), Location=t.Location, IsStatic = isStatic, IsPublic = isPublic };

            DeclarationAttributes.Clear();

            var imp = _Import();

            while (laKind == Comma)
            {
                importStatement.Imports.Add(imp);

                Step();

                imp = _Import();
            }

            if (laKind == Colon)
            {
                Step();
                importStatement.ImportBindList = ImportBindings(imp);
            }
            else
                importStatement.Imports.Add(imp); // Don't forget to add the last import

            Expect(Semicolon);

            CheckForPostSemicolonComment();

            importStatement.EndLocation = t.EndLocation;

            // Prepare for resolving external items
            importStatement.CreatePseudoAliases(scope);

            return importStatement;
        }
        public virtual void VisitImport(ImportStatement.ImportBindings i)
        {
            if(i.Module != null)
                i.Module.Accept (this);

            if(i.SelectedSymbols != null)
                foreach (var imp in i.SelectedSymbols)
                    if(imp != null)
                        imp.Accept (this);
        }
        public virtual void Visit(ImportStatement s)
        {
            if (s.Attributes != null)
                foreach (var attr in s.Attributes)
                    if(attr != null)
                        attr.Accept (this);

            if (s.Imports != null)
                foreach (var imp in s.Imports)
                    if(imp != null)
                        imp.Accept (this);

            if (s.ImportBindList != null)
                s.ImportBindList.Accept (this);

            VisitAbstractStmt(s);
        }
Exemplo n.º 8
0
        public ImportSymbolAlias(ImportStatement impStmt,ImportStatement.Import imp)
        {
            OriginalImportStatement = impStmt;

            IsModuleAlias = true;
            Name = imp.ModuleAlias;
            Type = imp.ModuleIdentifier;
            IsAlias = true;
        }
Exemplo n.º 9
0
        bool HandleNonAliasedImport(ImportStatement.Import imp, MemberFilter VisibleMembers)
        {
            if (imp == null || imp.ModuleIdentifier == null)
                return false;

            var thisModuleName = ctxt.ScopedBlock.NodeRoot is IAbstractSyntaxTree ? (ctxt.ScopedBlock.NodeRoot as IAbstractSyntaxTree).ModuleName : string.Empty;
            var moduleName = imp.ModuleIdentifier.ToString();

            List<string> seenModules = null;

            if(!scannedModules.TryGetValue(thisModuleName,out seenModules))
                seenModules = scannedModules[thisModuleName] = new List<string>();
            else if (seenModules.Contains(moduleName))
                return false;
            seenModules.Add(moduleName);

            if(ctxt.ParseCache!=null)
                foreach (var module in ctxt.ParseCache.LookupModuleName(moduleName))
                {
                    var scAst = ctxt.ScopedBlock.NodeRoot as IAbstractSyntaxTree;
                    if (module == null || (scAst!=null && module.FileName == scAst.FileName && module.FileName!=null))
                        continue;

                    if (HandleItem(module))
                        return true;

                    var ch = PrefilterSubnodes(module);
                    if(ch!=null)
                        foreach (var i in ch)
                        {
                            var dn = i as DNode;
                            if (dn != null)
                            {
                                // Add anonymous enums' items
                                if (dn is DEnum &&
                                    string.IsNullOrEmpty(i.Name) &&
                                    dn.IsPublic &&
                                    !dn.ContainsAttribute(DTokens.Package) &&
                                    CanAddMemberOfType(VisibleMembers, i))
                                {
                                    if (HandleItems((i as DEnum).Children))
                                        return true;
                                    continue;
                                }

                                if (dn.IsPublic && !dn.ContainsAttribute(DTokens.Package) &&
                                    CanAddMemberOfType(VisibleMembers, dn))
                                    if (HandleItem(dn))
                                        return true;
                            }
                            else
                                if (HandleItem(i))
                                    return true;
                        }

                    if (HandleDBlockNode(module as DBlockNode, VisibleMembers, true))
                        return true;
                }
            return false;
        }
Exemplo n.º 10
0
 public virtual void Visit(ImportStatement s)
 {
     VisitAbstractStmt(s);
 }
Exemplo n.º 11
0
        bool HandleNonAliasedImport(ImportStatement.Import imp, MemberFilter VisibleMembers)
        {
            if (imp == null || imp.ModuleIdentifier == null)
                return false;

            DModule mod;
            var thisModuleName = (ctxt.ScopedBlock != null && (mod=ctxt.ScopedBlock.NodeRoot as DModule)!=null) ? mod.ModuleName : string.Empty;

            if(string.IsNullOrEmpty(thisModuleName))
                return false;

            var moduleName = imp.ModuleIdentifier.ToString();

            List<string> seenModules = null;

            if (!scannedModules.TryGetValue(thisModuleName, out seenModules))
                seenModules = scannedModules[thisModuleName] = new List<string>();
            else if (seenModules.Contains(moduleName))
                return false;
            seenModules.Add(moduleName);

            var scAst = ctxt.ScopedBlock == null ? null : ctxt.ScopedBlock.NodeRoot as DModule;
            if (ctxt.ParseCache != null)
                foreach (var module in ctxt.ParseCache.LookupModuleName(moduleName)) //TODO: Only take the first module? Notify the user about ambigous module names?
                {
                    if (module == null || (scAst != null && module.FileName == scAst.FileName && module.FileName != null))
                        continue;

                    //ctxt.PushNewScope(module);

                    if(ScanImportedModule(module as DModule,VisibleMembers))
                    {
                        //ctxt.Pop();
                        return true;
                    }

                    //ctxt.Pop();
                }
            return false;
        }
Exemplo n.º 12
0
 public void VisitImport(ImportStatement.ImportBindings bindings)
 {
 }
Exemplo n.º 13
0
 public void VisitImport(ImportStatement.ImportBinding importBinding)
 {
 }
Exemplo n.º 14
0
 public void VisitImport(ImportStatement.Import import)
 {
 }
Exemplo n.º 15
0
        void ImportBind(ImportStatement imp)
        {
            if(imp.ExclusivelyImportedSymbols==null)
                imp.ExclusivelyImportedSymbols = new Dictionary<string, string>();

            if (Expect(Identifier))
            {
                string imbBind = t.Value;
                string imbBindDef = "";

                if (laKind == (Assign))
                {
                    Step();
                    Expect(Identifier);
                    imbBindDef = t.Value;
                }

                imp.ExclusivelyImportedSymbols.Add(imbBind, imbBindDef);
            }
        }
Exemplo n.º 16
0
        ImportStatement.ImportBindings ImportBindings(ImportStatement.Import imp)
        {
            var importBindings = new ImportStatement.ImportBindings { Module=imp };
            LastParsedObject = importBindings;

            bool init = true;
            while (laKind == Comma || init)
            {
                if (init)
                    init = false;
                else
                    Step();

                if (Expect(Identifier))
                {
                    var symbolAlias = new IdentifierDeclaration(t.Value){ Location = t.Location, EndLocation = t.EndLocation };

                    if (laKind == Assign)
                    {
                        Step();
                        if (Expect (Identifier))
                            importBindings.SelectedSymbols.Add (new ImportStatement.ImportBinding (new IdentifierDeclaration (t.Value) {
                                Location = t.Location,
                                EndLocation = t.EndLocation
                            }, symbolAlias));
                    }
                    else
                        importBindings.SelectedSymbols.Add(new ImportStatement.ImportBinding(symbolAlias));
                }
            }

            if (!IsEOF)
                LastParsedObject = null;

            return importBindings;
        }
Exemplo n.º 17
0
        ImportStatement _Import()
        {
            var import = new ImportStatement();
            LastParsedObject = import;

            // ModuleAliasIdentifier
            if (Lexer.CurrentPeekToken.Kind == (Assign))
            {
                if(Expect(Identifier))
                    import.ModuleAlias = t.Value;
                Step();
            }

            import.ModuleIdentifier = ModuleFullyQualifiedName();

            return import;
        }
Exemplo n.º 18
0
 public virtual void VisitImport(ImportStatement.Import i)
 {
     if (i.ModuleAlias != null)
         i.ModuleAlias.Accept (this);
     if (i.ModuleIdentifier != null)
         i.ModuleIdentifier.Accept (this);
 }
Exemplo n.º 19
0
 public override void VisitImport(ImportStatement.Import i)
 {
     if (IsIncompleteDeclaration(i.ModuleIdentifier))
     {
         prv = new ImportStatementCompletionProvider(cdgen, i);
         halt = true;
     }
     else
     {
         curImport = i;
         base.VisitImport(i);
     }
 }
Exemplo n.º 20
0
 public virtual void VisitImport(ImportStatement.ImportBinding i)
 {
     if (i.Alias != null)
         i.Alias.Accept (this);
     if (i.Symbol != null)
         i.Symbol.Accept (this);
 }
Exemplo n.º 21
0
 public override void VisitImport(ImportStatement.ImportBinding i)
 {
     if (!halt) {
         if (IsIncompleteDeclaration (i.Symbol)) {
             prv = new SelectiveImportCompletionProvider (cdgen, curImport);
             halt = true;
         } else
             base.VisitImport (i);
     }
 }
Exemplo n.º 22
0
        ImportStatement.ImportBindings ImportBindings(ImportStatement.Import imp)
        {
            var importBindings = new ImportStatement.ImportBindings { Module=imp };

            bool init = true;
            while (laKind == Comma || init)
            {
                if (init)
                    init = false;
                else
                    Step();

                var symbolAlias = Expect(Identifier) ?
                    new IdentifierDeclaration(t.Value){ Location = t.Location, EndLocation = t.EndLocation } :
                    (IsEOF ? new IdentifierDeclaration(DTokens.IncompleteIdHash) : null);

                if (laKind == Assign)
                {
                    Step();
                    if (Expect (Identifier))
                        importBindings.SelectedSymbols.Add (new ImportStatement.ImportBinding (new IdentifierDeclaration (t.Value) {
                            Location = t.Location,
                            EndLocation = t.EndLocation
                        }, symbolAlias));
                    else if(IsEOF)
                        importBindings.SelectedSymbols.Add (new ImportStatement.ImportBinding (new IdentifierDeclaration (DTokens.IncompleteIdHash), symbolAlias));
                }
                else if(symbolAlias != null)
                    importBindings.SelectedSymbols.Add(new ImportStatement.ImportBinding(symbolAlias));
            }

            return importBindings;
        }
Exemplo n.º 23
0
        ImportStatement.ImportBindings ImportBindings(ImportStatement.Import imp)
        {
            var importBindings = new ImportStatement.ImportBindings { Module=imp };
            LastParsedObject = importBindings;

            bool init = true;
            while (laKind == Comma || init)
            {
                if (init)
                    init = false;
                else
                    Step();

                if (Expect(Identifier))
                {
                    if (laKind == Assign)
                    {
                        var symbolAlias = t.Value;
                        Step();
                        if (Expect(Identifier))
                            importBindings.SelectedSymbols.Add(new KeyValuePair<string, string>(symbolAlias, t.Value));
                    }
                    else
                        importBindings.SelectedSymbols.Add(new KeyValuePair<string, string>(t.Value, null));
                }
            }

            if (!IsEOF)
                LastParsedObject = null;

            return importBindings;
        }
		public SelectiveImportCompletionProvider(ICompletionDataGenerator gen, ImportStatement.Import imp) : base(gen) {
			import = imp;
		}
Exemplo n.º 25
0
 protected ImportSymbolNode(ImportStatement impStmt, IBlockNode parentNode)
 {
     IsAlias = true;
     this.ImportStatement = impStmt;
     Parent = parentNode;
 }