Commit 79495e5b authored by Michael Schwarz's avatar Michael Schwarz

separate decls and precs in outline

parent 55fa1d48
......@@ -159,18 +159,19 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
// We currently will only expand if there is a small number of items.
if (visitor.getProductionCount() < AUTO_EXPAND_L3_MAX_ITEMS
&& visitor.getDeclPrecCount() < AUTO_EXPAND_L3_MAX_ITEMS)
&& visitor.getDeclAndPrecsCount() < AUTO_EXPAND_L3_MAX_ITEMS)
{
viewer.expandToLevel(3);
} else if (visitor.getProductionCount() < AUTO_EXPAND_L2_MAX_ITEMS
&& visitor.getDeclPrecCount() < AUTO_EXPAND_L2_MAX_ITEMS)
&& visitor.getDeclAndPrecsCount() < AUTO_EXPAND_L2_MAX_ITEMS)
{
viewer.expandToLevel(2);
}
// Even though we expanded before, we want to collapse decls and precs
// and imports
viewer.setExpandedState(visitor.getDeclsAndPrec(), false);
viewer.setExpandedState(visitor.getDecls(), false);
viewer.setExpandedState(visitor.getPrecs(), false);
viewer.setExpandedState(visitor.getImports(), false);
}
finally {
......@@ -250,10 +251,11 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
static public class OutlineVisitor extends Visitor<OutlineEntry> {
private OutlineEntry root;
private int shortenListsTo;
private int declPrecCount;
private int declAndPrecsCount;
private int productionCount;
private OutlineEntry declsAndPrec;
private OutlineEntry decls;
private OutlineEntry precs;
private OutlineEntry productions;
private OutlineEntry imports;
......@@ -261,8 +263,12 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
return root;
}
public OutlineEntry getDeclsAndPrec(){
return declsAndPrec;
public OutlineEntry getDecls(){
return decls;
}
public OutlineEntry getPrecs(){
return precs;
}
public OutlineEntry getImports(){
......@@ -273,8 +279,8 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
return productionCount;
}
public int getDeclPrecCount() {
return declPrecCount;
public int getDeclAndPrecsCount() {
return declAndPrecsCount;
}
public OutlineVisitor() {
......@@ -282,14 +288,24 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
this.shortenListsTo = 3;
}
private void addDeclOrPrec(OutlineEntry entry) {
if (declsAndPrec == null) {
this.declsAndPrec = OutlineEntry
.folderFromNode("Declarations and Precedences");
root.children.add(declsAndPrec);
private void addDecl(OutlineEntry entry) {
if (decls == null) {
this.decls = OutlineEntry
.folderFromNode("Declarations");
root.children.add(decls);
}
decls.children.add(entry);
declAndPrecsCount++;
}
private void addPrec(OutlineEntry entry) {
if (precs == null) {
this.precs = OutlineEntry
.folderFromNode("Precedences");
root.children.add(precs);
}
declsAndPrec.children.add(entry);
declPrecCount++;
precs.children.add(entry);
declAndPrecsCount++;
}
private void addImport(OutlineEntry entry) {
......@@ -359,7 +375,7 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
builder.append(Utility.shortenedList(node.getTerminals(),
t -> t.getNameStringOrNull(), this.shortenListsTo));
}
addDeclOrPrec(OutlineEntry.fromNode(builder.toString(), node));
addPrec(OutlineEntry.fromNode(builder.toString(), node));
}
@Override
......@@ -419,27 +435,27 @@ public class CupContentOutlinePage extends ContentOutlinePage implements
@Override
public void postVisit(NonTerminalDeclaration node, OutlineEntry data) {
addDeclOrPrec(OutlineEntry.fromNode(
addDecl(OutlineEntry.fromNode(
shortenNonTerminals(node.getNonTerminals()), node));
}
@Override
public void postVisit(TerminalDeclaration node, OutlineEntry data) {
addDeclOrPrec(OutlineEntry.fromNode(
addDecl(OutlineEntry.fromNode(
shortenTerminals(node.getTerminals()), node));
}
@Override
public void postVisit(TypedNonTerminalDeclaration node,
OutlineEntry data) {
addDeclOrPrec(OutlineEntry.fromNode(
addDecl(OutlineEntry.fromNode(
shortenNonTerminals(node.getNonTerminals()), node.type,
node));
}
@Override
public void postVisit(TypedTerminalDeclaration node, OutlineEntry data) {
addDeclOrPrec(OutlineEntry.fromNode(
addDecl(OutlineEntry.fromNode(
shortenTerminals(node.getTerminals()), node.type, node));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment