Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Nhibernate-Core
提交
5a38bd81
N
Nhibernate-Core
项目概览
jobily
/
Nhibernate-Core
9 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
Nhibernate-Core
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
5a38bd81
编写于
7月 26, 2023
作者:
R
Roman Artiukhin
提交者:
GitHub
7月 26, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move HqlToken.PossibleId to HqlParser.IsPossibleId method and remove castings (#3377)
上级
7a1bf08f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
44 deletion
+36
-44
src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs
src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs
+32
-39
src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs
src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs
+4
-5
未找到文件。
src/NHibernate/Hql/Ast/ANTLR/HqlParser.cs
浏览文件 @
5a38bd81
...
...
@@ -147,8 +147,8 @@ public void WeakKeywords()
// Case 2: The current token is after FROM and before '.'.
if
(
t
!=
IDENT
&&
input
.
LA
(-
1
)
==
FROM
&&
((
input
.
LA
(
2
)
==
DOT
)
||
(
input
.
LA
(
2
)
==
IDENT
)
||
(
input
.
LA
(
2
)
==
-
1
)))
{
HqlToken
hqlToken
=
input
.
LT
(
1
)
as
HqlToken
;
if
(
hqlToken
!=
null
&&
hqlToken
.
PossibleId
)
var
hqlToken
=
input
.
LT
(
1
)
;
if
(
IsPossibleId
(
hqlToken
)
)
{
hqlToken
.
Type
=
IDENT
;
if
(
log
.
IsDebugEnabled
())
...
...
@@ -192,8 +192,8 @@ public void WeakKeywords2()
// Case 2: The current token is after FROM and before '.'.
if
(
t
!=
IDENT
&&
input
.
LA
(-
1
)
==
FROM
&&
input
.
LA
(
2
)
==
DOT
)
{
HqlToken
hqlToken
=
(
HqlToken
)
input
.
LT
(
1
);
if
(
hqlToken
.
PossibleId
)
var
hqlToken
=
input
.
LT
(
1
);
if
(
IsPossibleId
(
hqlToken
)
)
{
hqlToken
.
Type
=
IDENT
;
if
(
log
.
IsDebugEnabled
())
...
...
@@ -290,16 +290,8 @@ public IASTNode NegateNode(IASTNode node)
}
}
public
IASTNode
ProcessEqualityExpression
(
object
o
)
public
IASTNode
ProcessEqualityExpression
(
IASTNode
x
)
{
IASTNode
x
=
o
as
IASTNode
;
if
(
x
==
null
)
{
log
.
Warn
(
"processEqualityExpression() : No expression to process!"
);
return
null
;
}
int
type
=
x
.
Type
;
if
(
type
==
EQ
||
type
==
NE
)
{
...
...
@@ -336,11 +328,11 @@ public void HandleDotIdent()
if
(
input
.
LA
(
1
)
==
DOT
&&
input
.
LA
(
2
)
!=
IDENT
)
{
// See if the second lookahed token can be an identifier.
HqlToken
t
=
input
.
LT
(
2
)
as
HqlToken
;
if
(
t
!=
null
&&
t
.
PossibleId
)
var
t
=
input
.
LT
(
2
)
;
if
(
IsPossibleId
(
t
)
)
{
// Set it!
input
.
LT
(
2
)
.
Type
=
IDENT
;
t
.
Type
=
IDENT
;
if
(
log
.
IsDebugEnabled
())
{
log
.
Debug
(
"handleDotIdent() : new LT(2) token - {0}"
,
input
.
LT
(
1
));
...
...
@@ -401,37 +393,38 @@ public IASTNode ProcessMemberOf(IToken n, IASTNode p, IASTNode root)
public
IASTNode
HandleIdentifierError
(
IToken
token
,
RecognitionException
ex
)
{
if
(
token
is
HqlToken
)
// ... and the token could be an identifier and the error is
// a mismatched token error ...
if
(
IsPossibleId
(
token
)
&&
(
ex
is
MismatchedTokenException
mte
)
// ... and the expected token type was an identifier, then:
&&
mte
.
Expecting
==
IDENT
)
{
HqlToken
hqlToken
=
(
HqlToken
)
token
;
// Use the token as an identifier.
_parseErrorHandler
.
ReportWarning
(
"Keyword '"
+
token
.
Text
+
"' is being interpreted as an identifier due to: "
+
mte
.
Message
);
// ... and the token could be an identifer and the error is
// a mismatched token error ...
if
(
hqlToken
.
PossibleId
&&
(
ex
is
MismatchedTokenException
))
{
MismatchedTokenException
mte
=
(
MismatchedTokenException
)
ex
;
// ... and the expected token type was an identifier, then:
if
(
mte
.
Expecting
==
IDENT
)
{
// Use the token as an identifier.
_parseErrorHandler
.
ReportWarning
(
"Keyword '"
+
token
.
Text
+
"' is being interpreted as an identifier due to: "
+
mte
.
Message
);
// Add the token to the AST.
// Add the token to the AST.
token
.
Type
=
WEIRD_IDENT
;
token
.
Type
=
WEIRD_IDENT
;
input
.
Consume
();
return
(
IASTNode
)
adaptor
.
Create
(
token
);
}
}
input
.
Consume
();
return
(
IASTNode
)
adaptor
.
Create
(
token
);
}
// Otherwise, handle the error normally.
ReflectHelper
.
PreserveStackTrace
(
ex
);
throw
ex
;
}
/// <summary>
/// Indicates if the token could be an identifier.
/// </summary>
/// <param name="token"></param>
public
static
bool
IsPossibleId
(
IToken
token
)
{
var
type
=
token
.
Type
;
return
type
>=
0
&&
type
<
possibleIds
.
Length
&&
possibleIds
[
type
];
}
}
}
src/NHibernate/Hql/Ast/ANTLR/HqlToken.cs
浏览文件 @
5a38bd81
...
...
@@ -39,10 +39,9 @@ public HqlToken(IToken other)
/// <summary>
/// Indicates if the token could be an identifier.
/// </summary>
public
bool
PossibleId
{
get
{
return
HqlParser
.
possibleIds
[
Type
];
}
}
// Since 5.5
[
Obsolete
(
"Use HqlParser.IsPossibleId method instead."
)]
public
bool
PossibleId
=>
HqlParser
.
IsPossibleId
(
this
);
/// <summary>
/// Returns the previous token type.
...
...
@@ -62,7 +61,7 @@ public override string ToString()
+
Text
+
"\",<"
+
Type
+
"> previously: <"
+
PreviousType
+
">,line="
+
Line
+
",col="
+
CharPositionInLine
+
",possibleID="
+
PossibleId
+
"]"
;
+
CharPositionInLine
+
",possibleID="
+
HqlParser
.
IsPossibleId
(
this
)
+
"]"
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录