private void HandleQualifiedReference(string expectedNamespace, LanguageElement reference, FileChangeGroup fileChangeGroup, SourceFile file) { TypeReferenceExpression typeReference = GetTypeReference(reference); TypeDeclaration declaration; if (typeReference == null) declaration = GetTypeDeclarationFromElementReference(reference); else declaration = typeReference.GetDeclaration(true) as TypeDeclaration; string expectedQualifiedNamespace; if (declaration != null && (declaration.GetSourceFile() == null || declaration.GetSourceFile() == file)) { expectedQualifiedNamespace = GetExpectedNamespace(declaration.FileNode); fileChangeGroup.AddQualifyingReferenceChange(reference, expectedQualifiedNamespace); } //else // expectedQualifiedNamespace = expectedNamespace; }
private void HandleNamespaceImport(LanguageElement reference, string referenceFileName, NamespaceReference import, FileChangeGroup fileChangeGroup) { List<TypeDeclaration> typesFound = null; if (_TypesFound.ContainsKey(referenceFileName)) typesFound = _TypesFound[referenceFileName]; // All the types (whose namespaces are changing) found in this file. fileChangeGroup.PrepareForTrackingImports(referenceFileName); List<TypeDeclaration> alreadyHandledImports = fileChangeGroup.GetHandledImports(referenceFileName); List<string> newImportsNeeded = new List<string>(); foreach (TypeDeclaration typeDeclaration in typesFound) { if (alreadyHandledImports.IndexOf(typeDeclaration) < 0) { string expectedImport = GetExpectedNamespace(typeDeclaration.FileNode); if (newImportsNeeded.IndexOf(expectedImport) < 0) newImportsNeeded.Add(expectedImport); alreadyHandledImports.Add(typeDeclaration); } } for (int i = 0; i < newImportsNeeded.Count; i++) { bool isLast = i == newImportsNeeded.Count - 1; fileChangeGroup.AddNewImport(import.Range.Start, newImportsNeeded[i], reference.FileNode, isLast); } fileChangeGroup.RemoveNamespaceImport(import); }