Search in sources :

Example 16 with AddedParseTree

use of org.eclipse.titan.common.parsers.AddedParseTree in project titan.EclipsePlug-ins by eclipse.

the class TestportParameterTransfer method nativeToJava.

@Override
protected TestportParameter[] nativeToJava(final TransferData transferData) {
    byte[] bytes = (byte[]) super.nativeToJava(transferData);
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
    try {
        int n = in.readInt();
        TestportParameter[] items = new TestportParameter[n];
        String componentName;
        String testportName;
        String parameterName;
        String hiddenBefore1;
        String hiddenBefore2;
        String value;
        for (int i = 0; i < n; i++) {
            TestportParameter item = new TestportParameterSectionHandler.TestportParameter();
            final ParseTree root = new ParserRuleContext();
            item.setRoot(root);
            // component name part
            hiddenBefore1 = in.readUTF();
            componentName = in.readUTF();
            hiddenBefore2 = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBefore1));
            item.setComponentName(new AddedParseTree(componentName));
            ConfigTreeNodeUtilities.addChild(root, item.getComponentName());
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBefore2));
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree("".equals(componentName) ? "" : "."));
            // testport name part
            hiddenBefore1 = in.readUTF();
            testportName = in.readUTF();
            hiddenBefore2 = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBefore2));
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree("".equals(testportName) ? "" : "."));
            // parameter name part
            hiddenBefore1 = in.readUTF();
            parameterName = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBefore1));
            item.setParameterName(new AddedParseTree(parameterName));
            ConfigTreeNodeUtilities.addChild(root, item.getParameterName());
            // the := sign and the hidden stuff before it
            hiddenBefore1 = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBefore1));
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(":="));
            // the value part
            value = in.readUTF();
            item.setValue(new AddedParseTree(value));
            ConfigTreeNodeUtilities.addChild(root, item.getValue());
            items[i] = item;
        }
        return items;
    } catch (IOException e) {
        ErrorReporter.logExceptionStackTrace(e);
        return new TestportParameter[] {};
    }
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) TestportParameter(org.eclipse.titan.common.parsers.cfg.indices.TestportParameterSectionHandler.TestportParameter) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 17 with AddedParseTree

use of org.eclipse.titan.common.parsers.AddedParseTree in project titan.EclipsePlug-ins by eclipse.

the class TestportParametersSectionPage method createNewTestportParameterSection.

private void createNewTestportParameterSection() {
    if (testportParametersHandler == null) {
        return;
    }
    ParserRuleContext sectionRoot = new ParserRuleContext();
    testportParametersHandler.setLastSectionRoot(sectionRoot);
    ParseTree header = new AddedParseTree("\n[TESTPORT_PARAMETERS]");
    ConfigTreeNodeUtilities.addChild(sectionRoot, header);
    ParserRuleContext root = editor.getParseTreeRoot();
    if (root != null) {
        root.addChild(sectionRoot);
    }
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 18 with AddedParseTree

use of org.eclipse.titan.common.parsers.AddedParseTree 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);
    }
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 19 with AddedParseTree

use of org.eclipse.titan.common.parsers.AddedParseTree 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[] {};
    }
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) Definition(org.eclipse.titan.common.parsers.cfg.indices.DefineSectionHandler.Definition) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ByteArrayInputStream(java.io.ByteArrayInputStream) Definition(org.eclipse.titan.common.parsers.cfg.indices.DefineSectionHandler.Definition) DefineSectionHandler(org.eclipse.titan.common.parsers.cfg.indices.DefineSectionHandler) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 20 with AddedParseTree

use of org.eclipse.titan.common.parsers.AddedParseTree 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);
    }
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)45 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)41 ParseTree (org.antlr.v4.runtime.tree.ParseTree)32 ByteArrayInputStream (java.io.ByteArrayInputStream)6 DataInputStream (java.io.DataInputStream)6 IOException (java.io.IOException)6 TerminalNodeImpl (org.antlr.v4.runtime.tree.TerminalNodeImpl)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)3 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)3 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)3 Section (org.eclipse.ui.forms.widgets.Section)3 Token (org.antlr.v4.runtime.Token)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 Component (org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component)2 Definition (org.eclipse.titan.common.parsers.cfg.indices.DefineSectionHandler.Definition)2 ExecuteItem (org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem)2