本文整理汇总了C#中ITextSourceVersion类的典型用法代码示例。如果您正苦于以下问题:C# ITextSourceVersion类的具体用法?C# ITextSourceVersion怎么用?C# ITextSourceVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextSourceVersion类属于命名空间,在下文中一共展示了ITextSourceVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StringTextSource
/// <summary>
/// Creates a new StringTextSource with the given text.
/// </summary>
public StringTextSource(string text, ITextSourceVersion version)
{
if (text == null)
throw new ArgumentNullException("text");
this.text = text;
this.version = version;
}
示例2: BelongsToSameDocumentAs
public bool BelongsToSameDocumentAs(ITextSourceVersion other)
{
if (other == null)
throw new ArgumentNullException("other");
Version o = other as Version;
return o != null && provider == o.provider;
}
示例3: RopeTextSource
/// <summary>
/// Creates a new RopeTextSource.
/// </summary>
public RopeTextSource(Rope<char> rope, ITextSourceVersion version)
{
if (rope == null)
throw new ArgumentNullException("rope");
this.rope = rope.Clone();
this.version = version;
}
示例4: ParseInformation
public ParseInformation(IUnresolvedFile unresolvedFile, ITextSourceVersion parsedVersion, bool isFullParseInformation)
{
if (unresolvedFile == null)
throw new ArgumentNullException("unresolvedFile");
this.unresolvedFile = unresolvedFile;
this.parsedVersion = parsedVersion;
this.isFullParseInformation = isFullParseInformation;
}
示例5: CSharpFullParseInformation
public CSharpFullParseInformation(CSharpUnresolvedFile unresolvedFile, ITextSourceVersion parsedVersion, SyntaxTree compilationUnit)
: base(unresolvedFile, parsedVersion, isFullParseInformation: true)
{
if (unresolvedFile == null)
throw new ArgumentNullException("unresolvedFile");
if (compilationUnit == null)
throw new ArgumentNullException("compilationUnit");
this.syntaxTree = compilationUnit;
}
示例6: StringTextSource
/// <summary>
/// Creates a new StringTextSource with the given text.
/// </summary>
public StringTextSource (string text, ITextSourceVersion version, Encoding encoding = null, bool useBom = true)
{
if (text == null)
throw new ArgumentNullException ("text");
this.text = text;
this.version = version;
this.UseBOM = useBom;
this.Encoding = encoding ?? Encoding.UTF8;
}
示例7: ImmutableTextTextSource
public ImmutableTextTextSource (ImmutableText immutableText, System.Text.Encoding encoding, bool useBom, ITextSourceVersion version = null)
{
if (immutableText == null)
throw new ArgumentNullException (nameof (immutableText));
this.immutableText = immutableText;
this.encoding = encoding;
UseBOM = useBom;
this.version = version;
}
示例8: PatchedFile
public PatchedFile(FileName fileName, IReadOnlyList<SearchResultMatch> matches, ITextSourceVersion oldVersion, ITextSourceVersion newVersion)
: base(fileName, matches)
{
if (oldVersion == null)
throw new ArgumentNullException("oldVersion");
if (newVersion == null)
throw new ArgumentNullException("newVersion");
this.oldVersion = oldVersion;
this.newVersion = newVersion;
}
示例9: CompareAge
public int CompareAge(ITextSourceVersion other)
{
if (other == null)
throw new ArgumentNullException("other");
var o = other as Version;
if (o == null || provider != o.provider)
throw new ArgumentException("Versions do not belong to the same document.");
// We will allow overflows, but assume that the maximum distance between checkpoints is 2^31-1.
// This is guaranteed on x86 because so many checkpoints don't fit into memory.
return Math.Sign(unchecked(id - o.id));
}
示例10: GetReuseMapTo
internal List<UnchangedSegment> GetReuseMapTo(ITextSourceVersion newVersion)
{
ITextSourceVersion oldVersion = this.Version;
if (oldVersion == null || newVersion == null)
return null;
if (!oldVersion.BelongsToSameDocumentAs(newVersion))
return null;
List<UnchangedSegment> reuseMap = new List<UnchangedSegment>();
reuseMap.Add(new UnchangedSegment(0, 0, this.TextLength));
foreach (var change in oldVersion.GetChangesTo(newVersion)) {
bool needsSegmentRemoval = false;
for (int i = 0; i < reuseMap.Count; i++) {
UnchangedSegment segment = reuseMap[i];
if (segment.NewOffset + segment.Length <= change.Offset) {
// change is completely after this segment
continue;
}
if (change.Offset + change.RemovalLength <= segment.NewOffset) {
// change is completely before this segment
segment.NewOffset += change.InsertionLength - change.RemovalLength;
reuseMap[i] = segment;
continue;
}
// Change is overlapping segment.
// Split segment into two parts: the part before change, and the part after change.
var segmentBefore = new UnchangedSegment(segment.OldOffset, segment.NewOffset, change.Offset - segment.NewOffset);
Debug.Assert(segmentBefore.Length < segment.Length);
int lengthAtEnd = segment.NewOffset + segment.Length - (change.Offset + change.RemovalLength);
var segmentAfter = new UnchangedSegment(
segment.OldOffset + segment.Length - lengthAtEnd,
change.Offset + change.InsertionLength,
lengthAtEnd);
Debug.Assert(segmentAfter.Length < segment.Length);
Debug.Assert(segmentBefore.Length + segmentAfter.Length <= segment.Length);
Debug.Assert(segmentBefore.NewOffset + segmentBefore.Length <= segmentAfter.NewOffset);
Debug.Assert(segmentBefore.OldOffset + segmentBefore.Length <= segmentAfter.OldOffset);
if (segmentBefore.Length > 0 && segmentAfter.Length > 0) {
reuseMap[i] = segmentBefore;
reuseMap.Insert(++i, segmentAfter);
} else if (segmentBefore.Length > 0) {
reuseMap[i] = segmentBefore;
} else {
reuseMap[i] = segmentAfter;
if (segmentAfter.Length <= 0)
needsSegmentRemoval = true;
}
}
if (needsSegmentRemoval)
reuseMap.RemoveAll(s => s.Length <= 0);
}
return reuseMap;
}
示例11: SnapshotDocument
public SnapshotDocument (string text, ITextSourceVersion version) : base (new StringBuffer (text), new PrimitiveLineSplitter ())
{
this.version = version;
Text = text;
ReadOnly = true;
}
示例12: GetCachedParseInformation
public ParseInformation GetCachedParseInformation(FileName fileName, ITextSourceVersion version, IProject parentProject)
{
var entry = GetFileEntry(fileName, false);
if (entry != null)
return entry.GetCachedParseInformation(version, parentProject);
else
return null;
}
示例13: GetExistingUnresolvedFile
public IUnresolvedFile GetExistingUnresolvedFile(FileName fileName, ITextSourceVersion version, IProject parentProject)
{
var entry = GetFileEntry(fileName, false);
if (entry != null)
return entry.GetExistingUnresolvedFile(version, parentProject);
else
return null;
}
示例14: CompareVersions
/// <summary>
/// Compares currentVersion with version.
/// -1 = currentVersion is older; 0 = same version; 1 = newVersion is older
/// </summary>
int CompareVersions(ITextSourceVersion newVersion)
{
if (currentVersion != null && newVersion != null && currentVersion.BelongsToSameDocumentAs(newVersion))
return currentVersion.CompareAge(newVersion);
else
return -1;
}
示例15: GetExistingUnresolvedFile
public IUnresolvedFile GetExistingUnresolvedFile(ITextSourceVersion version, IProject parentProject)
{
lock (this) {
if (version != null && CompareVersions(version) != 0) {
return null;
}
int index = FindIndexForProject(parentProject);
if (index < 0)
return null;
return entries[index].UnresolvedFile;
}
}