public void RegisterUnresolvedFile(IProject project, IUnresolvedFile unresolvedFile)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            if (unresolvedFile == null)
            {
                throw new ArgumentNullException("unresolvedFile");
            }
            FreezableHelper.Freeze(unresolvedFile);
            var newParseInfo = new ParseInformation(unresolvedFile, null, false);

            rwLock.EnterWriteLock();
            try {
                int index = FindIndexForProject(project);
                if (index >= 0)
                {
                    currentVersion = null;
                    var args = new ParseInformationEventArgs(project, entries[index].UnresolvedFile, newParseInfo);
                    entries[index] = new ProjectEntry(project, unresolvedFile, null);
                    project.OnParseInformationUpdated(args);
                    parserService.RaiseParseInformationUpdated(args);
                }
            } finally {
                rwLock.ExitWriteLock();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Overwrites the properties in this HighlightingColor with those from the given color;
 /// but maintains the current values where the properties of the given color return <c>null</c>.
 /// </summary>
 public void MergeWith(HighlightingColor color)
 {
     FreezableHelper.ThrowIfFrozen(this);
     if (color.fontWeight != null)
     {
         this.fontWeight = color.fontWeight;
     }
     if (color.fontStyle != null)
     {
         this.fontStyle = color.fontStyle;
     }
     if (color.foreground != null)
     {
         this.foreground = color.foreground;
     }
     if (color.background != null)
     {
         this.background = color.background;
     }
     if (color.underline != null)
     {
         this.underline = color.underline;
     }
     if (color.fontFamily != null)
     {
         this.fontFamily = color.fontFamily;
     }
     if (color.fontSize != null)
     {
         this.fontSize = color.fontSize;
     }
 }
Exemplo n.º 3
0
 protected override void FreezeInternal()
 {
     base.FreezeInternal();
     FreezableHelper.Freeze(addAccessor);
     FreezableHelper.Freeze(removeAccessor);
     FreezableHelper.Freeze(invokeAccessor);
 }
Exemplo n.º 4
0
 protected override void FreezeInternal()
 {
     parameters = FreezableHelper.FreezeListAndElements(parameters);
     FreezableHelper.Freeze(getter);
     FreezableHelper.Freeze(setter);
     base.FreezeInternal();
 }
 protected override void FreezeInternal()
 {
     conditionalSymbols       = FreezableHelper.FreezeList(conditionalSymbols);
     specificWarningsAsErrors = FreezableHelper.FreezeList(specificWarningsAsErrors);
     disabledWarnings         = FreezableHelper.FreezeList(disabledWarnings);
     base.FreezeInternal();
 }
Exemplo n.º 6
0
 protected override void FreezeInternal()
 {
     returnTypeAttributes = FreezableHelper.FreezeListAndElements(returnTypeAttributes);
     typeParameters       = FreezableHelper.FreezeListAndElements(typeParameters);
     parameters           = FreezableHelper.FreezeListAndElements(parameters);
     base.FreezeInternal();
 }
Exemplo n.º 7
0
 protected override void FreezeInternal()
 {
     base.FreezeInternal();
     baseTypes      = FreezableHelper.FreezeList(baseTypes);
     typeParameters = FreezableHelper.FreezeListAndElements(typeParameters);
     nestedTypes    = FreezableHelper.FreezeListAndElements(nestedTypes);
     members        = FreezableHelper.FreezeListAndElements(members);
 }
Exemplo n.º 8
0
 protected virtual void FreezeInternal()
 {
     attributes = FreezableHelper.FreezeListAndElements(attributes);
     if (rareFields != null)
     {
         rareFields.FreezeInternal();
     }
 }
Exemplo n.º 9
0
 public void AddDocumentation(IUnresolvedEntity entity, string xmlDocumentation)
 {
     FreezableHelper.ThrowIfFrozen(this);
     if (documentation == null)
     {
         documentation = new Dictionary <IUnresolvedEntity, string>();
     }
     documentation.Add(entity, xmlDocumentation);
 }
Exemplo n.º 10
0
 protected override void FreezeInternal()
 {
     base.FreezeInternal();
     rootUsingScope.Freeze();
     topLevelTypeDefinitions = FreezableHelper.FreezeListAndElements(topLevelTypeDefinitions);
     assemblyAttributes      = FreezableHelper.FreezeListAndElements(assemblyAttributes);
     moduleAttributes        = FreezableHelper.FreezeListAndElements(moduleAttributes);
     usingScopes             = FreezableHelper.FreezeListAndElements(usingScopes);
 }
Exemplo n.º 11
0
 void SetFlag(byte flag, bool value)
 {
     FreezableHelper.ThrowIfFrozen(this);
     if (value)
     {
         this.flags |= flag;
     }
     else
     {
         this.flags &= unchecked ((byte)~flag);
     }
 }
Exemplo n.º 12
0
        protected override void FreezeInternal()
        {
            usings        = FreezableHelper.FreezeList(usings);
            usingAliases  = FreezableHelper.FreezeList(usingAliases);
            externAliases = FreezableHelper.FreezeList(externAliases);

            // In current model (no child scopes), it makes sense to freeze the parent as well
            // to ensure the whole lookup chain is immutable.
            if (parent != null)
            {
                parent.Freeze();
            }

            base.FreezeInternal();
        }
Exemplo n.º 13
0
        ProjectEntry DoParse(ITextSource fileContent, IProject parentProject, bool fullParseInformationRequested,
                             CancellationToken cancellationToken)
        {
            if (parser == null)
            {
                return(default(ProjectEntry));
            }

            if (fileContent == null)
            {
                // No file content was specified. Because the callers of this method already check for currently open files,
                // we can assume that the file isn't open and simply read it from disk.
                try {
                    fileContent = SD.FileService.GetFileContentFromDisk(fileName, cancellationToken);
                } catch (IOException) {
                    // It is possible that the file gets deleted/becomes inaccessible while a background parse
                    // operation is enqueued, so we have to handle IO exceptions.
                    return(default(ProjectEntry));
                } catch (UnauthorizedAccessException) {
                    return(default(ProjectEntry));
                }
            }

            ProjectEntry result;

            rwLock.EnterUpgradeableReadLock();
            try {
                int index             = FindIndexForProject(parentProject);
                int versionComparison = CompareVersions(fileContent.Version);
                if (versionComparison > 0 || index < 0)
                {
                    // We're going backwards in time, or are requesting a project that is not an owner
                    // for this entry.
                    var parseInfo = ParseWithExceptionHandling(fileContent, fullParseInformationRequested, parentProject, cancellationToken);
                    FreezableHelper.Freeze(parseInfo.UnresolvedFile);
                    return(new ProjectEntry(parentProject, parseInfo.UnresolvedFile, parseInfo));
                }
                else
                {
                    if (versionComparison == 0 && index >= 0)
                    {
                        // Ensure we have parse info for the specified project (entry.UnresolvedFile is null for newly registered projects)
                        // If full parse info is requested, ensure we have full parse info.
                        if (entries[index].UnresolvedFile != null && !(fullParseInformationRequested && entries[index].CachedParseInformation == null))
                        {
                            // We already have the requested version parsed, just return it:
                            return(entries[index]);
                        }
                    }
                }

                ParseInformationEventArgs[] results = new ParseInformationEventArgs[entries.Count];
                for (int i = 0; i < entries.Count; i++)
                {
                    var parseInfo = ParseWithExceptionHandling(fileContent, fullParseInformationRequested, entries[i].Project, cancellationToken);
                    if (parseInfo == null)
                    {
                        throw new NullReferenceException(parser.GetType().Name + ".Parse() returned null");
                    }
                    if (fullParseInformationRequested && !parseInfo.IsFullParseInformation)
                    {
                        throw new InvalidOperationException(parser.GetType().Name + ".Parse() did not return full parse info as requested.");
                    }
                    OnDiskTextSourceVersion onDiskVersion = fileContent.Version as OnDiskTextSourceVersion;
                    if (onDiskVersion != null)
                    {
                        parseInfo.UnresolvedFile.LastWriteTime = onDiskVersion.LastWriteTime;
                    }
                    FreezableHelper.Freeze(parseInfo.UnresolvedFile);
                    results[i] = new ParseInformationEventArgs(entries[i].Project, entries[i].UnresolvedFile, parseInfo);
                }

                // Only if all parse runs succeeded, register the parse information.
                rwLock.EnterWriteLock();
                try {
                    currentVersion = fileContent.Version;
                    for (int i = 0; i < entries.Count; i++)
                    {
                        if (fullParseInformationRequested || (entries[i].CachedParseInformation != null && results[i].NewParseInformation.IsFullParseInformation))
                        {
                            entries[i] = new ProjectEntry(entries[i].Project, results[i].NewUnresolvedFile, results[i].NewParseInformation);
                        }
                        else
                        {
                            entries[i] = new ProjectEntry(entries[i].Project, results[i].NewUnresolvedFile, null);
                        }
                        if (entries[i].Project != null)
                        {
                            entries[i].Project.OnParseInformationUpdated(results[i]);
                        }
                        parserService.RaiseParseInformationUpdated(results[i]);
                    }
                    result = entries[index];
                } finally {
                    rwLock.ExitWriteLock();
                }
            } finally {
                rwLock.ExitUpgradeableReadLock();
            }
            parserService.RegisterForCacheExpiry(this);
            return(result);
        }
Exemplo n.º 14
0
 void FreezeInternal()
 {
     attributes = FreezableHelper.FreezeListAndElements(attributes);
     FreezableHelper.Freeze(defaultValue);
 }
Exemplo n.º 15
0
 protected void ThrowIfFrozen()
 {
     FreezableHelper.ThrowIfFrozen(this);
 }
Exemplo n.º 16
0
 protected override void FreezeInternal()
 {
     FreezableHelper.Freeze(constantValue);
     base.FreezeInternal();
 }
Exemplo n.º 17
0
 protected override void FreezeInternal()
 {
     base.FreezeInternal();
     interfaceImplementations = FreezableHelper.FreezeList(interfaceImplementations);
 }