FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/java/src/processing/mode/java/pdex/Searcher.java at master · dzaima/processing · GitHub
dzaima
processing
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
java
/
src
/
processing
/
mode
/
java
/
pdex
/
Searcher.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (47 loc) · 1.7 KB
Breadcrumbs
processing
/
java
/
src
/
processing
/
mode
/
java
/
pdex
/
Searcher.java
Copy path
File metadata and controls
58 lines (47 loc) · 1.7 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package
processing
.
mode
.
java
.
pdex
;
import
org
.
eclipse
.
jdt
.
core
.
dom
.*;
import
processing
.
app
.
ui
.*;
import
processing
.
mode
.
java
.
JavaEditor
;
import
java
.
awt
.*;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
function
.
Consumer
;
public
class
Searcher
{
private
final
JavaEditor
editor
;
private
final
PreprocessingService
pps
;
Searcher
(
JavaEditor
editor
,
PreprocessingService
pps
) {
this
.
editor
=
editor
;
this
.
pps
=
pps
;
}
public
void
search
(
Search
s
,
Consumer
<
ArrayList
<
SearchResult
>>
callback
) {
pps
.
whenDoneBlocking
(
ps
->
handleSearch
(
ps
,
s
,
callback
));
}
private
void
handleSearch
(
PreprocessedSketch
ps
,
Search
search
,
Consumer
<
ArrayList
<
SearchResult
>>
callback
) {
ArrayList
<
SearchResult
>
occurrences
=
new
ArrayList
<>();
ps
.
compilationUnit
.
getRoot
().
accept
(
new
ASTVisitor
() {
@
Override
public
boolean
visit
(
TypeDeclaration
name
) {
if
(
search
.
match
(
name
.
getName
().
getIdentifier
()))
occurrences
.
add
(
new
SNSearchResult
(
search
,
name
,
ps
));
return
super
.
visit
(
name
);
}
});
callback
.
accept
(
occurrences
);
}
class
SNSearchResult
extends
SearchResult
{
private
final
TypeDeclaration
item
;
private
final
PreprocessedSketch
ps
;
SNSearchResult
(
Search
s
,
TypeDeclaration
item
,
PreprocessedSketch
ps
) {
super
(
s
);
this
.
item
=
item
;
this
.
ps
=
ps
;
}
public
void
select
() {
PreprocessedSketch
.
SketchInterval
si
=
ps
.
mapJavaToSketch
(
item
.
getName
());
if
(!
ps
.
inRange
(
si
))
return
;
EventQueue
.
invokeLater
(() ->
editor
.
highlight
(
si
.
tabIndex
,
si
.
startTabOffset
,
si
.
stopTabOffset
));
close
();
}
@
Override
public
String
toString
() {
return
item
.
getName
().
getIdentifier
();
}
}
}
Back
|
FazBrowse Home
|
New Git URL