本文整理汇总了C#中SourceCodeKind类的典型用法代码示例。如果您正苦于以下问题:C# SourceCodeKind类的具体用法?C# SourceCodeKind怎么用?C# SourceCodeKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceCodeKind类属于命名空间,在下文中一共展示了SourceCodeKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseText
public SyntaxTree ParseText(string code, SourceCodeKind kind)
{
var options = _roslynAbstraction.NewParseOptions<LanguageVersion, CSharpParseOptions>(
_roslynAbstraction.GetMaxValue<LanguageVersion>(), kind
);
return _roslynAbstraction.ParseText(typeof(CSharpSyntaxTree), code, options);
}
示例2: AssertNavigatedAsync
protected async Task AssertNavigatedAsync(string code, bool next, SourceCodeKind? sourceCodeKind = null)
{
var kinds = sourceCodeKind != null
? SpecializedCollections.SingletonEnumerable(sourceCodeKind.Value)
: new[] { SourceCodeKind.Regular, SourceCodeKind.Script };
foreach (var kind in kinds)
{
using (var workspace = await TestWorkspaceFactory.CreateWorkspaceFromFileAsync(
LanguageName,
compilationOptions: null,
parseOptions: DefaultParseOptions.WithKind(kind),
content: code))
{
var hostDocument = workspace.DocumentWithCursor;
var document = workspace.CurrentSolution.GetDocument(hostDocument.Id);
Assert.Empty((await document.GetSyntaxTreeAsync()).GetDiagnostics());
var targetPosition = await GoToAdjacentMemberCommandHandler.GetTargetPositionAsync(
document,
hostDocument.CursorPosition.Value,
next,
CancellationToken.None);
Assert.NotNull(targetPosition);
Assert.Equal(hostDocument.SelectedSpans.Single().Start, targetPosition.Value);
}
}
}
示例3: DocumentInfo
/// <summary>
/// Create a new instance of a <see cref="DocumentInfo"/>.
/// </summary>
private DocumentInfo(
DocumentId id,
string name,
IEnumerable<string> folders,
SourceCodeKind sourceCodeKind,
TextLoader loader,
string filePath,
bool isGenerated)
{
if (id == null)
{
throw new ArgumentNullException(nameof(id));
}
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
this.Id = id;
this.Name = name;
this.Folders = folders.ToImmutableReadOnlyListOrEmpty();
this.SourceCodeKind = sourceCodeKind;
this.TextLoader = loader;
this.FilePath = filePath;
this.IsGenerated = isGenerated;
}
示例4: CreateCommandSource
private ScriptSource/*!*/ CreateCommandSource(string/*!*/ command, SourceCodeKind kind, string/*!*/ sourceUnitId) {
#if SILVERLIGHT
return Engine.CreateScriptSourceFromString(command, kind);
#else
var encoding = GetSourceCodeEncoding();
return Engine.CreateScriptSource(new BinaryContentProvider(encoding.GetBytes(command)), sourceUnitId, encoding, kind);
#endif
}
示例5: AddDocument
public static DocumentId AddDocument(this Workspace workspace, ProjectId projectId, IEnumerable<string> folders, string name, SourceText initialText, SourceCodeKind sourceCodeKind = SourceCodeKind.Regular)
{
var id = projectId.CreateDocumentId(name, folders);
var oldSolution = workspace.CurrentSolution;
var newSolution = oldSolution.AddDocument(id, name, initialText, folders).GetDocument(id).WithSourceCodeKind(sourceCodeKind).Project.Solution;
workspace.TryApplyChanges(newSolution);
return id;
}
示例6: DocumentChecksumObjectInfo
public DocumentChecksumObjectInfo(DocumentId id, string name, IReadOnlyList<string> folders, SourceCodeKind sourceCodeKind, string filePath, bool isGenerated)
{
Id = id;
Name = name;
Folders = folders;
SourceCodeKind = sourceCodeKind;
FilePath = filePath;
IsGenerated = isGenerated;
}
示例7: StandardTextDocument
public StandardTextDocument(
DocumentProvider documentProvider,
IVisualStudioHostProject project,
DocumentKey documentKey,
IReadOnlyList<string> folderNames,
SourceCodeKind sourceCodeKind,
ITextUndoHistoryRegistry textUndoHistoryRegistry,
IVsFileChangeEx fileChangeService,
ITextBuffer openTextBuffer,
DocumentId id,
EventHandler updatedOnDiskHandler,
EventHandler<bool> openedHandler,
EventHandler<bool> closingHandler)
{
Contract.ThrowIfNull(documentProvider);
this.Project = project;
this.Id = id ?? DocumentId.CreateNewId(project.Id, documentKey.Moniker);
this.Folders = folderNames;
_documentProvider = documentProvider;
this.Key = documentKey;
this.SourceCodeKind = sourceCodeKind;
_itemMoniker = documentKey.Moniker;
_textUndoHistoryRegistry = textUndoHistoryRegistry;
_fileChangeTracker = new FileChangeTracker(fileChangeService, this.FilePath);
_fileChangeTracker.UpdatedOnDisk += OnUpdatedOnDisk;
_openTextBuffer = openTextBuffer;
_snapshotTracker = new ReiteratedVersionSnapshotTracker(openTextBuffer);
// The project system does not tell us the CodePage specified in the proj file, so
// we use null to auto-detect.
_doNotAccessDirectlyLoader = new FileTextLoader(documentKey.Moniker, defaultEncoding: null);
// If we aren't already open in the editor, then we should create a file change notification
if (openTextBuffer == null)
{
_fileChangeTracker.StartFileChangeListeningAsync();
}
if (updatedOnDiskHandler != null)
{
UpdatedOnDisk += updatedOnDiskHandler;
}
if (openedHandler != null)
{
Opened += openedHandler;
}
if (closingHandler != null)
{
Closing += closingHandler;
}
}
示例8: VerifyWorkerAsync
protected override Task VerifyWorkerAsync(
string code, int position, string expectedItemOrNull, string expectedDescriptionOrNull,
SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger, bool checkForAbsence,
int? glyph, int? matchPriority)
{
return base.VerifyWorkerAsync(code, position,
expectedItemOrNull, expectedDescriptionOrNull,
SourceCodeKind.Regular, usePreviousCharAsTrigger, checkForAbsence,
glyph, matchPriority);
}
示例9: GetDocumentExtension
public override string GetDocumentExtension(SourceCodeKind sourceCodeKind)
{
switch (sourceCodeKind)
{
case SourceCodeKind.Script:
return ".csx";
default:
return ".cs";
}
}
示例10: Create
public static DocumentInfo Create(
DocumentId id,
string name,
IEnumerable<string> folders = null,
SourceCodeKind sourceCodeKind = SourceCodeKind.Regular,
TextLoader loader = null,
string filePath = null,
bool isGenerated = false)
{
return new DocumentInfo(id, name, folders, sourceCodeKind, loader, filePath, isGenerated);
}
示例11: VerifyItemExists
protected void VerifyItemExists(string input, string expectedItem, string expectedDescriptionOrNull = null, SourceCodeKind? sourceCodeKind = null, bool usePreviousCharAsTrigger = false, bool experimental = false, int? glyph = null)
{
var provider = CreateProvider (input, sourceCodeKind, usePreviousCharAsTrigger);
if (provider.Find (expectedItem) == null) {
foreach (var item in provider)
Console.WriteLine (item.DisplayText);
}
Assert.IsNotNull(provider.Find(expectedItem), "item '" + expectedItem + "' not found.");
}
示例12: VerifyWorker
protected override void VerifyWorker(string code, int position, string expectedItemOrNull, string expectedDescriptionOrNull, SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger, bool checkForAbsence, bool experimental, int? glyph)
{
BaseVerifyWorker(code,
position,
expectedItemOrNull,
expectedDescriptionOrNull,
sourceCodeKind,
usePreviousCharAsTrigger,
checkForAbsence,
glyph);
}
示例13: VerifyAbsenceWithRefsAsync
private async Task VerifyAbsenceWithRefsAsync(SourceCodeKind kind, string text)
{
switch (kind)
{
case SourceCodeKind.Regular:
await VerifyWorkerAsync(text, absent: true, options: Options.Regular.WithRefsFeature());
break;
case SourceCodeKind.Script:
await VerifyWorkerAsync(text, absent: true, options: Options.Script.WithRefsFeature());
break;
}
}
示例14: GetDocumentExtension
public override string GetDocumentExtension(SourceCodeKind sourceCodeKind)
{
string result;
if (sourceCodeKind != SourceCodeKind.Script)
{
result = ".vb";
}
else
{
result = ".vbx";
}
return result;
}
示例15: VerifyWorkerAsync
protected override async Task VerifyWorkerAsync(string code, int position, string expectedItemOrNull, string expectedDescriptionOrNull, SourceCodeKind sourceCodeKind, bool usePreviousCharAsTrigger, bool checkForAbsence, bool experimental, int? glyph)
{
await VerifyAtPositionAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, experimental, glyph);
await VerifyAtEndOfFileAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, experimental, glyph);
// Items cannot be partially written if we're checking for their absence,
// or if we're verifying that the list will show up (without specifying an actual item)
if (!checkForAbsence && expectedItemOrNull != null)
{
await VerifyAtPosition_ItemPartiallyWrittenAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, experimental, glyph);
await VerifyAtEndOfFile_ItemPartiallyWrittenAsync(code, position, usePreviousCharAsTrigger, expectedItemOrNull, expectedDescriptionOrNull, sourceCodeKind, checkForAbsence, experimental, glyph);
}
}