当前位置: 首页>>代码示例>>C#>>正文


C# SourceCodeKind类代码示例

本文整理汇总了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);
 }
开发者ID:i3arnon,项目名称:TryRoslyn,代码行数:7,代码来源:CSharpLanguage.cs

示例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);
                }
            }
        }
开发者ID:TerabyteX,项目名称:roslyn,代码行数:28,代码来源:AbstractGoToAdjacentMemberTests.cs

示例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;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:DocumentInfo.cs

示例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
        }
开发者ID:jschementi,项目名称:iron,代码行数:8,代码来源:RubyCommandLine.cs

示例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;
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:8,代码来源:WorkspaceExtensions.cs

示例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;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:SolutionChecksumObjectInfo.cs

示例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;
                }
            }
开发者ID:natidea,项目名称:roslyn,代码行数:57,代码来源:DocumentProvider.StandardTextDocument.cs

示例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);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:10,代码来源:SymbolCompletionProviderTests_NoInteractive.cs

示例9: GetDocumentExtension

 public override string GetDocumentExtension(SourceCodeKind sourceCodeKind)
 {
     switch (sourceCodeKind)
     {
         case SourceCodeKind.Script:
             return ".csx";
         default:
             return ".cs";
     }
 }
开发者ID:riversky,项目名称:roslyn,代码行数:10,代码来源:CSharpProjectFileLoader.CSharpProjectFile.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);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:11,代码来源:DocumentInfo.cs

示例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.");	
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:11,代码来源:CompletionTestBase.cs

示例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);
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:11,代码来源:LoadDirectiveCompletionProviderTests.cs

示例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;
            }
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:13,代码来源:RefKeywordRecommenderTests.cs

示例14: GetDocumentExtension

 public override string GetDocumentExtension(SourceCodeKind sourceCodeKind)
 {
     string result;
     if (sourceCodeKind != SourceCodeKind.Script)
     {
         result = ".vb";
     }
     else
     {
         result = ".vbx";
     }
     return result;
 }
开发者ID:daking2014,项目名称:roslyn,代码行数:13,代码来源:VisualBasicProjectFileLoader.cs

示例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);
            }
        }
开发者ID:gustavoasoares,项目名称:roslyn,代码行数:13,代码来源:CrefCompletionProviderTests.cs


注:本文中的SourceCodeKind类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。