|
| 1 | +/* |
| 2 | + * Copyright The Cryostat Authors |
| 3 | + * |
| 4 | + * The Universal Permissive License (UPL), Version 1.0 |
| 5 | + * |
| 6 | + * Subject to the condition set forth below, permission is hereby granted to any |
| 7 | + * person obtaining a copy of this software, associated documentation and/or data |
| 8 | + * (collectively the "Software"), free of charge and under any and all copyright |
| 9 | + * rights in the Software, and any and all patent rights owned or freely |
| 10 | + * licensable by each licensor hereunder covering either (i) the unmodified |
| 11 | + * Software as contributed to or provided by such licensor, or (ii) the Larger |
| 12 | + * Works (as defined below), to deal in both |
| 13 | + * |
| 14 | + * (a) the Software, and |
| 15 | + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if |
| 16 | + * one is included with the Software (each a "Larger Work" to which the Software |
| 17 | + * is contributed by such licensors), |
| 18 | + * |
| 19 | + * without restriction, including without limitation the rights to copy, create |
| 20 | + * derivative works of, display, perform, and distribute the Software and make, |
| 21 | + * use, sell, offer for sale, import, export, have made, and have sold the |
| 22 | + * Software and the Larger Work(s), and to sublicense the foregoing rights on |
| 23 | + * either these or other terms. |
| 24 | + * |
| 25 | + * This license is subject to the following condition: |
| 26 | + * The above copyright notice and either this complete permission notice or at |
| 27 | + * a minimum a reference to the UPL must be included in all copies or |
| 28 | + * substantial portions of the Software. |
| 29 | + * |
| 30 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 31 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 32 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 33 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 34 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 35 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 36 | + * SOFTWARE. |
| 37 | + */ |
| 38 | +package io.cryostat.rules; |
| 39 | + |
| 40 | +import jdk.nashorn.api.tree.BreakTree; |
| 41 | +import jdk.nashorn.api.tree.CaseTree; |
| 42 | +import jdk.nashorn.api.tree.CatchTree; |
| 43 | +import jdk.nashorn.api.tree.ClassDeclarationTree; |
| 44 | +import jdk.nashorn.api.tree.ClassExpressionTree; |
| 45 | +import jdk.nashorn.api.tree.ContinueTree; |
| 46 | +import jdk.nashorn.api.tree.DebuggerTree; |
| 47 | +import jdk.nashorn.api.tree.DoWhileLoopTree; |
| 48 | +import jdk.nashorn.api.tree.ErroneousTree; |
| 49 | +import jdk.nashorn.api.tree.ExportEntryTree; |
| 50 | +import jdk.nashorn.api.tree.ForInLoopTree; |
| 51 | +import jdk.nashorn.api.tree.ForLoopTree; |
| 52 | +import jdk.nashorn.api.tree.ForOfLoopTree; |
| 53 | +import jdk.nashorn.api.tree.FunctionCallTree; |
| 54 | +import jdk.nashorn.api.tree.FunctionDeclarationTree; |
| 55 | +import jdk.nashorn.api.tree.FunctionExpressionTree; |
| 56 | +import jdk.nashorn.api.tree.ImportEntryTree; |
| 57 | +import jdk.nashorn.api.tree.InstanceOfTree; |
| 58 | +import jdk.nashorn.api.tree.LabeledStatementTree; |
| 59 | +import jdk.nashorn.api.tree.ModuleTree; |
| 60 | +import jdk.nashorn.api.tree.NewTree; |
| 61 | +import jdk.nashorn.api.tree.RegExpLiteralTree; |
| 62 | +import jdk.nashorn.api.tree.ReturnTree; |
| 63 | +import jdk.nashorn.api.tree.SimpleTreeVisitorES5_1; |
| 64 | +import jdk.nashorn.api.tree.SpreadTree; |
| 65 | +import jdk.nashorn.api.tree.ThrowTree; |
| 66 | +import jdk.nashorn.api.tree.Tree; |
| 67 | +import jdk.nashorn.api.tree.TryTree; |
| 68 | +import jdk.nashorn.api.tree.UnaryTree; |
| 69 | +import jdk.nashorn.api.tree.WhileLoopTree; |
| 70 | +import jdk.nashorn.api.tree.WithTree; |
| 71 | +import jdk.nashorn.api.tree.YieldTree; |
| 72 | + |
| 73 | +class MatchExpressionTreeVisitor extends SimpleTreeVisitorES5_1<Void, String> { |
| 74 | + private Void fail(Tree node, String matchExpression) { |
| 75 | + throw new IllegalMatchExpressionException(node, matchExpression); |
| 76 | + } |
| 77 | + |
| 78 | + @Override |
| 79 | + public Void visitBreak(BreakTree node, String matchExpression) { |
| 80 | + return fail(node, matchExpression); |
| 81 | + } |
| 82 | + |
| 83 | + @Override |
| 84 | + public Void visitCase(CaseTree node, String matchExpression) { |
| 85 | + return fail(node, matchExpression); |
| 86 | + } |
| 87 | + |
| 88 | + @Override |
| 89 | + public Void visitCatch(CatchTree node, String matchExpression) { |
| 90 | + return fail(node, matchExpression); |
| 91 | + } |
| 92 | + |
| 93 | + @Override |
| 94 | + public Void visitClassDeclaration(ClassDeclarationTree node, String matchExpression) { |
| 95 | + return fail(node, matchExpression); |
| 96 | + } |
| 97 | + |
| 98 | + @Override |
| 99 | + public Void visitClassExpression(ClassExpressionTree node, String matchExpression) { |
| 100 | + return fail(node, matchExpression); |
| 101 | + } |
| 102 | + |
| 103 | + @Override |
| 104 | + public Void visitDoWhileLoop(DoWhileLoopTree node, String matchExpression) { |
| 105 | + return fail(node, matchExpression); |
| 106 | + } |
| 107 | + |
| 108 | + @Override |
| 109 | + public Void visitErroneous(ErroneousTree node, String matchExpression) { |
| 110 | + return fail(node, matchExpression); |
| 111 | + } |
| 112 | + |
| 113 | + @Override |
| 114 | + public Void visitExportEntry(ExportEntryTree node, String matchExpression) { |
| 115 | + return fail(node, matchExpression); |
| 116 | + } |
| 117 | + |
| 118 | + @Override |
| 119 | + public Void visitForInLoop(ForInLoopTree node, String matchExpression) { |
| 120 | + return fail(node, matchExpression); |
| 121 | + } |
| 122 | + |
| 123 | + @Override |
| 124 | + public Void visitForLoop(ForLoopTree node, String matchExpression) { |
| 125 | + return fail(node, matchExpression); |
| 126 | + } |
| 127 | + |
| 128 | + @Override |
| 129 | + public Void visitForOfLoop(ForOfLoopTree node, String matchExpression) { |
| 130 | + return fail(node, matchExpression); |
| 131 | + } |
| 132 | + |
| 133 | + @Override |
| 134 | + public Void visitFunctionCall(FunctionCallTree node, String matchExpression) { |
| 135 | + return fail(node, matchExpression); |
| 136 | + } |
| 137 | + |
| 138 | + @Override |
| 139 | + public Void visitFunctionDeclaration(FunctionDeclarationTree node, String matchExpression) { |
| 140 | + return fail(node, matchExpression); |
| 141 | + } |
| 142 | + |
| 143 | + @Override |
| 144 | + public Void visitFunctionExpression(FunctionExpressionTree node, String matchExpression) { |
| 145 | + return fail(node, matchExpression); |
| 146 | + } |
| 147 | + |
| 148 | + @Override |
| 149 | + public Void visitImportEntry(ImportEntryTree node, String matchExpression) { |
| 150 | + return fail(node, matchExpression); |
| 151 | + } |
| 152 | + |
| 153 | + @Override |
| 154 | + public Void visitInstanceOf(InstanceOfTree node, String matchExpression) { |
| 155 | + return fail(node, matchExpression); |
| 156 | + } |
| 157 | + |
| 158 | + @Override |
| 159 | + public Void visitLabeledStatement(LabeledStatementTree node, String matchExpression) { |
| 160 | + return fail(node, matchExpression); |
| 161 | + } |
| 162 | + |
| 163 | + @Override |
| 164 | + public Void visitModule(ModuleTree node, String matchExpression) { |
| 165 | + return fail(node, matchExpression); |
| 166 | + } |
| 167 | + |
| 168 | + @Override |
| 169 | + public Void visitNew(NewTree node, String matchExpression) { |
| 170 | + return fail(node, matchExpression); |
| 171 | + } |
| 172 | + |
| 173 | + @Override |
| 174 | + public Void visitRegExpLiteral(RegExpLiteralTree node, String matchExpression) { |
| 175 | + return fail(node, matchExpression); |
| 176 | + } |
| 177 | + |
| 178 | + @Override |
| 179 | + public Void visitReturn(ReturnTree node, String matchExpression) { |
| 180 | + return fail(node, matchExpression); |
| 181 | + } |
| 182 | + |
| 183 | + @Override |
| 184 | + public Void visitSpread(SpreadTree node, String matchExpression) { |
| 185 | + return fail(node, matchExpression); |
| 186 | + } |
| 187 | + |
| 188 | + @Override |
| 189 | + public Void visitUnary(UnaryTree node, String matchExpression) { |
| 190 | + return fail(node, matchExpression); |
| 191 | + } |
| 192 | + |
| 193 | + @Override |
| 194 | + public Void visitUnknown(Tree node, String matchExpression) { |
| 195 | + return fail(node, matchExpression); |
| 196 | + } |
| 197 | + |
| 198 | + @Override |
| 199 | + public Void visitWhileLoop(WhileLoopTree node, String matchExpression) { |
| 200 | + return fail(node, matchExpression); |
| 201 | + } |
| 202 | + |
| 203 | + @Override |
| 204 | + public Void visitWith(WithTree node, String matchExpression) { |
| 205 | + return fail(node, matchExpression); |
| 206 | + } |
| 207 | + |
| 208 | + @Override |
| 209 | + public Void visitYield(YieldTree node, String matchExpression) { |
| 210 | + return fail(node, matchExpression); |
| 211 | + } |
| 212 | + |
| 213 | + @Override |
| 214 | + public Void visitContinue(ContinueTree node, String matchExpression) { |
| 215 | + return fail(node, matchExpression); |
| 216 | + } |
| 217 | + |
| 218 | + @Override |
| 219 | + public Void visitDebugger(DebuggerTree node, String matchExpression) { |
| 220 | + return fail(node, matchExpression); |
| 221 | + } |
| 222 | + |
| 223 | + @Override |
| 224 | + public Void visitThrow(ThrowTree node, String matchExpression) { |
| 225 | + return fail(node, matchExpression); |
| 226 | + } |
| 227 | + |
| 228 | + @Override |
| 229 | + public Void visitTry(TryTree node, String matchExpression) { |
| 230 | + return fail(node, matchExpression); |
| 231 | + } |
| 232 | +} |
0 commit comments