コード例 #1
0
        public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.ImportBindings imbBind)
            : base(gen)
        {
            this.impBind = imbBind;
        }
コード例 #2
0
        public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.Import imp)
            : base(gen)
        {
            this.imp = imp;
        }
コード例 #3
0
ファイル: Parser_Impl.cs プロジェクト: gavin-norman/Mono-D
        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;
        }
コード例 #4
0
 public void Visit(ImportStatement importStatement)
 {
 }
コード例 #5
0
ファイル: Parser_Impl.cs プロジェクト: rainers/D_Parser
        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;
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public ImportSymbolAlias(ImportStatement impStmt,ImportStatement.Import imp)
        {
            OriginalImportStatement = impStmt;

            IsModuleAlias = true;
            Name = imp.ModuleAlias;
            Type = imp.ModuleIdentifier;
            IsAlias = true;
        }
コード例 #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;
        }
コード例 #10
0
 public virtual void Visit(ImportStatement s)
 {
     VisitAbstractStmt(s);
 }
コード例 #11
0
ファイル: AbstractVisitor.cs プロジェクト: DinrusGroup/DRC
        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;
        }
コード例 #12
0
 public void VisitImport(ImportStatement.ImportBindings bindings)
 {
 }
コード例 #13
0
 public void VisitImport(ImportStatement.ImportBinding importBinding)
 {
 }
コード例 #14
0
 public void VisitImport(ImportStatement.Import import)
 {
 }
コード例 #15
0
ファイル: Parser_Impl.cs プロジェクト: nazriel/Mono-D
        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);
            }
        }
コード例 #16
0
ファイル: Parser_Impl.cs プロジェクト: EnergonV/D_Parser
        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;
        }
コード例 #17
0
ファイル: Parser_Impl.cs プロジェクト: nazriel/Mono-D
        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;
        }
コード例 #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);
 }
コード例 #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);
     }
 }
コード例 #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);
 }
コード例 #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);
     }
 }
コード例 #22
0
ファイル: Parser_Impl.cs プロジェクト: rainers/D_Parser
        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;
        }
コード例 #23
0
ファイル: Parser_Impl.cs プロジェクト: gavin-norman/Mono-D
        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;
        }
コード例 #24
0
		public SelectiveImportCompletionProvider(ICompletionDataGenerator gen, ImportStatement.Import imp) : base(gen) {
			import = imp;
		}
コード例 #25
0
ファイル: ImportStatement.cs プロジェクト: rainers/D_Parser
 protected ImportSymbolNode(ImportStatement impStmt, IBlockNode parentNode)
 {
     IsAlias = true;
     this.ImportStatement = impStmt;
     Parent = parentNode;
 }