Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
ef07f4ba
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ef07f4ba
编写于
2月 27, 2017
作者:
T
Tomas Matousek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add resolvers to misc workspace script projects
上级
7648c822
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
52 addition
and
28 deletion
+52
-28
src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs
...eferenceHighlighting/AbstractDocumentHighlightsService.cs
+1
-1
src/VisualStudio/CSharp/Impl/CSharpPackage.cs
src/VisualStudio/CSharp/Impl/CSharpPackage.cs
+1
-2
src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.HostProject.cs
.../ProjectSystem/MiscellaneousFilesWorkspace.HostProject.cs
+12
-10
src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs
...plementation/ProjectSystem/MiscellaneousFilesWorkspace.cs
+34
-10
src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb
...io/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb
+1
-2
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/LinkedFileReferenceFinder.cs
...mbols/FindReferences/Finders/LinkedFileReferenceFinder.cs
+1
-1
src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs
...lWorkspaceService/SemanticModelWorkspaceServiceFactory.cs
+2
-2
未找到文件。
src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs
浏览文件 @
ef07f4ba
...
...
@@ -186,7 +186,7 @@ private bool ShouldConsiderSymbol(ISymbol symbol)
// Document once https://github.com/dotnet/roslyn/issues/5260 is fixed.
if
(
document
==
null
)
{
Debug
.
Assert
(
solution
.
Workspace
.
Kind
==
"Interactive"
);
Debug
.
Assert
(
solution
.
Workspace
.
Kind
==
WorkspaceKind
.
Interactive
||
solution
.
Workspace
.
Kind
==
WorkspaceKind
.
MiscellaneousFiles
);
continue
;
}
...
...
src/VisualStudio/CSharp/Impl/CSharpPackage.cs
浏览文件 @
ef07f4ba
...
...
@@ -163,8 +163,7 @@ protected override void RegisterMiscellaneousFilesWorkspaceInformation(Miscellan
miscellaneousFilesWorkspace
.
RegisterLanguage
(
Guids
.
CSharpLanguageServiceId
,
LanguageNames
.
CSharp
,
".csx"
,
CSharpParseOptions
.
Default
);
".csx"
);
}
protected
override
string
RoslynLanguageName
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.HostProject.cs
浏览文件 @
ef07f4ba
...
...
@@ -20,22 +20,24 @@ private sealed class HostProject : IVisualStudioHostProject
internal
IVisualStudioHostDocument
Document
{
get
;
set
;
}
private
readonly
string
_assemblyName
;
private
readonly
ParseOptions
_parseOptions
;
private
readonly
ParseOptions
_parseOptionsOpt
;
private
readonly
CompilationOptions
_compilationOptionsOpt
;
private
readonly
IEnumerable
<
MetadataReference
>
_metadataReferences
;
private
readonly
VersionStamp
_version
;
private
readonly
Workspace
_workspace
;
public
HostProject
(
Workspace
workspace
,
SolutionId
solutionId
,
string
languageName
,
ParseOptions
parseOptions
,
IEnumerable
<
MetadataReference
>
metadataReferences
)
public
HostProject
(
Workspace
workspace
,
SolutionId
solutionId
,
string
languageName
,
ParseOptions
parseOptions
Opt
,
CompilationOptions
compilationOptionsOpt
,
IEnumerable
<
MetadataReference
>
metadataReferences
)
{
Debug
.
Assert
(
workspace
!=
null
);
Debug
.
Assert
(
languageName
!=
null
);
Debug
.
Assert
(
parseOptions
!=
null
);
Debug
.
Assert
(
metadataReferences
!=
null
);
_workspace
=
workspace
;
this
.
Id
=
ProjectId
.
CreateNewId
(
debugName
:
"Miscellaneous Files"
);
this
.
Language
=
languageName
;
_parseOptions
=
parseOptions
;
_parseOptionsOpt
=
parseOptionsOpt
;
_compilationOptionsOpt
=
compilationOptionsOpt
;
Id
=
ProjectId
.
CreateNewId
(
debugName
:
"Miscellaneous Files"
);
Language
=
languageName
;
// the assembly name must be unique for each collection of loose files. since the name doesn't matter
// a random GUID can be used.
...
...
@@ -48,14 +50,14 @@ public HostProject(Workspace workspace, SolutionId solutionId, string languageNa
public
ProjectInfo
CreateProjectInfoForCurrentState
()
{
var
info
=
ProjectInfo
.
Create
(
this
.
Id
,
Id
,
_version
,
name
:
ServicesVSResources
.
Miscellaneous_Files
,
assemblyName
:
_assemblyName
,
language
:
this
.
Language
,
language
:
Language
,
filePath
:
null
,
compilationOptions
:
null
,
// we don't have compilation options?
parseOptions
:
_parseOptions
,
compilationOptions
:
_compilationOptionsOpt
,
parseOptions
:
_parseOptions
Opt
,
documents
:
SpecializedCollections
.
EmptyEnumerable
<
DocumentInfo
>(),
projectReferences
:
SpecializedCollections
.
EmptyEnumerable
<
ProjectReference
>(),
metadataReferences
:
_metadataReferences
,
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs
浏览文件 @
ef07f4ba
...
...
@@ -16,6 +16,7 @@
using
Roslyn.Utilities
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Host
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
{
...
...
@@ -68,9 +69,9 @@ internal sealed partial class MiscellaneousFilesWorkspace : Workspace, IVsRunnin
saveEventsService
.
StartSendingSaveEvents
();
}
public
void
RegisterLanguage
(
Guid
languageGuid
,
string
languageName
,
string
scriptExtension
,
ParseOptions
parseOptions
)
public
void
RegisterLanguage
(
Guid
languageGuid
,
string
languageName
,
string
scriptExtension
)
{
_languageInformationByLanguageGuid
.
Add
(
languageGuid
,
new
LanguageInformation
(
languageName
,
scriptExtension
,
parseOptions
));
_languageInformationByLanguageGuid
.
Add
(
languageGuid
,
new
LanguageInformation
(
languageName
,
scriptExtension
));
}
internal
void
StartSolutionCrawler
()
...
...
@@ -328,21 +329,46 @@ private void AttachToDocument(uint docCookie, string moniker)
// This should always succeed since we only got here if we already confirmed the moniker is acceptable
var
languageInformation
=
TryGetLanguageInformation
(
moniker
);
Contract
.
ThrowIfNull
(
languageInformation
);
var
parseOptions
=
languageInformation
.
ParseOptions
;
if
(
Path
.
GetExtension
(
moniker
)
==
languageInformation
.
ScriptExtension
)
var
languageServices
=
Services
.
GetLanguageServices
(
languageInformation
.
LanguageName
);
var
compilationOptionsOpt
=
languageServices
.
GetService
<
ICompilationFactoryService
>()?.
GetDefaultCompilationOptions
();
var
parseOptionsOpt
=
languageServices
.
GetService
<
ISyntaxTreeFactoryService
>()?.
GetDefaultParseOptions
();
if
(
parseOptionsOpt
!=
null
&&
compilationOptionsOpt
!=
null
&&
PathUtilities
.
GetExtension
(
moniker
)
==
languageInformation
.
ScriptExtension
)
{
parseOptions
=
parseOptions
.
WithKind
(
SourceCodeKind
.
Script
);
parseOptionsOpt
=
parseOptionsOpt
.
WithKind
(
SourceCodeKind
.
Script
);
var
metadataService
=
Services
.
GetService
<
IMetadataService
>();
var
directory
=
PathUtilities
.
GetDirectoryName
(
moniker
);
// TODO (https://github.com/dotnet/roslyn/issues/5325, https://github.com/dotnet/roslyn/issues/13886):
// - Need to have a way to specify these somewhere in VS options.
// - Use RuntimeMetadataReferenceResolver like in InteractiveEvaluator.CreateMetadataReferenceResolver
// - Add default namespace imports
// - Add default script globals available in 'csi foo.csx' environment: CommandLineScriptGlobals
var
referenceSearchPaths
=
ImmutableArray
<
string
>.
Empty
;
var
sourceSearchPaths
=
ImmutableArray
<
string
>.
Empty
;
var
referenceResolver
=
new
WorkspaceMetadataFileReferenceResolver
(
metadataService
,
new
RelativePathResolver
(
referenceSearchPaths
,
directory
));
compilationOptionsOpt
=
compilationOptionsOpt
.
WithMetadataReferenceResolver
(
referenceResolver
).
WithSourceReferenceResolver
(
new
SourceFileResolver
(
sourceSearchPaths
,
directory
));
}
// First, create the project
var
hostProject
=
new
HostProject
(
this
,
CurrentSolution
.
Id
,
languageInformation
.
LanguageName
,
parseOptions
,
_metadataReferences
);
var
hostProject
=
new
HostProject
(
this
,
CurrentSolution
.
Id
,
languageInformation
.
LanguageName
,
parseOptions
Opt
,
compilationOptionsOpt
,
_metadataReferences
);
// Now try to find the document. We accept any text buffer, since we've already verified it's an appropriate file in ShouldIncludeFile.
var
document
=
_documentProvider
.
TryGetDocumentForFile
(
hostProject
,
moniker
,
parseOptions
.
Kind
,
parseOptions
Opt
?.
Kind
??
SourceCodeKind
.
Regular
,
getFolderNames
:
_
=>
SpecializedCollections
.
EmptyReadOnlyList
<
string
>(),
canUseTextBuffer
:
_
=>
true
);
...
...
@@ -453,16 +479,14 @@ void IVisualStudioHostProjectContainer.NotifyNonDocumentOpenedForProject(IVisual
private
class
LanguageInformation
{
public
LanguageInformation
(
string
languageName
,
string
scriptExtension
,
ParseOptions
parseOptions
)
public
LanguageInformation
(
string
languageName
,
string
scriptExtension
)
{
this
.
LanguageName
=
languageName
;
this
.
ScriptExtension
=
scriptExtension
;
this
.
ParseOptions
=
parseOptions
;
}
public
string
LanguageName
{
get
;
}
public
string
ScriptExtension
{
get
;
}
public
ParseOptions
ParseOptions
{
get
;
}
}
}
}
src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb
浏览文件 @
ef07f4ba
...
...
@@ -156,8 +156,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic
miscellaneousFilesWorkspace
.
RegisterLanguage
(
Guids
.
VisualBasicLanguageServiceId
,
LanguageNames
.
VisualBasic
,
".vbx"
,
VisualBasicParseOptions
.
Default
)
".vbx"
)
End
Sub
Protected
Overrides
ReadOnly
Property
RoslynLanguageName
As
String
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/LinkedFileReferenceFinder.cs
浏览文件 @
ef07f4ba
...
...
@@ -26,7 +26,7 @@ internal class LinkedFileReferenceFinder : IReferenceFinder
// Document once https://github.com/dotnet/roslyn/issues/5260 is fixed.
if
(
originalDocument
==
null
)
{
Debug
.
Assert
(
solution
.
Workspace
.
Kind
==
"Interactive"
);
Debug
.
Assert
(
solution
.
Workspace
.
Kind
==
WorkspaceKind
.
Interactive
||
solution
.
Workspace
.
Kind
==
WorkspaceKind
.
MiscellaneousFiles
);
continue
;
}
...
...
src/Workspaces/Core/Portable/SemanticModelWorkspaceService/SemanticModelWorkspaceServiceFactory.cs
浏览文件 @
ef07f4ba
...
...
@@ -473,8 +473,8 @@ private CompilationSet(VersionStamp version, ValueSource<Compilation> compilatio
// Document once https://github.com/dotnet/roslyn/issues/5260 is fixed.
if
(
documentId
==
null
)
{
Debug
.
Assert
(
newProject
.
Solution
.
Workspace
.
Kind
==
"Interactive"
);
continue
;
Debug
.
Assert
(
newProject
.
Solution
.
Workspace
.
Kind
==
WorkspaceKind
.
Interactive
||
newProject
.
Solution
.
Workspace
.
Kind
==
WorkspaceKind
.
MiscellaneousFiles
);
continue
;
}
map
=
map
.
SetItem
(
documentId
,
newTree
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录