Пример #1
0
 //^^ requires newDocumentToPreprocess.IsUpdatedVersionOf(this.SourceLocation.SourceDocument);
 internal override Directive MakeShallowCopy(ISourceDocument newDocumentToPreprocess)
 {
     ISourceLocation sloc = this.SourceLocation;
       //^ assume newDocumentToPreprocess.IsUpdatedVersionOf(sloc.SourceDocument); //follows from the precondition
       RegionDirective result = new RegionDirective(this.Label, newDocumentToPreprocess.GetCorrespondingSourceLocation(sloc));
       if (this.Endregion != null)
     result.endregion = new EndregionPart(this.Endregion.Label, newDocumentToPreprocess.GetCorrespondingSourceLocation(this.Endregion.SourceLocation));
       return result;
 }
Пример #2
0
 /// <summary>
 /// Parses a #region-#endregion directive, starting at the character following "region". 
 /// Adds a corresponding RegionDirective instance to this.preprocesorInformation.
 /// Leaves this.fragmentIndex pointing to the start of the first line after the matching #endif directive.
 /// Returns all source locations that are to be included in the preprocessor output. (No locations are returned if the include parameter is false.)
 /// </summary>
 /// <param name="include">True if the directive is part of an included block. If false, the directive is parsed but ignored. (No locations are returned.)</param>
 private IEnumerable<ISourceLocation> ParseRegion(bool include)
 {
     SourceLocationBuilder slb = new SourceLocationBuilder(this.GetSourceLocation(this.startOfCurrentLine, this.fragmentIndex-this.startOfCurrentLine));
       string label = this.ScanMessage();
       RegionDirective regionDirective = new RegionDirective(label, slb);
       this.preprocessorInformation.directives.Add(regionDirective);
       foreach (ISourceLocation includedSourceFragment in this.ParseSection(false, false, true, include, false))
     yield return includedSourceFragment;
       slb.UpdateToSpan(this.GetSourceLocation(this.fragmentIndex-1, 0));
 }