public CodeStatementBlock(string name, string fullName, CodeLocation location, CodeElement parent) : base(name, fullName, location, parent) { Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Requires(!string.IsNullOrEmpty(fullName)); Contract.Requires(location != null); Contract.Requires(parent != null); }
internal CodeType(string name, string fullName, CodeLocation location, CodeElement parent) : base(name, fullName, location, parent) { Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Requires(!string.IsNullOrEmpty(fullName)); Contract.Requires(location != null); Contract.Requires(parent != null); }
public CodePackage(IntelliSenseCache cache, string name, string fullName, CodeElement parent) : base(name, fullName, CodeLocation.Abstract, parent) { Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Requires(!string.IsNullOrEmpty(fullName)); Contract.Requires(parent != null); _cache = cache; }
internal CodeElement(string name, string fullName, CodeLocation location, CodeElement parent) { Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Requires(!string.IsNullOrEmpty(fullName)); Contract.Requires(location != null); _name = name; _fullName = fullName; _location = location; _parent = parent; _children = new List<CodeElement>(); }
public override CodeElement[] GetMatchingElements() { // just going to be the top-level package names plus all types in java.lang CodeElement[] packages = _cache.GetPackages(); CodePackage[] javaLangPackage = _cache.ResolvePackage("java.lang", true); CodeType[] globalTypes = javaLangPackage.SelectMany(i => i.Children).OfType<CodeType>().ToArray(); CodeElement[] result = new CodeElement[packages.Length + globalTypes.Length]; Array.Copy(packages, result, packages.Length); Array.Copy(globalTypes, 0, result, packages.Length, globalTypes.Length); return result; }
public CodePackageStatement(string name, string fullName, CodeLocation location, CodeElement parent) : base(name, fullName, location, parent) { Contract.Requires(!string.IsNullOrEmpty(name)); Contract.Requires(!string.IsNullOrEmpty(fullName)); Contract.Requires(location != null); Contract.Requires(parent != null); }
internal virtual void AddChild(CodeElement child) { Contract.Requires<InvalidOperationException>(!IsFrozen); Contract.Requires(child != null); _children.Add(child); }
private void UpdateFile(CodeFileBuilder fileBuilder) { Contract.Requires(fileBuilder != null); CodeElement fileElement = fileBuilder.BuildElement(null); CodePhysicalFile file = fileElement as CodePhysicalFile; if (file == null) { throw new NotSupportedException(); } CodeElement[] elementsToAdd = file.GetDescendents(true).ToArray(); // apply changes to the cache using (_updateLock.WriteLock()) { CodePhysicalFile existingFile; if (_files.TryGetValue(file.FullName, out existingFile)) { // remove the file CodeElement[] elementsToRemove = existingFile.GetDescendents(true).ToArray(); foreach (var type in elementsToRemove.OfType <CodeType>()) { _types[type.Name].Remove(type); } string previousPackage = string.Empty; CodePackageStatement previousPackageStatement = elementsToRemove.OfType <CodePackageStatement>().FirstOrDefault(); if (previousPackageStatement != null) { previousPackage = previousPackageStatement.FullName; } _packages[previousPackage].Remove(existingFile); _packagesIgnoreCase[previousPackage].Remove(existingFile); _files.Remove(existingFile.FullName); } // now add the new file foreach (var type in elementsToAdd.OfType <CodeType>()) { HashSet <CodeType> types; if (!_types.TryGetValue(type.Name, out types)) { types = new HashSet <CodeType>(CodeElementLocationEqualityComparer.Default); _types.Add(type.Name, types); } types.Add(type); } string package = string.Empty; CodePackageStatement packageStatement = elementsToAdd.OfType <CodePackageStatement>().FirstOrDefault(); if (packageStatement != null) { package = packageStatement.FullName; } HashSet <CodePhysicalFile> packageFiles; if (!_packages.TryGetValue(package, out packageFiles)) { packageFiles = new HashSet <CodePhysicalFile>(ObjectReferenceEqualityComparer <CodePhysicalFile> .Default); _packages.Add(package, packageFiles); } packageFiles.Add(file); if (!_packagesIgnoreCase.TryGetValue(package, out packageFiles)) { packageFiles = new HashSet <CodePhysicalFile>(ObjectReferenceEqualityComparer <CodePhysicalFile> .Default); _packagesIgnoreCase.Add(package, packageFiles); } packageFiles.Add(file); _files.Add(file.FullName, file); } }