Search in sources :

Example 86 with ParseTree

use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.

the class LoggingBitsSubPage method pluginRenamed.

public void pluginRenamed() {
    if (selectedLogEntry.getConsoleMaskRoot() != null) {
        ParseTree child = selectedLogEntry.getConsoleMask().getChild(0);
        ConfigTreeNodeUtilities.removeChild(loggingSectionHandler.getLastSectionRoot(), selectedLogEntry.getConsoleMaskRoot());
        createConsoleMaskRootNode(loggingPage.getSelectedTreeElement(), selectedLogEntry);
        if (child != null) {
            ConfigTreeNodeUtilities.addChild(selectedLogEntry.getConsoleMask(), child, 0);
        }
    }
    if (selectedLogEntry.getFileMaskRoot() != null) {
        ParseTree child = selectedLogEntry.getFileMask().getChild(0);
        ConfigTreeNodeUtilities.removeChild(loggingSectionHandler.getLastSectionRoot(), selectedLogEntry.getFileMaskRoot());
        createFileMaskRootNode(loggingPage.getSelectedTreeElement(), selectedLogEntry);
        if (child != null) {
            ConfigTreeNodeUtilities.addChild(selectedLogEntry.getFileMask(), child, 0);
        }
    }
}
Also used : AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 87 with ParseTree

use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.

the class ModuleParameterTransfer method nativeToJava.

@Override
protected ModuleParameter[] nativeToJava(final TransferData transferData) {
    byte[] bytes = (byte[]) super.nativeToJava(transferData);
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
    try {
        int n = in.readInt();
        ModuleParameter[] items = new ModuleParameter[n];
        for (int i = 0; i < n; i++) {
            ModuleParameter newModuleParameter = new ModuleParameterSectionHandler.ModuleParameter();
            final ParseTree root = new ParserRuleContext();
            newModuleParameter.setRoot(root);
            // module name part
            final String hiddenBeforeModuleName = in.readUTF();
            final String moduleName = in.readUTF();
            final String hiddenBeforeSeparator = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree("\n"));
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBeforeModuleName));
            newModuleParameter.setModuleName(new AddedParseTree(moduleName));
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBeforeSeparator));
            ConfigTreeNodeUtilities.addChild(root, newModuleParameter.getModuleName());
            final boolean isModuleNameEmpty = moduleName == null || moduleName.isEmpty();
            newModuleParameter.setSeparator(new AddedParseTree(isModuleNameEmpty ? "" : "."));
            ConfigTreeNodeUtilities.addChild(root, newModuleParameter.getSeparator());
            // parameter name part
            final String hiddenBeforeParameterName = in.readUTF();
            final String parameterName = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBeforeParameterName));
            newModuleParameter.setParameterName(new AddedParseTree(parameterName));
            ConfigTreeNodeUtilities.addChild(root, newModuleParameter.getParameterName());
            // the := sign and the hidden stuff before it
            final String hiddenBeforeOperator = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBeforeOperator));
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(" := "));
            // the value part
            final String hiddenBeforeValue = in.readUTF();
            final String value = in.readUTF();
            ConfigTreeNodeUtilities.addChild(root, new AddedParseTree(hiddenBeforeValue));
            newModuleParameter.setValue(new AddedParseTree(value));
            ConfigTreeNodeUtilities.addChild(root, newModuleParameter.getValue());
            // put it under the root node
            items[i] = newModuleParameter;
        }
        return items;
    } catch (IOException e) {
        ErrorReporter.logExceptionStackTrace(e);
        return new ModuleParameter[] {};
    }
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) ModuleParameter(org.eclipse.titan.common.parsers.cfg.indices.ModuleParameterSectionHandler.ModuleParameter) 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 88 with ParseTree

use of org.antlr.v4.runtime.tree.ParseTree 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 89 with ParseTree

use of org.antlr.v4.runtime.tree.ParseTree 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 90 with ParseTree

use of org.antlr.v4.runtime.tree.ParseTree in project titan.EclipsePlug-ins by eclipse.

the class ExecuteSectionDropTargetListener method drop.

@Override
public void drop(final DropTargetEvent event) {
    if (ExecuteItemTransfer.getInstance().isSupportedType(event.currentDataType)) {
        if (event.item != null && viewer.getInput() != null) {
            ExecuteSectionHandler executeSectionHandler = (ExecuteSectionHandler) viewer.getInput();
            ExecuteItem element = (ExecuteItem) event.item.getData();
            ExecuteItem[] items = (ExecuteItem[]) event.data;
            int baseindex = executeSectionHandler.getExecuteitems().indexOf(element);
            final ParseTree parent = executeSectionHandler.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++) {
                    executeSectionHandler.getExecuteitems().add(++baseindex, items[i]);
                }
                executeSectionHandler.getExecuteitems().add(++baseindex, items[items.length - 1]);
            }
            viewer.refresh(true);
            editor.setDirty();
        }
    }
}
Also used : ExecuteItem(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem) ExecuteSectionHandler(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

ParseTree (org.antlr.v4.runtime.tree.ParseTree)311 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)104 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)60 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)49 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)46 CharStream (org.antlr.v4.runtime.CharStream)43 Test (org.junit.Test)43 CommonToken (org.antlr.v4.runtime.CommonToken)35 ParseTreeWalker (org.antlr.v4.runtime.tree.ParseTreeWalker)35 JavadocContext (com.puppycrawl.tools.checkstyle.grammars.javadoc.JavadocParser.JavadocContext)31 TextContext (com.puppycrawl.tools.checkstyle.grammars.javadoc.JavadocParser.TextContext)29 File (java.io.File)26 ArrayList (java.util.ArrayList)22 TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)22 CancellationException (java.util.concurrent.CancellationException)20 ConsoleErrorListener (org.antlr.v4.runtime.ConsoleErrorListener)20 Grammar (org.antlr.v4.tool.Grammar)20 ByteArrayInputStream (java.io.ByteArrayInputStream)19 IOException (java.io.IOException)19 LexerGrammar (org.antlr.v4.tool.LexerGrammar)16