Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
71f69140
提交
71f69140
authored
14 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
H2 Console: improved autocomplete feature (also simplified the source code for this feature).
上级
efc3bd71
master
noel-pr1
plus33-master
pr/267
stumc-Issue#576
version-1.4.198
version-1.4.197
version-1.4.196
version-1.4.195
version-1.4.194
version-1.4.193
version-1.4.192
version-1.4.191
version-1.4.190
version-1.4.188
version-1.4.187
version-1.4.186
version-1.4.185
version-1.4.184
version-1.4.183
version-1.4.182
version-1.4.181
version-1.4.178
version-1.4.177
version-1.3
version-1.2
version-1.1
version-1.0
无相关合并请求
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
252 行增加
和
637 行删除
+252
-637
Bnf.java
h2/src/main/org/h2/bnf/Bnf.java
+3
-1
Rule.java
h2/src/main/org/h2/bnf/Rule.java
+4
-14
RuleElement.java
h2/src/main/org/h2/bnf/RuleElement.java
+11
-37
RuleFixed.java
h2/src/main/org/h2/bnf/RuleFixed.java
+76
-146
RuleList.java
h2/src/main/org/h2/bnf/RuleList.java
+13
-43
RuleOptional.java
h2/src/main/org/h2/bnf/RuleOptional.java
+4
-18
RuleRepeat.java
h2/src/main/org/h2/bnf/RuleRepeat.java
+6
-28
DbContextRule.java
h2/src/main/org/h2/server/web/DbContextRule.java
+135
-350
没有找到文件。
h2/src/main/org/h2/bnf/Bnf.java
浏览文件 @
71f69140
...
...
@@ -280,7 +280,9 @@ public class Bnf {
continue
;
}
sentence
.
start
();
head
.
getRule
().
addNextTokenList
(
sentence
);
if
(
head
.
getRule
().
autoComplete
(
sentence
))
{
break
;
}
}
return
sentence
.
getNext
();
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/bnf/Rule.java
浏览文件 @
71f69140
...
...
@@ -28,23 +28,13 @@ public interface Rule {
void
setLinks
(
HashMap
<
String
,
RuleHead
>
ruleMap
);
/**
* Add the next possible token
for a query.
*
Used for autocomplete support
.
* Add the next possible token
(s). If there was a match, the query in the
*
sentence is updated (the matched token is removed)
.
*
* @param sentence the sentence context
* @return true if a full match
*/
void
addNextTokenList
(
Sentence
sentence
);
/**
* Remove a token from a sentence. Used for autocomplete support.
* If there was a match, the query in the sentence is updated
* (the matched token is removed).
*
* @param sentence
* the sentence context
* @return false if not a match or a partial match, true if a full match
*/
boolean
matchRemove
(
Sentence
sentence
);
boolean
autoComplete
(
Sentence
sentence
);
/**
* Call the visit method in the given visitor.
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/bnf/RuleElement.java
浏览文件 @
71f69140
...
...
@@ -29,10 +29,6 @@ public class RuleElement implements Rule {
this
.
type
=
topic
.
startsWith
(
"function"
)
?
Sentence
.
FUNCTION
:
Sentence
.
KEYWORD
;
}
public
String
toString
()
{
return
name
;
}
public
void
accept
(
BnfVisitor
visitor
)
{
visitor
.
visitRuleElement
(
keyword
,
name
,
link
);
}
...
...
@@ -60,16 +56,14 @@ public class RuleElement implements Rule {
throw
new
AssertionError
(
"Unknown "
+
name
+
"/"
+
test
);
}
public
boolean
matchRemov
e
(
Sentence
sentence
)
{
public
boolean
autoComplet
e
(
Sentence
sentence
)
{
if
(
sentence
.
shouldStop
())
{
return
false
;
}
String
query
=
sentence
.
getQuery
();
if
(
query
.
length
()
==
0
)
{
return
false
;
}
if
(
keyword
)
{
String
up
=
sentence
.
getQueryUpper
();
String
query
=
sentence
.
getQuery
();
String
q
=
query
.
trim
();
String
up
=
sentence
.
getQueryUpper
().
trim
();
if
(
up
.
startsWith
(
name
))
{
query
=
query
.
substring
(
name
.
length
());
while
(!
"_"
.
equals
(
name
)
&&
query
.
length
()
>
0
&&
Character
.
isWhitespace
(
query
.
charAt
(
0
)))
{
...
...
@@ -77,38 +71,18 @@ public class RuleElement implements Rule {
}
sentence
.
setQuery
(
query
);
return
true
;
}
return
false
;
}
if
(!
link
.
matchRemove
(
sentence
))
{
return
false
;
}
if
(
name
!=
null
&&
!
name
.
startsWith
(
"@"
)
&&
(
link
.
name
()
==
null
||
!
link
.
name
().
startsWith
(
"@"
)))
{
query
=
sentence
.
getQuery
();
while
(
query
.
length
()
>
0
&&
Character
.
isWhitespace
(
query
.
charAt
(
0
)))
{
query
=
query
.
substring
(
1
);
}
sentence
.
setQuery
(
query
);
}
return
true
;
}
public
void
addNextTokenList
(
Sentence
sentence
)
{
if
(
sentence
.
shouldStop
())
{
return
;
}
if
(
keyword
)
{
String
query
=
sentence
.
getQuery
();
String
q
=
query
.
trim
();
String
up
=
sentence
.
getQueryUpper
().
trim
();
if
(
q
.
length
()
==
0
||
name
.
startsWith
(
up
))
{
}
else
if
(
q
.
length
()
==
0
||
name
.
startsWith
(
up
))
{
if
(
q
.
length
()
<
name
.
length
())
{
sentence
.
add
(
name
,
name
.
substring
(
q
.
length
()),
type
);
}
}
return
;
return
false
;
}
link
.
addNextTokenList
(
sentence
);
return
link
.
autoComplete
(
sentence
);
}
public
String
toString
()
{
return
name
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/bnf/RuleFixed.java
浏览文件 @
71f69140
差异被折叠。
点击展开。
h2/src/main/org/h2/bnf/RuleList.java
浏览文件 @
71f69140
...
...
@@ -9,7 +9,6 @@ package org.h2.bnf;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
org.h2.util.New
;
import
org.h2.util.StatementBuilder
;
/**
* Represents a sequence of BNF rules, or a list of alternative rules.
...
...
@@ -35,24 +34,6 @@ public class RuleList implements Rule {
this
.
or
=
or
;
}
public
String
toString
()
{
StatementBuilder
buff
=
new
StatementBuilder
();
if
(
or
)
{
buff
.
append
(
'{'
);
for
(
Rule
r
:
list
)
{
buff
.
appendExceptFirst
(
"|"
);
buff
.
append
(
r
.
toString
());
}
buff
.
append
(
'}'
);
}
else
{
for
(
Rule
r
:
list
)
{
buff
.
appendExceptFirst
(
" "
);
buff
.
append
(
r
.
toString
());
}
}
return
buff
.
toString
();
}
public
void
accept
(
BnfVisitor
visitor
)
{
visitor
.
visitRuleList
(
or
,
list
);
}
...
...
@@ -70,43 +51,32 @@ public class RuleList implements Rule {
}
}
public
boolean
matchRemove
(
Sentence
sentence
)
{
String
query
=
sentence
.
getQuery
();
if
(
query
.
length
()
==
0
)
{
public
boolean
autoComplete
(
Sentence
sentence
)
{
if
(
sentence
.
shouldStop
())
{
return
false
;
}
String
old
=
sentence
.
getQuery
();
if
(
or
)
{
for
(
Rule
r
:
list
)
{
if
(
r
.
matchRemove
(
sentence
))
{
sentence
.
setQuery
(
old
);
if
(
r
.
autoComplete
(
sentence
))
{
return
true
;
}
}
return
false
;
}
for
(
Rule
r
:
list
)
{
if
(!
r
.
matchRemove
(
sentence
))
{
return
false
;
}
}
return
true
;
}
public
void
addNextTokenList
(
Sentence
sentence
)
{
String
old
=
sentence
.
getQuery
();
if
(
or
)
{
for
(
Rule
r
:
list
)
{
sentence
.
setQuery
(
old
);
r
.
addNextTokenList
(
sentence
);
}
}
else
{
for
(
Rule
r
:
list
)
{
r
.
addNextTokenList
(
sentence
);
if
(!
r
.
matchRemove
(
sentence
))
{
break
;
if
(!
r
.
autoComplete
(
sentence
))
{
sentence
.
setQuery
(
old
);
return
false
;
}
}
return
true
;
}
sentence
.
setQuery
(
old
);
}
public
String
toString
()
{
return
or
?
"or: "
:
""
+
list
.
toString
();
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/bnf/RuleOptional.java
浏览文件 @
71f69140
...
...
@@ -19,10 +19,6 @@ public class RuleOptional implements Rule {
this
.
rule
=
rule
;
}
public
String
toString
()
{
return
"["
+
rule
.
toString
()
+
"]"
;
}
public
void
accept
(
BnfVisitor
visitor
)
{
visitor
.
visitRuleOptional
(
rule
);
}
...
...
@@ -37,26 +33,16 @@ public class RuleOptional implements Rule {
mapSet
=
true
;
}
}
public
boolean
matchRemove
(
Sentence
sentence
)
{
public
boolean
autoComplete
(
Sentence
sentence
)
{
if
(
sentence
.
shouldStop
())
{
return
false
;
}
String
query
=
sentence
.
getQuery
();
if
(
query
.
length
()
==
0
)
{
return
true
;
}
if
(!
rule
.
matchRemove
(
sentence
))
{
return
true
;
}
rule
.
autoComplete
(
sentence
);
return
true
;
}
public
void
addNextTokenList
(
Sentence
sentence
)
{
if
(
sentence
.
shouldStop
())
{
return
;
}
rule
.
addNextTokenList
(
sentence
);
public
String
toString
()
{
return
rule
.
toString
();
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/bnf/RuleRepeat.java
浏览文件 @
71f69140
...
...
@@ -21,10 +21,6 @@ public class RuleRepeat implements Rule {
this
.
comma
=
comma
;
}
public
String
toString
()
{
return
"..."
;
}
public
void
accept
(
BnfVisitor
visitor
)
{
visitor
.
visitRuleRepeat
(
comma
,
rule
);
}
...
...
@@ -37,36 +33,18 @@ public class RuleRepeat implements Rule {
// rule.setLinks(ruleMap);
}
public
boolean
matchRemov
e
(
Sentence
sentence
)
{
public
boolean
autoComplet
e
(
Sentence
sentence
)
{
if
(
sentence
.
shouldStop
())
{
return
false
;
}
String
query
=
sentence
.
getQuery
();
if
(
query
.
length
()
==
0
)
{
return
false
;
}
while
(
true
)
{
if
(!
rule
.
matchRemove
(
sentence
))
{
return
true
;
}
if
(
sentence
.
getQuery
().
length
()
==
0
)
{
return
true
;
}
while
(
rule
.
autoComplete
(
sentence
))
{
// nothing to do
}
return
true
;
}
public
void
addNextTokenList
(
Sentence
sentence
)
{
if
(
sentence
.
shouldStop
())
{
return
;
}
String
old
=
sentence
.
getQuery
();
while
(
true
)
{
rule
.
addNextTokenList
(
sentence
);
if
(!
rule
.
matchRemove
(
sentence
)
||
old
.
equals
(
sentence
.
getQuery
()))
{
break
;
}
}
sentence
.
setQuery
(
old
);
public
String
toString
()
{
return
rule
.
toString
();
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/web/DbContextRule.java
浏览文件 @
71f69140
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论