Exemplo n.º 1
0
        public object Part2(IParsedFile file)
        {
            var adapters = file.ToList <int>();

            adapters.Add(0);
            adapters.Sort();
            adapters.Add(adapters[^ 1] + 3);
Exemplo n.º 2
0
 /// <summary>
 /// Removes types and attributes from oldFile from the project, and adds those from newFile.
 /// </summary>
 /// <remarks>
 /// The update is done inside a write lock; when other threads access this project content
 /// from within a <c>using (Synchronize())</c> block, they will not see intermediate (inconsistent) state.
 /// </remarks>
 public void UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
 {
     if (oldFile != null && newFile != null)
     {
         if (!Platform.FileNameComparer.Equals(oldFile.FileName, newFile.FileName))
         {
             throw new ArgumentException("When both oldFile and newFile are specified, they must use the same file name.");
         }
     }
     readerWriterLock.EnterWriteLock();
     try {
         if (oldFile != null)
         {
             foreach (var element in oldFile.TopLevelTypeDefinitions)
             {
                 RemoveType(element);
             }
             if (newFile == null)
             {
                 fileDict.Remove(oldFile.FileName);
             }
         }
         if (newFile != null)
         {
             foreach (var element in newFile.TopLevelTypeDefinitions)
             {
                 AddType(element);
             }
             fileDict[newFile.FileName] = newFile;
         }
         AddRemoveAssemblyAttributes(oldFile != null ? oldFile.AssemblyAttributes : null, newFile != null ? newFile.AssemblyAttributes : null);
     } finally {
         readerWriterLock.ExitWriteLock();
     }
 }
        public IProjectContent UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
        {
            if (oldFile == null && newFile == null)
            {
                return(this);
            }
            if (oldFile != null && newFile != null)
            {
                if (!Platform.FileNameComparer.Equals(oldFile.FileName, newFile.FileName))
                {
                    throw new ArgumentException("When both oldFile and newFile are specified, they must use the same file name.");
                }
            }
            CSharpProjectContent pc = Clone();

            if (newFile == null)
            {
                pc.parsedFiles.Remove(oldFile.FileName);
            }
            else
            {
                pc.parsedFiles[newFile.FileName] = newFile;
            }
            return(pc);
        }
Exemplo n.º 4
0
        public object Part1(IParsedFile file)
        {
            var numbers = file.ToList <int>();
            var match   = numbers.First(number => numbers.IndexOf(2020 - number) != -1);

            return(match * (2020 - match));
        }
Exemplo n.º 5
0
        public object Part2(IParsedFile file)
        {
            const ulong invalid = 375054920UL;
            var         numbers = file.ToList <string>().Select(ulong.Parse).ToArray();
            var         prefix  = new BigInteger[numbers.Length];

            prefix[0] = numbers[0];
            for (int i = 1; i < numbers.Length; i++)
            {
                prefix[i] = prefix[i - 1] + numbers[i];
            }
            for (int i = 0; i < numbers.Length; i++)
            {
                for (int j = i + 1; j < numbers.Length; j++)
                {
                    if (prefix[j] - prefix[i] == invalid)
                    {
                        var segment = numbers.Skip(i + 1).Take(j - i);
                        Debug.Assert(segment.Aggregate(0UL, (a, c) => a + c) == invalid);
                        return(segment.Min() + segment.Max());
                    }
                }
            }

            return(null);
        }
Exemplo n.º 6
0
        public object Part1(IParsedFile file)
        {
            var bootloader = ParseBootloader(file).ToArray();

            CorrectBootloader(bootloader, out var acc);
            return(acc);
        }
Exemplo n.º 7
0
		public GenerateNamespaceImport GetResult (IParsedFile unit, IType type, MonoDevelop.Ide.Gui.Document doc)
		{
			GenerateNamespaceImport result;
			if (cache.TryGetValue (type.Namespace, out result))
				return result;
			result = new GenerateNamespaceImport ();
			cache[type.Namespace] = result;
			TextEditorData data = doc.Editor;
			
			result.InsertNamespace  = false;
			var loc = new TextLocation (data.Caret.Line, data.Caret.Column);
			foreach (var ns in RefactoringOptions.GetUsedNamespaces (doc, loc)) {
				if (type.Namespace == ns) {
					result.GenerateUsing = false;
					return result;
				}
			}
			
			result.GenerateUsing = true;
			string name = type.Name;
			
			foreach (string ns in RefactoringOptions.GetUsedNamespaces (doc, loc)) {
				if (doc.Compilation.MainAssembly.GetTypeDefinition (ns, name, type.TypeParameterCount) != null) {
					result.GenerateUsing = false;
					result.InsertNamespace = true;
					return result;
				}
			}
			return result;
		}
Exemplo n.º 8
0
 public Day2Test()
 {
     fileMock = new ParsedFile(new [] {
         new ParsedLine("1-3 a: abcde".Split(' ')),
         new ParsedLine("1-3 b: cdefg".Split(' ')),
         new ParsedLine("2-9 c: ccccccccc".Split(' '))
     });
 }
Exemplo n.º 9
0
        public object Part1(IParsedFile file)
        {
            file.NextLine();
            file.NextLine();
            file.NextLine();
            var a = file.NextLine();

            return(a);
        }
Exemplo n.º 10
0
        public object Part1(IParsedFile file)
        {
            // (bag, parent)
            var parentPairing = new HashSet <(string bag, string parent)>();

            while (!file.Empty)
            {
                var line         = file.NextLine().ToSingleString();
                var containIndex = line.IndexOf(" contain ", StringComparison.Ordinal);
                var bag          = line[..(containIndex - 1)];
Exemplo n.º 11
0
        public object Part1(IParsedFile file)
        {
            var adapters = file.ToList <int>();

            adapters.Add(adapters.Max() + 3);
            adapters.Add(0);
            adapters.Sort();
            var enumer = adapters.Zip(adapters.Skip(1)).Select((x) => x.Second - x.First);

            return(enumer.Count(x => x == 1) * enumer.Count(x => x == 3));
        }
Exemplo n.º 12
0
        public object Part1(IParsedFile file)
        {
            var height = file.Count;
            var line   = file.NextLine().ToSingleString();
            var layout = new char[line.Length, height];

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < line.Length; x++)
                {
                    layout[x, y] = line[x];
                }
                if (!file.Empty)
                {
                    line = file.NextLine().ToSingleString();
                }
            }

            bool changed = true;

            while (changed)
            {
                changed = false;
                var newLayout = (char[, ])layout.Clone();
                for (int y = 0; y < layout.GetLength(1); y++)
                {
                    for (int x = 0; x < layout.GetLength(0); x++)
                    {
                        if (layout[x, y] == '.')
                        {
                            continue;
                        }
                        var adjSeats = CountAdjacent(layout, '#', x, y);
                        if (layout[x, y] == 'L' && adjSeats == 0)
                        {
                            newLayout[x, y] = '#';
                            changed         = true;
                        }
                        else if (layout[x, y] == '#' && adjSeats >= 4)
                        {
                            newLayout[x, y] = 'L';
                            changed         = true;
                        }
                    }
                }

                layout = newLayout;
            }

            return(CountSeats(layout));
        }
Exemplo n.º 13
0
        public object Part1(IParsedFile file)
        {
            var numbers = file.ToList <string>().Select(ulong.Parse).ToArray();

            for (int i = 25; i < numbers.Length; i++)
            {
                var seg = new ArraySegment <ulong>(numbers, i - 25, 25);
                if (GetSums(seg).All(x => x != numbers[i]))
                {
                    return(numbers[i]);
                }
            }
            throw new Exception();
        }
Exemplo n.º 14
0
 private static IEnumerable <Operation> ParseBootloader(IParsedFile file)
 {
     while (!file.Empty)
     {
         var line = file.NextLine();
         Op  op   = line.NextElement <string>() switch {
             "acc" => Op.Acc,
             "nop" => Op.Nop,
             "jmp" => Op.Jmp,
             _ => throw new Exception()
         };
         yield return(new Operation(op, line.NextElement <int>()));
     }
 }
Exemplo n.º 15
0
		public LanguageItemWindow (ExtensibleTextEditor ed, Gdk.ModifierType modifierState, ResolveResult result, string errorInformations, IParsedFile unit)
		{
			Ambience ambience = AmbienceService.GetAmbience (ed.Document.MimeType);
			string tooltip = null;
			if (result is UnknownIdentifierResolveResult) {
				tooltip = string.Format ("error CS0103: The name `{0}' does not exist in the current context", ((UnknownIdentifierResolveResult)result).Identifier);
			} else if (result is UnknownMemberResolveResult) {
				var ur = (UnknownMemberResolveResult)result;
				if (ur.TargetType.Kind != TypeKind.Unknown)
					tooltip = string.Format ("error CS0117: `{0}' does not contain a definition for `{1}'", ur.TargetType.FullName, ur.MemberName);
			} else if (result != null && ed.TextEditorResolverProvider != null) {
				tooltip = ed.TextEditorResolverProvider.CreateTooltip (unit, result, errorInformations, ambience, modifierState);
				// TODO: Type sysetm conversion. (btw. this isn't required because the analyzer should provide semantic error messages.)	
				//				if (result.ResolveErrors.Count > 0) {
				//					StringBuilder sb = new StringBuilder ();
				//					sb.Append (tooltip);
				//					sb.AppendLine ();
				//					sb.AppendLine ();
				//					sb.AppendLine (GettextCatalog.GetPluralString ("Error:", "Errors:", result.ResolveErrors.Count));
				//					for (int i = 0; i < result.ResolveErrors.Count; i++) {
				//						sb.Append ('\t');
				//						sb.Append (result.ResolveErrors[i]);
				//						if (i + 1 < result.ResolveErrors.Count) 
				//							sb.AppendLine ();
				//					}
				//					tooltip = sb.ToString ();
				//				}
			} else {
				tooltip = errorInformations;
			}
			if (string.IsNullOrEmpty (tooltip)|| tooltip == "?") {
				IsEmpty = true;
				return;
			}

			var label = new MonoDevelop.Components.FixedWidthWrapLabel () {
				Wrap = Pango.WrapMode.WordChar,
				Indent = -20,
				BreakOnCamelCasing = true,
				BreakOnPunctuation = true,
				Markup = tooltip,
			};
			this.BorderWidth = 3;
			Add (label);
			UpdateFont (label);
			
			EnableTransparencyControl = true;
		}
Exemplo n.º 16
0
        public DefaultTypeDefinition(IParsedFile parsedFile, string ns, string name)
        {
            if (parsedFile == null)
            {
                throw new ArgumentNullException("parsedFile");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("name");
            }
            this.parsedFile     = parsedFile;
            this.projectContent = parsedFile.ProjectContent;
            this.ns             = ns ?? string.Empty;
            this.name           = name;

            this.compoundTypeDefinition = this;
        }
Exemplo n.º 17
0
        public object Part2(IParsedFile file)
        {
            var bootloader = ParseBootloader(file).ToArray();
            int i          = 0;

            while (i < bootloader.Length)
            {
                i = Array.FindIndex(bootloader, i, o => o.Op != Op.Acc);
                var op = bootloader[i++];
                op.Switch();
                if (CorrectBootloader(bootloader, out var acc))
                {
                    return(acc);
                }
                op.Switch();
            }
            throw new Exception();
        }
Exemplo n.º 18
0
        public object Part2(IParsedFile file)
        {
            var valid = 0;

            while (!file.Empty)
            {
                var line = file.NextLine();
                var rule = line.NextElement <string>().Split('-').Select(int.Parse).ToArray();
                var ch   = line.NextElement <string>()[0];
                var str  = line.NextElement <string>();
                if (rule.Count(x => ch == str[x - 1]) == 1)
                {
                    valid++;
                }
            }

            return(valid);
        }
Exemplo n.º 19
0
        public object Part1(IParsedFile file)
        {
            var valid = 0;

            while (!file.Empty)
            {
                var line   = file.NextLine();
                var minmax = line.NextElement <string>().Split('-').Select(int.Parse).ToArray();
                var ch     = line.NextElement <string>()[0];
                var str    = line.NextElement <string>();
                var cnt    = str.Count(x => x == ch);
                if (cnt >= minmax[0] && cnt <= minmax[1])
                {
                    valid++;
                }
            }

            return(valid);
        }
Exemplo n.º 20
0
        public DefaultTypeDefinition(ITypeDefinition declaringTypeDefinition, string name)
        {
            if (declaringTypeDefinition == null)
            {
                throw new ArgumentNullException("declaringTypeDefinition");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("name");
            }
            this.projectContent          = declaringTypeDefinition.ProjectContent;
            this.parsedFile              = declaringTypeDefinition.ParsedFile;
            this.declaringTypeDefinition = declaringTypeDefinition;

            this.name = name;
            this.ns   = declaringTypeDefinition.Namespace;

            this.compoundTypeDefinition = this;
        }
Exemplo n.º 21
0
        public object Part2(IParsedFile file)
        {
            var numbers = file.ToList <int>();

            for (int x = 0; x < numbers.Count; x++)
            {
                for (int y = x + 1; y < numbers.Count; y++)
                {
                    for (int z = y + 1; z < numbers.Count; z++)
                    {
                        if (numbers[x] + numbers[y] + numbers[z] == 2020)
                        {
                            return(numbers[x] * numbers[y] * numbers[z]);
                        }
                    }
                }
            }

            throw new Exception();
        }
Exemplo n.º 22
0
        public object Part1(IParsedFile file)
        {
            string[] rows = file.ToList <string>().ToArray();
            int      x = 0, y = 0;
            var      count = 0;

            while (y < rows.Length)
            {
                if (rows[y][x] == '#')
                {
                    count++;
                }
                x += 3;
                if (x >= rows[y].Length)
                {
                    x %= rows[y].Length;
                }
                y++;
            }

            return(count);
        }
Exemplo n.º 23
0
        public GenerateNamespaceImport GetResult(IParsedFile unit, IType type, MonoDevelop.Ide.Gui.Document doc)
        {
            GenerateNamespaceImport result;

            if (cache.TryGetValue(type.Namespace, out result))
            {
                return(result);
            }
            result = new GenerateNamespaceImport();
            cache[type.Namespace] = result;
            TextEditorData data = doc.Editor;

            result.InsertNamespace = false;
            var loc = new TextLocation(data.Caret.Line, data.Caret.Column);

            foreach (var ns in RefactoringOptions.GetUsedNamespaces(doc, loc))
            {
                if (type.Namespace == ns)
                {
                    result.GenerateUsing = false;
                    return(result);
                }
            }

            result.GenerateUsing = true;
            string name = type.Name;

            foreach (string ns in RefactoringOptions.GetUsedNamespaces(doc, loc))
            {
                if (doc.Compilation.MainAssembly.GetTypeDefinition(ns, name, type.TypeParameterCount) != null)
                {
                    result.GenerateUsing   = false;
                    result.InsertNamespace = true;
                    return(result);
                }
            }
            return(result);
        }
Exemplo n.º 24
0
 public ParsedDocumentDecorator(IParsedFile parsedFile) : base(parsedFile.FileName)
 {
     this.parsedFile = parsedFile;
 }
		public string CreateTooltip (IParsedFile unit, ResolveResult result, string errorInformations, Ambience ambience, Gdk.ModifierType modifierState)
		{
			OutputSettings settings = new OutputSettings (OutputFlags.ClassBrowserEntries | OutputFlags.IncludeParameterName | OutputFlags.IncludeKeywords | OutputFlags.IncludeMarkup | OutputFlags.UseFullName);
			//			if ((Gdk.ModifierType.ShiftMask & modifierState) == Gdk.ModifierType.ShiftMask) {
			//				settings.EmitNameCallback = delegate(object domVisitable, ref string outString) {
			//					// crop used namespaces.
			//					if (unit != null) {
			//						int len = 0;
			//						foreach (var u in unit.Usings) {
			//							foreach (string ns in u.Namespaces) {
			//								if (outString.StartsWith (ns + ".")) {
			//									len = Math.Max (len, ns.Length + 1);
			//								}
			//							}
			//						}
			//						string newName = outString.Substring (len);
			//						int count = 0;
			//						// check if there is a name clash.
			//						if (dom.GetType (newName) != null)
			//							count++;
			//						foreach (IUsing u in unit.Usings) {
			//							foreach (string ns in u.Namespaces) {
			//								if (dom.GetType (ns + "." + newName) != null)
			//									count++;
			//							}
			//						}
			//						if (len > 0 && count == 1)
			//							outString = newName;
			//					}
			//				};
			//			}
			
			// Approximate value for usual case
			StringBuilder s = new StringBuilder (150);
			string doc = null;
			if (result != null) {
				if (result is UnknownIdentifierResolveResult) {
					s.Append (String.Format (GettextCatalog.GetString ("Unresolved identifier '{0}'"), ((UnknownIdentifierResolveResult)result).Identifier));
				} else if (result.IsError) {
					s.Append (GettextCatalog.GetString ("Resolve error."));
				} else if (result is LocalResolveResult) {
					var lr = (LocalResolveResult)result;
					s.Append ("<small><i>");
					s.Append (lr.IsParameter ? paramStr : localStr);
					s.Append ("</i></small>\n");
					s.Append (ambience.GetString (lr.Variable.Type, settings));
					s.Append (" ");
					s.Append (lr.Variable.Name);
				} else if (result is MethodGroupResolveResult) {
					var mrr = (MethodGroupResolveResult)result;
					s.Append ("<small><i>");
					s.Append (methodStr);
					s.Append ("</i></small>\n");
					var allMethods = new List<IMethod> (mrr.Methods);
					foreach (var l in mrr.GetExtensionMethods ()) {
						allMethods.AddRange (l);
					}
					
					var method = allMethods.FirstOrDefault ();
					if (method != null) {
						s.Append (ambience.GetString (method, settings));
						if (allMethods.Count > 1) {
							int overloadCount = allMethods.Count - 1;
							s.Append (string.Format (GettextCatalog.GetPluralString (" (+{0} overload)", " (+{0} overloads)", overloadCount), overloadCount));
						}
						doc = AmbienceService.GetDocumentationSummary (method);
					}
				} else if (result is MemberResolveResult) {
					var member = ((MemberResolveResult)result).Member;
					s.Append ("<small><i>");
					s.Append (GetString (member));
					s.Append ("</i></small>\n");
					var field = member as IField;
					if (field != null && field.IsConst) {
						s.Append (ambience.GetString (field.Type, settings));
						s.Append (" ");
						s.Append (field.Name);
						s.Append (" = ");
						s.Append (GetConst (field.ConstantValue));
						s.Append (";");
					} else {
						s.Append (ambience.GetString (member, settings));
					}
					doc = AmbienceService.GetDocumentationSummary (member);
				} else if (result is NamespaceResolveResult) {
					s.Append ("<small><i>");
					s.Append (namespaceStr);
					s.Append ("</i></small>\n");
					s.Append (ambience.GetString (((NamespaceResolveResult)result).NamespaceName, settings));
				} else {
					var tr = result;
					var typeString = GetString (tr.Type);
					if (!string.IsNullOrEmpty (typeString)) {
						s.Append ("<small><i>");
						s.Append (typeString);
						s.Append ("</i></small>\n");
					}
					settings.OutputFlags |= OutputFlags.UseFullName;
					s.Append (ambience.GetString (tr.Type, settings));
					doc = AmbienceService.GetDocumentationSummary (tr.Type.GetDefinition ());
				}
				
				if (!string.IsNullOrEmpty (doc)) {
					s.Append ("\n<small>");
					s.Append (AmbienceService.GetDocumentationMarkup ("<summary>" + doc + "</summary>"));
					s.Append ("</small>");
				}
			}
			
			if (!string.IsNullOrEmpty (errorInformations)) {
				if (s.Length != 0)
					s.Append ("\n\n");
				s.Append ("<small>");
				s.Append (errorInformations);
				s.Append ("</small>");
			}
			return s.ToString ();
		}
Exemplo n.º 26
0
 /// <summary>
 /// Gets the member defined at the specified location.
 /// Returns null if no member is defined at that location.
 /// </summary>
 public static IUnresolvedMember GetMember(this IParsedFile file, int line, int column)
 {
     return(file.GetMember(new TextLocation(line, column)));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Gets the type (potentially a nested type) defined at the specified location.
 /// Returns null if no type is defined at that location.
 /// </summary>
 public static IUnresolvedTypeDefinition GetInnermostTypeDefinition(this IParsedFile file, int line, int column)
 {
     return(file.GetInnermostTypeDefinition(new TextLocation(line, column)));
 }
Exemplo n.º 28
0
 /// <summary>
 /// Gets all unresolved type definitions from the file.
 /// For partial classes, each part is returned.
 /// </summary>
 public static IEnumerable <IUnresolvedTypeDefinition> GetAllTypeDefinitions(this IParsedFile file)
 {
     return(TreeTraversal.PreOrder(file.TopLevelTypeDefinitions, t => t.NestedTypes));
 }
		public void UpdateProjectContent (IParsedFile oldFile, IParsedFile newFile)
		{}
        public LanguageItemWindow(ExtensibleTextEditor ed, Gdk.ModifierType modifierState, ResolveResult result, string errorInformations, IParsedFile unit)
        {
            string tooltip = null;

            if (result is UnknownIdentifierResolveResult)
            {
                tooltip = string.Format("error CS0103: The name `{0}' does not exist in the current context", ((UnknownIdentifierResolveResult)result).Identifier);
            }
            else if (result is UnknownMemberResolveResult)
            {
                var ur = (UnknownMemberResolveResult)result;
                if (ur.TargetType.Kind != TypeKind.Unknown)
                {
                    tooltip = string.Format("error CS0117: `{0}' does not contain a definition for `{1}'", ur.TargetType.FullName, ur.MemberName);
                }
            }
            else if (result != null && ed.TextEditorResolverProvider != null)
            {
                //tooltip = ed.TextEditorResolverProvider.CreateTooltip (unit, result, errorInformations, ambience, modifierState);
                // TODO: Type sysetm conversion. (btw. this isn't required because the analyzer should provide semantic error messages.)
                //				if (result.ResolveErrors.Count > 0) {
                //					StringBuilder sb = new StringBuilder ();
                //					sb.Append (tooltip);
                //					sb.AppendLine ();
                //					sb.AppendLine ();
                //					sb.AppendLine (GettextCatalog.GetPluralString ("Error:", "Errors:", result.ResolveErrors.Count));
                //					for (int i = 0; i < result.ResolveErrors.Count; i++) {
                //						sb.Append ('\t');
                //						sb.Append (result.ResolveErrors[i]);
                //						if (i + 1 < result.ResolveErrors.Count)
                //							sb.AppendLine ();
                //					}
                //					tooltip = sb.ToString ();
                //				}
            }
            else
            {
                tooltip = errorInformations;
            }
            if (string.IsNullOrEmpty(tooltip) || tooltip == "?")
            {
                IsEmpty = true;
                return;
            }

            var label = new MonoDevelop.Components.FixedWidthWrapLabel()
            {
                Wrap               = Pango.WrapMode.WordChar,
                Indent             = -20,
                BreakOnCamelCasing = true,
                BreakOnPunctuation = true,
                Markup             = tooltip,
            };

            this.BorderWidth = 3;
            Add(label);
            UpdateFont(label);

            EnableTransparencyControl = true;
        }
 void IProjectContent.UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
 {
     throw new NotSupportedException();
 }
		private CompoundTypeDefinition(IParsedFile parsedFile, string ns, string name)
			: base(parsedFile, ns, name)
		{
		}
Exemplo n.º 33
0
		void IProjectContent.UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
		{
			throw new NotSupportedException();
		}
		public IProjectContent UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
		{
			if (oldFile == null && newFile == null)
				return this;
			if (oldFile != null && newFile != null) {
				if (!Platform.FileNameComparer.Equals(oldFile.FileName, newFile.FileName))
					throw new ArgumentException("When both oldFile and newFile are specified, they must use the same file name.");
			}
			CSharpProjectContent pc = Clone();
			if (newFile == null)
				pc.parsedFiles.Remove(oldFile.FileName);
			else
				pc.parsedFiles[newFile.FileName] = newFile;
			return pc;
		}
Exemplo n.º 35
0
		/// <summary>
		/// Removes types and attributes from oldFile from the project, and adds those from newFile.
		/// </summary>
		/// <remarks>
		/// The update is done inside a write lock; when other threads access this project content
		/// from within a <c>using (Synchronize())</c> block, they will not see intermediate (inconsistent) state.
		/// </remarks>
		public void UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
		{
			if (oldFile != null && newFile != null) {
				if (!Platform.FileNameComparer.Equals(oldFile.FileName, newFile.FileName))
					throw new ArgumentException("When both oldFile and newFile are specified, they must use the same file name.");
			}
			readerWriterLock.EnterWriteLock();
			try {
				if (oldFile != null) {
					foreach (var element in oldFile.TopLevelTypeDefinitions) {
						RemoveType(element);
					}
					if (newFile == null) {
						fileDict.Remove(oldFile.FileName);
					}
				}
				if (newFile != null) {
					foreach (var element in newFile.TopLevelTypeDefinitions) {
						AddType(element);
					}
					fileDict[newFile.FileName] = newFile;
				}
				AddRemoveAssemblyAttributes(oldFile != null ? oldFile.AssemblyAttributes : null, newFile != null ? newFile.AssemblyAttributes : null);
			} finally {
				readerWriterLock.ExitWriteLock();
			}
		}
Exemplo n.º 36
0
 /// <summary>
 /// Gets the type (potentially a nested type) defined at the specified location.
 /// Returns null if no type is defined at that location.
 /// </summary>
 public static ITypeDefinition GetTypeDefinition(this IParsedFile file, int line, int column)
 {
     return(file.GetTypeDefinition(new AstLocation(line, column)));
 }
Exemplo n.º 37
0
 /// <summary>
 /// Gets the member defined at the specified location.
 /// Returns null if no member is defined at that location.
 /// </summary>
 public static IMember GetMember(this IParsedFile file, int line, int column)
 {
     return(file.GetMember(new AstLocation(line, column)));
 }
Exemplo n.º 38
0
 public void UpdateProjectContent(IParsedFile oldFile, IParsedFile newFile)
 {
 }
Exemplo n.º 39
0
		public ParsedFileEventArgs (IParsedFile file)
		{
			this.File = file;
		}