public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.ImportBindings imbBind)
            : base(gen)
        {
            this.impBind = imbBind;
        }
        public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.Import imp)
            : base(gen)
        {
            this.imp = imp;
        }
Exemple #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;
        }
 public void Visit(ImportStatement importStatement)
 {
 }
Exemple #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);
        }
        public ImportSymbolAlias(ImportStatement impStmt,ImportStatement.Import imp)
        {
            OriginalImportStatement = impStmt;

            IsModuleAlias = true;
            Name = imp.ModuleAlias;
            Type = imp.ModuleIdentifier;
            IsAlias = true;
        }
        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;
        }
 public virtual void Visit(ImportStatement s)
 {
     VisitAbstractStmt(s);
 }
Exemple #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;
        }
 public void VisitImport(ImportStatement.ImportBindings bindings)
 {
 }
 public void VisitImport(ImportStatement.ImportBinding importBinding)
 {
 }
 public void VisitImport(ImportStatement.Import import)
 {
 }
Exemple #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);
            }
        }
Exemple #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;
        }
Exemple #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;
        }
 public virtual void VisitImport(ImportStatement.Import i)
 {
     if (i.ModuleAlias != null)
         i.ModuleAlias.Accept (this);
     if (i.ModuleIdentifier != null)
         i.ModuleIdentifier.Accept (this);
 }
 public override void VisitImport(ImportStatement.Import i)
 {
     if (IsIncompleteDeclaration(i.ModuleIdentifier))
     {
         prv = new ImportStatementCompletionProvider(cdgen, i);
         halt = true;
     }
     else
     {
         curImport = i;
         base.VisitImport(i);
     }
 }
 public virtual void VisitImport(ImportStatement.ImportBinding i)
 {
     if (i.Alias != null)
         i.Alias.Accept (this);
     if (i.Symbol != null)
         i.Symbol.Accept (this);
 }
 public override void VisitImport(ImportStatement.ImportBinding i)
 {
     if (!halt) {
         if (IsIncompleteDeclaration (i.Symbol)) {
             prv = new SelectiveImportCompletionProvider (cdgen, curImport);
             halt = true;
         } else
             base.VisitImport (i);
     }
 }
Exemple #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;
        }
Exemple #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;
		}
Exemple #25
0
 protected ImportSymbolNode(ImportStatement impStmt, IBlockNode parentNode)
 {
     IsAlias = true;
     this.ImportStatement = impStmt;
     Parent = parentNode;
 }