Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Schwarz
CUP Eclipse Plugin
Commits
0c1acc13
Commit
0c1acc13
authored
Feb 27, 2016
by
Michael Schwarz
🤔
Browse files
group productions that start with the same nonterminal
bugfix: check if there are precs before collapsing
parent
79495e5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
CupPlugin/src/de/tum/in/www2/cupplugin/Pair.java
View file @
0c1acc13
...
...
@@ -13,6 +13,14 @@ public class Pair<A, B> {
return
second
;
}
public
void
setFirst
(
A
first
){
this
.
first
=
first
;
}
public
void
setSecond
(
B
second
){
this
.
second
=
second
;
}
public
Pair
(
A
first
,
B
second
)
{
this
.
first
=
first
;
this
.
second
=
second
;
...
...
CupPlugin/src/de/tum/in/www2/cupplugin/editors/CupContentOutlinePage.java
View file @
0c1acc13
...
...
@@ -50,6 +50,7 @@ import de.in.tum.www2.cup.ast.Terminal;
import
de.in.tum.www2.cup.ast.TerminalDeclaration
;
import
de.in.tum.www2.cup.ast.TypedNonTerminalDeclaration
;
import
de.in.tum.www2.cup.ast.TypedTerminalDeclaration
;
import
de.tum.in.www2.cupplugin.Pair
;
import
de.tum.in.www2.cupplugin.controller.Controller
;
import
de.tum.in.www2.cupplugin.controller.Controller.JobsToDo
;
import
de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges
;
...
...
@@ -170,9 +171,15 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
// Even though we expanded before, we want to collapse decls and precs
// and imports
viewer
.
setExpandedState
(
visitor
.
getDecls
(),
false
);
viewer
.
setExpandedState
(
visitor
.
getPrecs
(),
false
);
viewer
.
setExpandedState
(
visitor
.
getImports
(),
false
);
viewer
.
setExpandedState
(
visitor
.
getDecls
(),
false
);
if
(
visitor
.
getPrecs
()
!=
null
){
viewer
.
setExpandedState
(
visitor
.
getPrecs
(),
false
);
}
if
(
visitor
.
getImports
()
!=
null
){
viewer
.
setExpandedState
(
visitor
.
getImports
(),
false
);
}
}
finally
{
viewer
.
getTree
().
setRedraw
(
true
);
...
...
@@ -198,6 +205,7 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
private
List
<
OutlineEntry
>
children
;
private
boolean
_isFolder
;
public
boolean
isFolder
()
{
return
_isFolder
;
}
...
...
@@ -258,7 +266,36 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
private
OutlineEntry
precs
;
private
OutlineEntry
productions
;
private
OutlineEntry
imports
;
// Keeps track of the position of the last production for an NT
private
List
<
Pair
<
String
,
Integer
>>
productionPos
=
new
ArrayList
<>();
// Returns the index at which to insert the production
private
int
getPlaceToAddProductionFor
(
String
nonterminal
){
boolean
found
=
false
;
int
pos
=
productionCount
;
for
(
int
i
=
0
;
i
<
productionPos
.
size
();
i
++){
if
(
found
){
// Increment end position of all following
productionPos
.
get
(
i
).
setSecond
(
productionPos
.
get
(
i
).
getSecond
()+
1
);
}
else
if
(
nonterminal
.
equals
(
productionPos
.
get
(
i
).
getFirst
())){
found
=
true
;
//insert right after current last
pos
=
productionPos
.
get
(
i
).
getSecond
()+
1
;
//increase length
productionPos
.
get
(
i
).
setSecond
(
productionPos
.
get
(
i
).
getSecond
()+
1
);
}
}
if
(
pos
==
productionCount
){
// Not in yet, insert at the very end
productionPos
.
add
(
new
Pair
<>(
nonterminal
,
productionCount
));
}
return
pos
;
}
public
OutlineEntry
getTree
()
{
return
root
;
}
...
...
@@ -321,7 +358,8 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
this
.
productions
=
OutlineEntry
.
folderFromNode
(
"Productions"
);
root
.
children
.
add
(
productions
);
}
productions
.
children
.
add
(
entry
);
productions
.
children
.
add
(
getPlaceToAddProductionFor
(
entry
.
id
),
entry
);
productionCount
++;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment