blob: f8e8a4ee72fd692b2994111ba84213a2cceec762 [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2009 Thales Corporate Services S.A.S.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Thales Corporate Services S.A.S - initial API and implementation
*
* </copyright>
*/
package parsejet.test2;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
/**
* @author Matthieu Helleboid
*
*/
public class StructureVisitor extends ASTVisitor {
private final CodegenJetParser codegenJetParser;
StructureVisitor(CodegenJetParser codegenJetParser) {
this.codegenJetParser = codegenJetParser;
}
Section section;
int depth;
@Override
public boolean visit(ClassInstanceCreation node) {
Mark mark = this.codegenJetParser.getMark(node);
if (mark == null)
return true;
Section includeSection = new Section(node);
switch (mark) {
case EGFMarkInclude:
case EGFMarkIncludeSilent:
section.subSections.add(includeSection);
includeSection.parentSection = section;
break;
case EGFMarkIncludeAlternative:
includeSection.parentSection = section;
section.subSections.add(includeSection);
section = includeSection;
depth++;
break;
case EGFMarkStart:
break;
case EGFMarkEnd:
section = section.parentSection;
depth--;
break;
}
return true;
}
}