public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.Import imp)
			: base(gen)
		{
			this.imp = imp;
		}
		public ImportStatementCompletionProvider(
			ICompletionDataGenerator gen, 
			ImportStatement.ImportBindings imbBind)
			: base(gen)
		{
			this.impBind = imbBind;
			imp = impBind.Module;
		}
Exemplo n.º 3
0
 // ImportStatement
 public override bool Walk(ImportStatement node)
 {
     return(false);
 }
Exemplo n.º 4
0
 public ulong Visit(ImportStatement importStatement)
 {
     return(1000291);
 }
Exemplo n.º 5
0
 public RemovedImportStatement(ImportStatement removed)
 {
     _import = removed;
 }
Exemplo n.º 6
0
 public override object Visit(ImportStatement that, object value = null)
 {
     /** \todo Somehow import an existing scope. */
     return null;
 }
Exemplo n.º 7
0
 // ImportStatement
 public virtual bool Walk(ImportStatement node) { return true; }
Exemplo n.º 8
0
 public override object Visit(ImportStatement that, object value)
 {
     _writer.Write("import ");
     that.Location.Visit(this);
     _writer.Write(" is ");
     that.Name.Visit(this);
     _writer.WriteLine();
     return null;
 }
Exemplo n.º 9
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.º 10
0
 /// <summary>
 /// Visits a <see cref="ImportStatement"/>.
 /// </summary>
 /// <param name="node">
 /// The node.
 /// </param>
 /// <returns>
 /// The node, or a new version of the node.
 /// </returns>
 protected internal override Node VisitImportStatement(ImportStatement node)
 {
     return(this.VisitImplementation(node) ?? base.VisitImportStatement(node));
 }
Exemplo n.º 11
0
 public override bool Walk(ImportStatement node)
 {
     writer.WriteLine("Import: " + GetImports(node.Names));
     return(base.Walk(node));
 }
Exemplo n.º 12
0
 public override bool Walk(ImportStatement node) => ImportHandler.HandleImport(node);
Exemplo n.º 13
0
 // ImportStatement
 public override bool Walk(ImportStatement node)
 {
     return(Location >= node.StartIndex && Location <= node.EndIndex);
 }
Exemplo n.º 14
0
 public void Visit(ImportStatement node)
 {
     // starts with import, so we don't care
 }
Exemplo n.º 15
0
 // ImportStatement
 public virtual bool Walk(ImportStatement node)
 {
     return(true);
 }
Exemplo n.º 16
0
 public override bool Walk(ImportStatement node) => Save(node, base.Walk(node), "import");
Exemplo n.º 17
0
 public void Register(ImportStatement importStatement)
 {
     Register(this, importStatement.Library, importStatement.Imports);
 }
Exemplo n.º 18
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;
		}
        public void StatementCreatorOrderTest()
        {
            DBTable  table = new DBTable("dbo", "TestTable");
            DBColumn col1  = new DBColumn(table, "TestCol1", true, DBDatatype.integer);
            DBColumn col2  = new DBColumn(table, "TestCol2", false, DBDatatype.nvarchar);
            DBColumn col3  = new DBColumn(table, "TestCol3", false, DBDatatype.integer);

            table.Columns = new List <DBColumn>()
            {
                col1, col2, col3
            };

            Database db = new Database("TestDB", new List <DBTable>()
            {
                table
            });

            TableMapping sourceTablemapping = new TableMapping(new DBTable("dbo", "TestTable2"), TableMappingImportType.Insert, null);

            ColumnMapping colMap1 = new TableColumnMapping(sourceTablemapping, col1, col1, ColumnUse.Where);
            ColumnMapping colMap2 = new LiteralColumnMapping("2", LiteralType.String, col2, ColumnUse.Where);
            ColumnMapping colMap3 = new LiteralColumnMapping("3", LiteralType.String, col2, ColumnUse.Set);

            TableMapping tableMapping = new TableMapping(table, TableMappingImportType.Update, new ColumnMapping[] { colMap1, colMap2, colMap3 });

            ErrorHandling       errorHandling = new ErrorHandling();
            ImportConfiguration config        = new ImportConfiguration(new TableMapping[] { tableMapping }, null, "TestDB", errorHandling);

            SourceDataEntry[] entries = new SourceDataEntry[] { SourceDataEntry.CreateDataEntry("", DataType.String, "") };
            SourceDataRow[]   rows    = new SourceDataRow[] { new SourceDataRow(entries, "0") };
            SourceDataTable   dt      = new SourceDataTable(rows, new string[] { "" });

            SQLServerStatementCreator statementCreator = new SQLServerStatementCreator(config, dt);

            ImportStatement statement = statementCreator.CreateStatement(0);

            ImportStatement[] statements = statementCreator.CreateStatements();

            Assert.AreEqual(1, statements.Length);
            Assert.AreEqual(statement.RowReference, statements[0].RowReference);
            Assert.AreEqual(statement.SqlStatement, statements[0].SqlStatement);

            string[] lines = statement.SqlStatement
                             .Split(new string[] { "\n" }, StringSplitOptions.None).Where(s => s.Length > 0).ToArray();

            StatementSetupPart setupPart = new StatementSetupPart(config);

            Assert.AreEqual(setupPart.GetDatabasePart(), lines[0]);
            Assert.AreEqual(setupPart.GetWarningsPart(), lines[1]);


            StatementTransactionPart transPart = new StatementTransactionPart(config);

            string[] transStartPart = transPart.GetTransactionStartPart()
                                      .Split(new string[] { "\n" }, StringSplitOptions.None).Where(s => s.Length > 0).ToArray();;

            Assert.AreEqual(2, transStartPart.Length);
            Assert.AreEqual(transStartPart[0], lines[2]);
            Assert.AreEqual(transStartPart[1], lines[3]);


            StatementTableMappingPart tmParts = new StatementTableMappingPart(tableMapping, dt.GetDataRow(0));
            string variablePart = tmParts.GetTableVariablePart().Replace("\n", "");

            Assert.AreEqual(variablePart, lines[4]);

            string[] bodyParts = tmParts.GetStatementBodyPart()
                                 .Split(new string[] { "\n" }, StringSplitOptions.None).Where(s => s.Length > 0).ToArray();

            Assert.AreEqual(4, bodyParts.Length);
            Assert.AreEqual(bodyParts[0], lines[5]);
            Assert.AreEqual(bodyParts[1], lines[6]);
            Assert.AreEqual(bodyParts[2], lines[7]);
            Assert.AreEqual(bodyParts[3], lines[8]);


            string[] transEndPart = transPart.GetTransactionEndPart()
                                    .Split(new string[] { "\n" }, StringSplitOptions.None).Where(s => s.Length > 0).ToArray();

            Assert.AreEqual(12, transEndPart.Length);
            Assert.AreEqual(transEndPart[0], lines[9]);
            Assert.AreEqual(transEndPart[1], lines[10]);
            Assert.AreEqual(transEndPart[2], lines[11]);
            Assert.AreEqual(transEndPart[3], lines[12]);
            Assert.AreEqual(transEndPart[4], lines[13]);
            Assert.AreEqual(transEndPart[5], lines[14]);
            Assert.AreEqual(transEndPart[6], lines[15]);
            Assert.AreEqual(transEndPart[7], lines[16]);
            Assert.AreEqual(transEndPart[8], lines[17]);
            Assert.AreEqual(transEndPart[9], lines[18]);
            Assert.AreEqual(transEndPart[10], lines[19]);
            Assert.AreEqual(transEndPart[11], lines[20]);
        }
Exemplo n.º 20
0
 public void VisitImport(ImportStatement i)
 {
     foreach (var name in i.names)
     {
         if (name.alias == null)
         {
             gen.Using(name.orig.ToString());
         }
         else
         {
             gen.Using(
                 name.alias.Name,
                 string.Join(
                     ".",
                     name.orig.segs.Concat(new[] { name.alias })
                         .Select(s => gen.EscapeKeywordName(s.Name))));
         }
     }
 }
Exemplo n.º 21
0
 public PythonImport(IProjectContent projectContent, ImportStatement importStatement)
     : base(projectContent)
 {
     this.importStatement = importStatement;
     AddUsings();
 }
Exemplo n.º 22
0
 // ImportStatement
 public override bool Walk(ImportStatement node) { return false; }
Exemplo n.º 23
0
            protected internal override Node VisitImportStatement([NotNull] ImportStatement node)
            {
                this.Builder.Append($"IMPORT '{node.Uri}'");

                return(node);
            }
Exemplo n.º 24
0
 public void Visit(ImportStatement node)
 {
     // not applicable; terminate
 }
Exemplo n.º 25
0
 // ImportStatement
 public override bool Walk(ImportStatement node)
 {
     return(ShouldWalkWorker(node));
 }
Exemplo n.º 26
0
 public UpdatedImportStatement(ImportStatement import)
 {
     _import = import;
 }
Exemplo n.º 27
0
 public override void PostWalk(ImportStatement node)
 {
     PostWalkWorker(node);
 }
Exemplo n.º 28
0
        public override bool Walk(ImportStatement node)
        {
            int len = Math.Min(node.Names.Count, node.AsNames.Count);

            for (int i = 0; i < len; i++)
            {
                var curName = node.Names[i];
                var asName  = node.AsNames[i];

                string importing, saveName;
                Node   nameNode;
                if (curName.Names.Count == 0)
                {
                    continue;
                }
                else if (curName.Names.Count > 1)
                {
                    // import fob.oar
                    if (asName != null)
                    {
                        // import fob.oar as baz, baz becomes the value of the oar module
                        importing = curName.MakeString();
                        saveName  = asName.Name;
                        nameNode  = asName;
                    }
                    else
                    {
                        // plain import fob.oar, we bring in fob into the scope
                        saveName = importing = curName.Names[0].Name;
                        nameNode = curName.Names[0];
                    }
                }
                else
                {
                    // import fob
                    importing = curName.Names[0].Name;
                    if (asName != null)
                    {
                        saveName = asName.Name;
                        nameNode = asName;
                    }
                    else
                    {
                        saveName = importing;
                        nameNode = curName.Names[0];
                    }
                }

                ModuleReference modRef;

                var def = Scope.CreateVariable(nameNode, _unit, saveName);
                if (TryImportModule(importing, node.ForceAbsolute, out modRef))
                {
                    modRef.AddReference(_unit.DeclaringModule);

                    Debug.Assert(modRef.Module != null);
                    if (modRef.Module != null)
                    {
                        modRef.Module.Imported(_unit);

                        if (modRef.AnalysisModule != null)
                        {
                            def.AddTypes(_unit, modRef.AnalysisModule);
                        }
                        def.AddAssignment(nameNode, _unit);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 29
0
 public SymbolTable VisitImport(ImportStatement i)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 30
0
 public override void PostWalk(ImportStatement node)
 {
 }
Exemplo n.º 31
0
 public void Visit(ImportStatement importStatement)
 {
 }
Exemplo n.º 32
0
 public virtual void PostWalk(ImportStatement node)
 {
 }
Exemplo n.º 33
0
 public ImportResult(ImportStatement statement)
 {
     this.statement = statement;
 }
Exemplo n.º 34
0
 // ImportStatement
 public override bool Walk(ImportStatement node) { return Location >= node.StartIndex && Location <= node.EndIndex; }
Exemplo n.º 35
0
 public SuccesfulImport(ImportStatement statement, int rowsAffected)
     : base(statement)
 {
     this.rowsAffected = rowsAffected;
 }
Exemplo n.º 36
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

			if (Expect(Semicolon))
				LastParsedObject = null;

			CheckForPostSemicolonComment();

			importStatement.EndLocation = t.EndLocation;

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

			return importStatement;
		}
Exemplo n.º 37
0
 public UnsuccesfulImport(ImportStatement statement, string errorMsg)
     : base(statement)
 {
     this.errorMsg = errorMsg;
 }
        public override object Visit(ImportStatement that, object value = null)
        {
            PrintPrologue(that);
            PrintDefinition(that);
            PrintNodeId("Location", that.Location);
            PrintEpilogue(that);

            that.Name.Visit(this);
            that.Location.Visit(this);

            return null;
        }
Exemplo n.º 39
0
Arquivo: DDG.cs Projeto: xing2fan/PTVS
        public override bool Walk(ImportStatement node)
        {
            int len = Math.Min(node.Names.Count, node.AsNames.Count);

            for (int i = 0; i < len; i++)
            {
                var curName = node.Names[i];
                var asName  = node.AsNames[i];

                string         importing, saveName;
                NameExpression nameNode;
                if (curName.Names.Count == 0)
                {
                    continue;
                }
                else if (curName.Names.Count > 1)
                {
                    // import fob.oar
                    if (asName != null)
                    {
                        // import fob.oar as baz, baz becomes the value of the oar module
                        importing = curName.MakeString();
                        saveName  = asName.Name;
                        nameNode  = asName;
                    }
                    else
                    {
                        // plain import fob.oar, we bring in fob into the scope
                        saveName = importing = curName.Names[0].Name;
                        nameNode = curName.Names[0];
                    }
                }
                else
                {
                    // import fob
                    importing = curName.Names[0].Name;
                    if (asName != null)
                    {
                        saveName = asName.Name;
                        nameNode = asName;
                    }
                    else
                    {
                        saveName = importing;
                        nameNode = curName.Names[0];
                    }
                }

                // Ensure a variable exists, even if the import fails
                Scope.CreateVariable(nameNode, _unit, saveName);

                if (!TryImportModule(importing, node.ForceAbsolute, out var modRef, out var bits))
                {
                    _unit.DeclaringModule.AddUnresolvedModule(importing, node.ForceAbsolute);
                    continue;
                }

                _unit.DeclaringModule.AddModuleReference(modRef);

                var userMod = modRef.Module;
                Debug.Assert(userMod != null);

                if (userMod != null)
                {
                    userMod.Imported(_unit);

                    AssignImportedModule(nameNode, modRef, bits, saveName);
                }
            }
            return(true);
        }
Exemplo n.º 40
0
 public void VisitImport(ImportStatement i)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 41
0
 public ImportDefinition(DottedName name, ImportStatement import)
 {
     this.name            = name;
     this.importStatement = import;
 }
		public virtual void Visit(ImportStatement s)
		{
			VisitAbstractStmt(s);
		}
Exemplo n.º 43
0
        public override bool Walk(ImportStatement node)
        {
            UpdateLineInfo(node);

            return(base.Walk(node));
        }
Exemplo n.º 44
0
 public virtual void PostWalk(ImportStatement node) { }
Exemplo n.º 45
0
 private List <Inferred> InferImportStatement(ImportStatement node, Scope scope)
 {
     Debug.Print("Not implemented: InferImportStatementIn");
     return(null);
 }
Exemplo n.º 46
0
 public override void PostWalk(ImportStatement node) { }
Exemplo n.º 47
0
 public virtual object Visit(ImportStatement that, object value)
 {
     throw new System.NotImplementedException();
 }