use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class ExternalCommandsSubPage method createExternalCommandsSection.
// creates the maincontroller section if needed
private void createExternalCommandsSection() {
if (executeCommandSectionHandler == null || executeCommandSectionHandler.getLastSectionRoot() != null) {
return;
}
ParserRuleContext sectionRoot = new ParserRuleContext();
executeCommandSectionHandler.setLastSectionRoot(sectionRoot);
ParseTree header = new AddedParseTree("\n[EXTERNAL_COMMANDS]");
ConfigTreeNodeUtilities.addChild(sectionRoot, header);
ParserRuleContext root = editor.getParseTreeRoot();
if (root != null) {
root.addChild(sectionRoot);
}
}
use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class DefineItemTransfer method nativeToJava.
@Override
protected Definition[] nativeToJava(final TransferData transferData) {
byte[] bytes = (byte[]) super.nativeToJava(transferData);
DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
try {
int n = in.readInt();
Definition[] items = new Definition[n];
String name;
String value;
String hiddenBefore;
for (int i = 0; i < n; i++) {
items[i] = new DefineSectionHandler.Definition();
final ParseTree root = new ParserRuleContext();
items[i].setRoot(root);
hiddenBefore = in.readUTF();
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
name = in.readUTF();
final ParseTree nameNode = new AddedParseTree(name);
items[i].setDefinitionName(nameNode);
ConfigTreeNodeUtilities.addChild(root, nameNode);
hiddenBefore = in.readUTF();
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(":="));
hiddenBefore = in.readUTF();
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode(hiddenBefore));
value = in.readUTF();
final ParseTree valueNode = new AddedParseTree(value);
items[i].setDefinitionValue(valueNode);
ConfigTreeNodeUtilities.addChild(root, valueNode);
}
return items;
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
return new Definition[] {};
}
}
use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class DefineSectionDropTargetListener method drop.
@Override
public void drop(final DropTargetEvent event) {
if (DefineItemTransfer.getInstance().isSupportedType(event.currentDataType)) {
if (event.item != null && viewer.getInput() != null) {
DefineSectionHandler defineSectionHandler = (DefineSectionHandler) viewer.getInput();
Definition element = (Definition) event.item.getData();
Definition[] items = (Definition[]) event.data;
int baseindex = defineSectionHandler.getDefinitions().indexOf(element);
final ParseTree parent = defineSectionHandler.getLastSectionRoot();
ConfigTreeNodeUtilities.removeChild(parent, element.getRoot());
ConfigTreeNodeUtilities.addChild(parent, element.getRoot(), baseindex);
if (items.length > 0) {
for (int i = 0; i < items.length - 1; i++) {
defineSectionHandler.getDefinitions().add(++baseindex, items[i]);
}
defineSectionHandler.getDefinitions().add(++baseindex, items[items.length - 1]);
}
viewer.refresh(true);
editor.setDirty();
}
}
}
use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class DefineSubPage method createNewDefineSection.
private void createNewDefineSection() {
if (defineSectionHandler == null) {
return;
}
ParserRuleContext sectionRoot = new ParserRuleContext();
defineSectionHandler.setLastSectionRoot(sectionRoot);
ParseTree header = new AddedParseTree("\n[DEFINE]");
ConfigTreeNodeUtilities.addChild(sectionRoot, header);
ParserRuleContext root = editor.getParseTreeRoot();
if (root != null) {
root.addChild(sectionRoot);
}
}
use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.
the class DefineSubPage method createNewDefineItem.
private Definition createNewDefineItem() {
if (defineSectionHandler == null) {
return null;
}
final Definition item = new DefineSectionHandler.Definition();
final ParseTree root = new ParserRuleContext();
item.setRoot(root);
final ParseTree name = new AddedParseTree("definition_name");
final ParseTree value = new AddedParseTree("definition_value");
item.setDefinitionName(name);
item.setDefinitionValue(value);
ConfigTreeNodeUtilities.addChild(root, ConfigTreeNodeUtilities.createHiddenTokenNode("\n"));
ConfigTreeNodeUtilities.addChild(root, name);
ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(" := "));
ConfigTreeNodeUtilities.addChild(root, value);
return item;
}
Aggregations