Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
c1898912
F
fsharp
项目概览
dotNET Platform
/
fsharp
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
c1898912
编写于
7月 25, 2022
作者:
F
Florian Verdonck
提交者:
GitHub
7月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use SynLongIdent in SynOpenDeclTarget.ModuleOrNamespace (#13523)
上级
80b55032
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
37 addition
and
17 deletion
+37
-17
src/Compiler/Checking/CheckDeclarations.fs
src/Compiler/Checking/CheckDeclarations.fs
+5
-4
src/Compiler/Symbols/Symbols.fs
src/Compiler/Symbols/Symbols.fs
+1
-1
src/Compiler/SyntaxTree/SyntaxTree.fs
src/Compiler/SyntaxTree/SyntaxTree.fs
+1
-1
src/Compiler/SyntaxTree/SyntaxTree.fsi
src/Compiler/SyntaxTree/SyntaxTree.fsi
+1
-1
src/Compiler/pars.fsy
src/Compiler/pars.fsy
+3
-3
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
...s/FSharp.CompilerService.SurfaceArea.netstandard.expected
+5
-5
tests/service/InteractiveCheckerTests.fs
tests/service/InteractiveCheckerTests.fs
+1
-1
tests/service/SyntaxTreeTests/ModuleOrNamespaceTests.fs
tests/service/SyntaxTreeTests/ModuleOrNamespaceTests.fs
+20
-1
未找到文件。
src/Compiler/Checking/CheckDeclarations.fs
浏览文件 @
c1898912
...
...
@@ -366,7 +366,8 @@ let ImplicitlyOpenOwnNamespace tcSink g amap scopem enclosingNamespacePath (env:
match
ResolveLongIdentAsModuleOrNamespace
tcSink
ResultCollectionSettings
.
AllResults
amap
scopem
true
OpenQualified
env
.
eNameResEnv
ad
id
rest
true
with
|
Result
modrefs
->
let
modrefs
=
List
.
map
p23
modrefs
let
openTarget
=
SynOpenDeclTarget
.
ModuleOrNamespace
(
enclosingNamespacePathToOpen
,
scopem
)
let
lid
=
SynLongIdent
(
enclosingNamespacePathToOpen
,
[]
,
[]
)
let
openTarget
=
SynOpenDeclTarget
.
ModuleOrNamespace
(
lid
,
scopem
)
let
openDecl
=
OpenDeclaration
.
Create
(
openTarget
,
modrefs
,
[]
,
scopem
,
true
)
OpenModuleOrNamespaceRefs
tcSink
g
amap
scopem
false
env
modrefs
openDecl
|
Exception
_
->
env
...
...
@@ -656,7 +657,7 @@ let TcOpenModuleOrNamespaceDecl tcSink g amap scopem env (longId, m) =
let
modrefs
=
List
.
map
p23
modrefs
modrefs
|>
List
.
iter
(
fun
modref
->
CheckEntityAttributes
g
modref
m
|>
CommitOperationResult
)
let
openDecl
=
OpenDeclaration
.
Create
(
SynOpenDeclTarget
.
ModuleOrNamespace
(
longId
,
m
),
modrefs
,
[]
,
scopem
,
false
)
let
openDecl
=
OpenDeclaration
.
Create
(
SynOpenDeclTarget
.
ModuleOrNamespace
(
SynLongIdent
(
longId
,
[]
,
[]
)
,
m
),
modrefs
,
[]
,
scopem
,
false
)
let
env
=
OpenModuleOrNamespaceRefs
tcSink
g
amap
scopem
false
env
modrefs
openDecl
env
,
[
openDecl
]
...
...
@@ -681,7 +682,7 @@ let TcOpenDecl (cenv: cenv) mOpenDecl scopem env target =
let
g
=
cenv
.
g
match
target
with
|
SynOpenDeclTarget
.
ModuleOrNamespace
(
longId
,
m
)
->
TcOpenModuleOrNamespaceDecl
cenv
.
tcSink
g
cenv
.
amap
scopem
env
(
longId
,
m
)
TcOpenModuleOrNamespaceDecl
cenv
.
tcSink
g
cenv
.
amap
scopem
env
(
longId
.
LongIdent
,
m
)
|
SynOpenDeclTarget
.
Type
(
synType
,
m
)
->
TcOpenTypeDecl
cenv
mOpenDecl
scopem
env
(
synType
,
m
)
...
...
@@ -4981,7 +4982,7 @@ let ApplyAssemblyLevelAutoOpenAttributeToTcEnv g amap (ccu: CcuThunk) scopem env
match
modref
.
TryDeref
with
|
ValueNone
->
warn
()
|
ValueSome
_
->
let
openTarget
=
SynOpenDeclTarget
.
ModuleOrNamespace
(
[]
,
scopem
)
let
openTarget
=
SynOpenDeclTarget
.
ModuleOrNamespace
(
SynLongIdent
([],[],[])
,
scopem
)
let
openDecl
=
OpenDeclaration
.
Create
(
openTarget
,
[
modref
],
[]
,
scopem
,
false
)
let
envinner
=
OpenModuleOrNamespaceRefs
TcResultsSink
.
NoSink
g
amap
scopem
root
env
[
modref
]
openDecl
[
openDecl
],
envinner
...
...
src/Compiler/Symbols/Symbols.fs
浏览文件 @
c1898912
...
...
@@ -2794,7 +2794,7 @@ type FSharpOpenDeclaration(target: SynOpenDeclTarget, range: range option, modul
member
_.
LongId
=
match
target
with
|
SynOpenDeclTarget
.
ModuleOrNamespace
(
longId
,
_)
->
longId
|
SynOpenDeclTarget
.
ModuleOrNamespace
(
longId
,
_)
->
longId
.
LongIdent
|
SynOpenDeclTarget
.
Type
(
synType
,
_)
->
let
rec
get
ty
=
match
ty
with
...
...
src/Compiler/SyntaxTree/SyntaxTree.fs
浏览文件 @
c1898912
...
...
@@ -1471,7 +1471,7 @@ type SynModuleDecl =
[<
NoEquality
;
NoComparison
;
RequireQualifiedAccess
>]
type
SynOpenDeclTarget
=
|
ModuleOrNamespace
of
longId
:
LongIdent
*
range
:
range
|
ModuleOrNamespace
of
longId
:
Syn
LongIdent
*
range
:
range
|
Type
of
typeName
:
SynType
*
range
:
range
...
...
src/Compiler/SyntaxTree/SyntaxTree.fsi
浏览文件 @
c1898912
...
...
@@ -1654,7 +1654,7 @@ type SynModuleDecl =
type
SynOpenDeclTarget
=
/// A 'open' declaration
|
ModuleOrNamespace
of
longId
:
LongIdent
*
range
:
range
|
ModuleOrNamespace
of
longId
:
Syn
LongIdent
*
range
:
range
/// A 'open type' declaration
|
Type
of
typeName
:
SynType
*
range
:
range
...
...
src/Compiler/pars.fsy
浏览文件 @
c1898912
...
...
@@ -1432,7 +1432,7 @@ moduleDefn:
openDecl:
/* 'open' declarations */
| OPEN path
{ SynOpenDeclTarget.ModuleOrNamespace($2
.LongIdent
, (rhs parseState 2)) }
{ SynOpenDeclTarget.ModuleOrNamespace($2, (rhs parseState 2)) }
| OPEN typeKeyword appType
{ SynOpenDeclTarget.Type($3, (rhs parseState 3)) }
...
...
@@ -2013,7 +2013,7 @@ atomicPatternLongIdent:
| GLOBAL DOT pathOp
{ let globalIdent = ident(MangledGlobalName, rhs parseState 1)
let mDot = rhs parseState 2
None, prependIdentInLongIdentWithTrivia (SynIdent(globalIdent,
None
)) mDot $3 }
None, prependIdentInLongIdentWithTrivia (SynIdent(globalIdent,
(Some (IdentTrivia.OriginalNotation "global"))
)) mDot $3 }
| pathOp
{ (None, $1) }
...
...
@@ -5445,7 +5445,7 @@ ident:
/* A A.B.C path used to an identifier */
path:
| GLOBAL
{ SynLongIdent([ident(MangledGlobalName, rhs parseState 1)], [], [
None
]) }
{ SynLongIdent([ident(MangledGlobalName, rhs parseState 1)], [], [
Some (IdentTrivia.OriginalNotation "global")
]) }
| ident
{ SynLongIdent([$1], [], [None]) }
...
...
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
浏览文件 @
c1898912
...
...
@@ -2081,12 +2081,14 @@ FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: System.String get_FileName(
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: System.String[] DependencyFiles
FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: System.String[] get_DependencyFiles()
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean ApplyLineDirectives
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean CompilingFSharpCore
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean Equals(FSharp.Compiler.CodeAnalysis.FSharpParsingOptions)
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean Equals(System.Object)
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean Equals(System.Object, System.Collections.IEqualityComparer)
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean IsExe
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean IsInteractive
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_ApplyLineDirectives()
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_CompilingFSharpCore()
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_IsExe()
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_IsInteractive()
...
...
@@ -2108,8 +2110,6 @@ FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String ToString()
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String get_LangVersionText()
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] SourceFiles
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: System.String[] get_SourceFiles()
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean ApplyLineDirectives
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Boolean get_ApplyLineDirectives()
FSharp.Compiler.CodeAnalysis.FSharpParsingOptions: Void .ctor(System.String[], Boolean, Microsoft.FSharp.Collections.FSharpList`1[System.String], FSharp.Compiler.Diagnostics.FSharpDiagnosticOptions, System.String, Boolean, Microsoft.FSharp.Core.FSharpOption`1[System.Boolean], Boolean, Boolean)
FSharp.Compiler.CodeAnalysis.FSharpProjectContext
FSharp.Compiler.CodeAnalysis.FSharpProjectContext: FSharp.Compiler.CodeAnalysis.FSharpProjectOptions ProjectOptions
...
...
@@ -7882,10 +7882,10 @@ FSharp.Compiler.Syntax.SynModuleSigDecl: Int32 Tag
FSharp.Compiler.Syntax.SynModuleSigDecl: Int32 get_Tag()
FSharp.Compiler.Syntax.SynModuleSigDecl: System.String ToString()
FSharp.Compiler.Syntax.SynOpenDeclTarget
FSharp.Compiler.Syntax.SynOpenDeclTarget+ModuleOrNamespace: FSharp.Compiler.Syntax.SynLongIdent get_longId()
FSharp.Compiler.Syntax.SynOpenDeclTarget+ModuleOrNamespace: FSharp.Compiler.Syntax.SynLongIdent longId
FSharp.Compiler.Syntax.SynOpenDeclTarget+ModuleOrNamespace: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynOpenDeclTarget+ModuleOrNamespace: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynOpenDeclTarget+ModuleOrNamespace: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident] get_longId()
FSharp.Compiler.Syntax.SynOpenDeclTarget+ModuleOrNamespace: Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident] longId
FSharp.Compiler.Syntax.SynOpenDeclTarget+Tags: Int32 ModuleOrNamespace
FSharp.Compiler.Syntax.SynOpenDeclTarget+Tags: Int32 Type
FSharp.Compiler.Syntax.SynOpenDeclTarget+Type: FSharp.Compiler.Syntax.SynType get_typeName()
...
...
@@ -7896,7 +7896,7 @@ FSharp.Compiler.Syntax.SynOpenDeclTarget: Boolean IsModuleOrNamespace
FSharp.Compiler.Syntax.SynOpenDeclTarget: Boolean IsType
FSharp.Compiler.Syntax.SynOpenDeclTarget: Boolean get_IsModuleOrNamespace()
FSharp.Compiler.Syntax.SynOpenDeclTarget: Boolean get_IsType()
FSharp.Compiler.Syntax.SynOpenDeclTarget: FSharp.Compiler.Syntax.SynOpenDeclTarget NewModuleOrNamespace(
Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Syntax.Ident]
, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynOpenDeclTarget: FSharp.Compiler.Syntax.SynOpenDeclTarget NewModuleOrNamespace(
FSharp.Compiler.Syntax.SynLongIdent
, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynOpenDeclTarget: FSharp.Compiler.Syntax.SynOpenDeclTarget NewType(FSharp.Compiler.Syntax.SynType, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynOpenDeclTarget: FSharp.Compiler.Syntax.SynOpenDeclTarget+ModuleOrNamespace
FSharp.Compiler.Syntax.SynOpenDeclTarget: FSharp.Compiler.Syntax.SynOpenDeclTarget+Tags
...
...
tests/service/InteractiveCheckerTests.fs
浏览文件 @
c1898912
...
...
@@ -42,7 +42,7 @@ let internal identsAndRanges (input: ParsedInput) =
|
SynModuleDecl
.
Let
_
->
failwith
"Not implemented yet"
|
SynModuleDecl
.
Expr
_
->
failwith
"Not implemented yet"
|
SynModuleDecl
.
Exception
_
->
failwith
"Not implemented yet"
|
SynModuleDecl
.
Open
(
SynOpenDeclTarget
.
ModuleOrNamespace
(
lid
,
range
),
_)
->
[
identAndRange
(
longIdentToString
lid
)
range
]
|
SynModuleDecl
.
Open
(
SynOpenDeclTarget
.
ModuleOrNamespace
(
lid
,
range
),
_)
->
[
identAndRange
(
longIdentToString
lid
.
LongIdent
)
range
]
|
SynModuleDecl
.
Open
(
SynOpenDeclTarget
.
Type
_,
_)
->
failwith
"Not implemented yet"
|
SynModuleDecl
.
Attributes
_
->
failwith
"Not implemented yet"
|
SynModuleDecl
.
HashDirective
_
->
failwith
"Not implemented yet"
...
...
tests/service/SyntaxTreeTests/ModuleOrNamespaceTests.fs
浏览文件 @
c1898912
...
...
@@ -2,6 +2,7 @@ module FSharp.Compiler.Service.Tests.SyntaxTreeTests.ModuleOrNamespaceTests
open
FSharp
.
Compiler
.
Service
.
Tests
.
Common
open
FSharp
.
Compiler
.
Syntax
open
FSharp
.
Compiler
.
SyntaxTrivia
open
NUnit
.
Framework
[<
Test
>]
...
...
@@ -114,4 +115,22 @@ let a = 42
|
ParsedInput
.
ImplFile
(
ParsedImplFileInput
(
modules
=
[
SynModuleOrNamespace
.
SynModuleOrNamespace
(
kind
=
SynModuleOrNamespaceKind
.
DeclaredNamespace
;
trivia
=
{
ModuleKeyword
=
None
;
NamespaceKeyword
=
Some
mNamespace
})
]))
->
assertRange
(
2
,
0
)
(
2
,
9
)
mNamespace
|
_
->
Assert
.
Fail
"Could not get valid AST"
|
_
->
Assert
.
Fail
$
"Could not get valid AST, got {parseResults}"
[<
Test
>]
let
``global in open path should contain trivia``
()
=
let
parseResults
=
getParseResults
"""
namespace Ionide.VSCode.FSharp
open global.Node
"""
match
parseResults
with
|
ParsedInput
.
ImplFile
(
ParsedImplFileInput
(
modules
=
[
SynModuleOrNamespace
.
SynModuleOrNamespace
(
decls
=
[
SynModuleDecl
.
Open
(
target
=
SynOpenDeclTarget
.
ModuleOrNamespace
(
longId
=
SynLongIdent
(
trivia
=
[
Some
(
IdentTrivia
.
OriginalNotation
(
"global"
));
None
])))
])
]))
->
Assert
.
Pass
()
|
_
->
Assert
.
Fail
$
"Could not get valid AST, got {parseResults}"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录