Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
3f15910a
F
fsharp
项目概览
dotNET Platform
/
fsharp
大约 1 年 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3f15910a
编写于
6月 16, 2022
作者:
F
Florian Verdonck
提交者:
GitHub
6月 16, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add range of access to SyntaxTree. (#13304)
上级
49214c5f
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
98 addition
and
53 deletion
+98
-53
src/Compiler/Checking/CheckDeclarations.fs
src/Compiler/Checking/CheckDeclarations.fs
+3
-2
src/Compiler/Checking/CheckExpressions.fs
src/Compiler/Checking/CheckExpressions.fs
+3
-3
src/Compiler/SyntaxTree/SyntaxTree.fs
src/Compiler/SyntaxTree/SyntaxTree.fs
+12
-6
src/Compiler/SyntaxTree/SyntaxTree.fsi
src/Compiler/SyntaxTree/SyntaxTree.fsi
+5
-3
src/Compiler/pars.fsy
src/Compiler/pars.fsy
+6
-3
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
...s/FSharp.CompilerService.SurfaceArea.netstandard.expected
+14
-9
tests/service/Symbols.fs
tests/service/Symbols.fs
+31
-3
vsintegration/src/FSharp.Editor/Common/Extensions.fs
vsintegration/src/FSharp.Editor/Common/Extensions.fs
+24
-24
未找到文件。
src/Compiler/Checking/CheckDeclarations.fs
浏览文件 @
3f15910a
...
...
@@ -422,7 +422,8 @@ module TcRecdUnionAndEnumDeclarations =
error
(
Error
(
FSComp
.
SR
.
tcVolatileOnlyOnClassLetBindings
()
,
m
))
if
isIncrClass
&&
(
not
zeroInit
||
not
isMutable
)
then
errorR
(
Error
(
FSComp
.
SR
.
tcUninitializedValFieldsMustBeMutable
()
,
m
))
if
isStatic
&&
(
not
zeroInit
||
not
isMutable
||
vis
<>
Some
SynAccess
.
Private
)
then
errorR
(
Error
(
FSComp
.
SR
.
tcStaticValFieldsMustBeMutableAndPrivate
()
,
m
))
let
isPrivate
=
match
vis
with
|
Some
(
SynAccess
.
Private
_)
->
true
|
_
->
false
if
isStatic
&&
(
not
zeroInit
||
not
isMutable
||
not
isPrivate
)
then
errorR
(
Error
(
FSComp
.
SR
.
tcStaticValFieldsMustBeMutableAndPrivate
()
,
m
))
let
konst
=
if
zeroInit
then
Some
Const
.
Zero
else
None
let
rfspec
=
MakeRecdFieldSpec
cenv
env
parent
(
isStatic
,
konst
,
tyR
,
attrsForProperty
,
attrsForField
,
id
,
nameGenerated
,
isMutable
,
isVolatile
,
xmldoc
,
vis
,
m
)
match
parent
with
...
...
@@ -815,7 +816,7 @@ module IncrClassChecking =
let
prelimValReprInfo
=
TranslateSynValInfo
m
(
TcAttributes
cenv
env
)
valSynData
let
prelimTyschemeG
=
GeneralizedType
(
copyOfTyconTypars
,
cctorTy
)
let
topValInfo
=
InferGenericArityFromTyScheme
prelimTyschemeG
prelimValReprInfo
let
cctorValScheme
=
ValScheme
(
id
,
prelimTyschemeG
,
Some
topValInfo
,
Some
memberInfo
,
false
,
ValInline
.
Never
,
NormalVal
,
Some
SynAccess
.
Private
,
false
,
true
,
false
,
false
)
let
cctorValScheme
=
ValScheme
(
id
,
prelimTyschemeG
,
Some
topValInfo
,
Some
memberInfo
,
false
,
ValInline
.
Never
,
NormalVal
,
Some
(
SynAccess
.
Private
Range
.
Zero
)
,
false
,
true
,
false
,
false
)
let
cctorVal
=
MakeAndPublishVal
cenv
env
(
Parent
tcref
,
false
,
ModuleOrMemberBinding
,
ValNotInRecScope
,
cctorValScheme
,
[(*
no
attributes
*)],
XmlDoc
.
Empty
,
None
,
false
)
cctorArgs
,
cctorVal
,
cctorValScheme
)
...
...
src/Compiler/Checking/CheckExpressions.fs
浏览文件 @
3f15910a
...
...
@@ -1446,9 +1446,9 @@ let ComputeAccessAndCompPath env declKindOpt m vis overrideVis actualParent =
match overrideVis, vis with
| Some v, _ -> v
| _, None -> taccessPublic (* a module or member binding defaults to "public" *)
| _, Some
SynAccess.Public
-> taccessPublic
| _, Some
SynAccess.Private
-> taccessPrivate accessPath
| _, Some
SynAccess.Internal
-> taccessInternal
| _, Some
(SynAccess.Public _)
-> taccessPublic
| _, Some
(SynAccess.Private _)
-> taccessPrivate accessPath
| _, Some
(SynAccess.Internal _)
-> taccessInternal
let vis =
match actualParent with
...
...
src/Compiler/SyntaxTree/SyntaxTree.fs
浏览文件 @
3f15910a
...
...
@@ -198,17 +198,23 @@ type SynRationalConst =
[<
RequireQualifiedAccess
>]
type
SynAccess
=
|
Public
|
Public
of
range
:
range
|
Internal
|
Internal
of
range
:
range
|
Private
|
Private
of
range
:
range
override
this
.
ToString
()
=
match
this
with
|
Public
->
"Public"
|
Internal
->
"Internal"
|
Private
->
"Private"
|
Public
_
->
"Public"
|
Internal
_
->
"Internal"
|
Private
_
->
"Private"
member
this
.
Range
:
range
=
match
this
with
|
Public
m
|
Internal
m
|
Private
m
->
m
[<
RequireQualifiedAccess
>]
type
DebugPointAtTarget
=
...
...
src/Compiler/SyntaxTree/SyntaxTree.fsi
浏览文件 @
3f15910a
...
...
@@ -224,13 +224,15 @@ type SynRationalConst =
[<
RequireQualifiedAccess
>]
type
SynAccess
=
/// A construct marked or assumed 'public'
|
Public
|
Public
of
range
:
range
/// A construct marked or assumed 'internal'
|
Internal
|
Internal
of
range
:
range
/// A construct marked or assumed 'private'
|
Private
|
Private
of
range
:
range
member
Range
:
range
/// Represents whether a debug point should be present for the target
/// of a decision tree, that is whether the construct corresponds to a debug
...
...
src/Compiler/pars.fsy
浏览文件 @
3f15910a
...
...
@@ -2228,13 +2228,16 @@ opt_access:
access:
| PRIVATE
{ SynAccess.Private }
{ let m = rhs parseState 1
SynAccess.Private m }
| PUBLIC
{ SynAccess.Public }
{ let m = rhs parseState 1
SynAccess.Public m }
| INTERNAL
{ SynAccess.Internal }
{ let m = rhs parseState 1
SynAccess.Internal m }
/* only valid on 'NEW' */
opt_declVisibility:
...
...
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
浏览文件 @
3f15910a
...
...
@@ -5762,6 +5762,12 @@ FSharp.Compiler.Syntax.SeqExprOnly: Int32 Tag
FSharp.Compiler.Syntax.SeqExprOnly: Int32 get_Tag()
FSharp.Compiler.Syntax.SeqExprOnly: System.String ToString()
FSharp.Compiler.Syntax.SynAccess
FSharp.Compiler.Syntax.SynAccess+Internal: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynAccess+Internal: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynAccess+Private: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynAccess+Private: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynAccess+Public: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynAccess+Public: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynAccess+Tags: Int32 Internal
FSharp.Compiler.Syntax.SynAccess+Tags: Int32 Private
FSharp.Compiler.Syntax.SynAccess+Tags: Int32 Public
...
...
@@ -5774,16 +5780,15 @@ FSharp.Compiler.Syntax.SynAccess: Boolean IsPublic
FSharp.Compiler.Syntax.SynAccess: Boolean get_IsInternal()
FSharp.Compiler.Syntax.SynAccess: Boolean get_IsPrivate()
FSharp.Compiler.Syntax.SynAccess: Boolean get_IsPublic()
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
Internal
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
Private
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
Public
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
get_Internal()
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
get_Private()
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
get_Public()
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
NewInternal(FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
NewPrivate(FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
NewPublic(FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
+Internal
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
+Private
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess
+Public
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Syntax.SynAccess+Tags
FSharp.Compiler.Syntax.SynAccess: Int32 CompareTo(FSharp.Compiler.Syntax.SynAccess)
FSharp.Compiler.Syntax.SynAccess: Int32 CompareTo(System.Object)
FSharp.Compiler.Syntax.SynAccess: Int32 CompareTo(System.Object, System.Collections.IComparer)
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Text.Range Range
FSharp.Compiler.Syntax.SynAccess: FSharp.Compiler.Text.Range get_Range()
FSharp.Compiler.Syntax.SynAccess: Int32 GetHashCode()
FSharp.Compiler.Syntax.SynAccess: Int32 GetHashCode(System.Collections.IEqualityComparer)
FSharp.Compiler.Syntax.SynAccess: Int32 Tag
...
...
tests/service/Symbols.fs
浏览文件 @
3f15910a
...
...
@@ -70,12 +70,12 @@ extern int private c()
let
(
SynModuleOrNamespace
(
decls
=
decls
))
=
getSingleModuleLikeDecl
parseResults
.
ParseTree
[
None
Some
SynAccess
.
Public
Some
SynAccess
.
Private
]
Some
"Public"
Some
"Private"
]
|>
List
.
zip
decls
|>
List
.
iter
(
fun
(
actual
,
expected
)
->
match
actual
with
|
SynModuleDecl
.
Let
(_,
[
SynBinding
(
accessibility
=
access
)],
_)
->
access
|>
should
equal
expected
|
SynModuleDecl
.
Let
(_,
[
SynBinding
(
accessibility
=
access
)],
_)
->
Option
.
map
string
access
|>
should
equal
expected
|
decl
->
Assert
.
Fail
(
sprintf
"unexpected decl: %O"
decl
))
[
"a"
,
(
true
,
false
,
false
,
false
)
...
...
@@ -3252,6 +3252,34 @@ type Foo = Bar of string
|
_
->
Assert
.
Fail
"Could not get valid AST"
[<
Test
>]
let
``private keyword has range``
()
=
let
ast
=
"""
type Currency =
// Temporary fix until a new Thoth.Json.Net package is released
// See https://github.com/MangelMaxime/Thoth/pull/70
#if !FABLE_COMPILER
private
#endif
| Code of string
"""
|>
getParseResults
match
ast
with
|
ParsedInput
.
ImplFile
(
ParsedImplFileInput
(
modules
=
[
SynModuleOrNamespace
.
SynModuleOrNamespace
(
decls
=
[
SynModuleDecl
.
Types
([
SynTypeDefn
.
SynTypeDefn
(
typeRepr
=
SynTypeDefnRepr
.
Simple
(
simpleRepr
=
SynTypeDefnSimpleRepr
.
Union
(
accessibility
=
Some
(
SynAccess
.
Private
mPrivate
)
unionCases
=
[
SynUnionCase
.
SynUnionCase
_
])))
],
_)
])
]))
->
assertRange
(
7
,
4
)
(
7
,
11
)
mPrivate
|
_
->
Assert
.
Fail
"Could not get valid AST"
module
EnumCases
=
[<
Test
>]
let
``single SynEnumCase has bar range``
()
=
...
...
vsintegration/src/FSharp.Editor/Common/Extensions.fs
浏览文件 @
3f15910a
...
...
@@ -157,68 +157,68 @@ type NavigationItem with
|
FSharpGlyph
.
Type
|
FSharpGlyph
.
Exception
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
ClassPrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
ClassInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
ClassPrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
ClassInternal
|
_
->
FSharpRoslynGlyph
.
ClassPublic
|
FSharpGlyph
.
Constant
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
ConstantPrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
ConstantInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
ConstantPrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
ConstantInternal
|
_
->
FSharpRoslynGlyph
.
ConstantPublic
|
FSharpGlyph
.
Delegate
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
DelegatePrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
DelegateInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
DelegatePrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
DelegateInternal
|
_
->
FSharpRoslynGlyph
.
DelegatePublic
|
FSharpGlyph
.
Union
|
FSharpGlyph
.
Enum
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
EnumPrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
EnumInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
EnumPrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
EnumInternal
|
_
->
FSharpRoslynGlyph
.
EnumPublic
|
FSharpGlyph
.
EnumMember
|
FSharpGlyph
.
Variable
|
FSharpGlyph
.
Field
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
FieldPrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
FieldInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
FieldPrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
FieldInternal
|
_
->
FSharpRoslynGlyph
.
FieldPublic
|
FSharpGlyph
.
Event
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
EventPrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
EventInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
EventPrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
EventInternal
|
_
->
FSharpRoslynGlyph
.
EventPublic
|
FSharpGlyph
.
Interface
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
InterfacePrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
InterfaceInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
InterfacePrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
InterfaceInternal
|
_
->
FSharpRoslynGlyph
.
InterfacePublic
|
FSharpGlyph
.
Method
|
FSharpGlyph
.
OverridenMethod
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
MethodPrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
MethodInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
MethodPrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
MethodInternal
|
_
->
FSharpRoslynGlyph
.
MethodPublic
|
FSharpGlyph
.
Module
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
ModulePrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
ModuleInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
ModulePrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
ModuleInternal
|
_
->
FSharpRoslynGlyph
.
ModulePublic
|
FSharpGlyph
.
NameSpace
->
FSharpRoslynGlyph
.
Namespace
|
FSharpGlyph
.
Property
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
PropertyPrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
PropertyInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
PropertyPrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
PropertyInternal
|
_
->
FSharpRoslynGlyph
.
PropertyPublic
|
FSharpGlyph
.
Struct
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
StructurePrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
StructureInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
StructurePrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
StructureInternal
|
_
->
FSharpRoslynGlyph
.
StructurePublic
|
FSharpGlyph
.
ExtensionMethod
->
match
x
.
Access
with
|
Some
SynAccess
.
Private
->
FSharpRoslynGlyph
.
ExtensionMethodPrivate
|
Some
SynAccess
.
Internal
->
FSharpRoslynGlyph
.
ExtensionMethodInternal
|
Some
(
SynAccess
.
Private
_)
->
FSharpRoslynGlyph
.
ExtensionMethodPrivate
|
Some
(
SynAccess
.
Internal
_)
->
FSharpRoslynGlyph
.
ExtensionMethodInternal
|
_
->
FSharpRoslynGlyph
.
ExtensionMethodPublic
|
FSharpGlyph
.
Error
->
FSharpRoslynGlyph
.
Error
|
FSharpGlyph
.
TypeParameter
->
FSharpRoslynGlyph
.
TypeParameter
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录