001/* 002 * Copyright 2010-2013 JetBrains s.r.o. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.jetbrains.jet.lang.psi; 018 019import com.intellij.psi.PsiElementVisitor; 020 021public class JetVisitor<R, D> extends PsiElementVisitor { 022 public R visitJetElement(JetElement element, D data) { 023 visitElement(element); 024 return null; 025 } 026 027 public R visitDeclaration(JetDeclaration dcl, D data) { 028 return visitExpression(dcl, data); 029 } 030 031 public R visitClass(JetClass klass, D data) { 032 return visitNamedDeclaration(klass, data); 033 } 034 035 public R visitClassObject(JetClassObject classObject, D data) { 036 return visitDeclaration(classObject, data); 037 } 038 039 public R visitNamedFunction(JetNamedFunction function, D data) { 040 return visitNamedDeclaration(function, data); 041 } 042 043 public R visitProperty(JetProperty property, D data) { 044 return visitNamedDeclaration(property, data); 045 } 046 047 public R visitMultiDeclaration(JetMultiDeclaration multiDeclaration, D data) { 048 return visitDeclaration(multiDeclaration, data); 049 } 050 051 public R visitMultiDeclarationEntry(JetMultiDeclarationEntry multiDeclarationEntry, D data) { 052 return visitNamedDeclaration(multiDeclarationEntry, data); 053 } 054 055 public R visitTypedef(JetTypedef typedef, D data) { 056 return visitNamedDeclaration(typedef, data); 057 } 058 059 public R visitJetFile(JetFile file, D data) { 060 visitFile(file); 061 return null; 062 } 063 064 public R visitScript(JetScript script, D data) { 065 return visitDeclaration(script, data); 066 } 067 068 public R visitImportDirective(JetImportDirective importDirective, D data) { 069 return visitJetElement(importDirective, data); 070 } 071 072 public R visitClassBody(JetClassBody classBody, D data) { 073 return visitJetElement(classBody, data); 074 } 075 076 public R visitModifierList(JetModifierList list, D data) { 077 return visitJetElement(list, data); 078 } 079 080 public R visitAnnotation(JetAnnotation annotation, D data) { 081 return visitJetElement(annotation, data); 082 } 083 084 public R visitAnnotationEntry(JetAnnotationEntry annotationEntry, D data) { 085 return visitJetElement(annotationEntry, data); 086 } 087 088 public R visitTypeParameterList(JetTypeParameterList list, D data) { 089 return visitJetElement(list, data); 090 } 091 092 public R visitTypeParameter(JetTypeParameter parameter, D data) { 093 return visitNamedDeclaration(parameter, data); 094 } 095 096 public R visitEnumEntry(JetEnumEntry enumEntry, D data) { 097 return visitClass(enumEntry, data); 098 } 099 100 public R visitParameterList(JetParameterList list, D data) { 101 return visitJetElement(list, data); 102 } 103 104 public R visitParameter(JetParameter parameter, D data) { 105 return visitNamedDeclaration(parameter, data); 106 } 107 108 public R visitDelegationSpecifierList(JetDelegationSpecifierList list, D data) { 109 return visitJetElement(list, data); 110 } 111 112 public R visitDelegationSpecifier(JetDelegationSpecifier specifier, D data) { 113 return visitJetElement(specifier, data); 114 } 115 116 public R visitDelegationByExpressionSpecifier(JetDelegatorByExpressionSpecifier specifier, D data) { 117 return visitDelegationSpecifier(specifier, data); 118 } 119 120 public R visitDelegationToSuperCallSpecifier(JetDelegatorToSuperCall call, D data) { 121 return visitDelegationSpecifier(call, data); 122 } 123 124 public R visitDelegationToSuperClassSpecifier(JetDelegatorToSuperClass specifier, D data) { 125 return visitDelegationSpecifier(specifier, data); 126 } 127 128 public R visitDelegationToThisCall(JetDelegatorToThisCall thisCall, D data) { 129 return visitDelegationSpecifier(thisCall, data); 130 } 131 132 public R visitPropertyDelegate(JetPropertyDelegate delegate, D data) { 133 return visitJetElement(delegate, data); 134 } 135 136 public R visitTypeReference(JetTypeReference typeReference, D data) { 137 return visitJetElement(typeReference, data); 138 } 139 140 public R visitValueArgumentList(JetValueArgumentList list, D data) { 141 return visitJetElement(list, data); 142 } 143 144 public R visitArgument(JetValueArgument argument, D data) { 145 return visitJetElement(argument, data); 146 } 147 148 public R visitExpression(JetExpression expression, D data) { 149 return visitJetElement(expression, data); 150 } 151 152 public R visitLoopExpression(JetLoopExpression loopExpression, D data) { 153 return visitExpression(loopExpression, data); 154 } 155 156 public R visitConstantExpression(JetConstantExpression expression, D data) { 157 return visitExpression(expression, data); 158 } 159 160 public R visitSimpleNameExpression(JetSimpleNameExpression expression, D data) { 161 return visitReferenceExpression(expression, data); 162 } 163 164 public R visitReferenceExpression(JetReferenceExpression expression, D data) { 165 return visitExpression(expression, data); 166 } 167 168 public R visitPrefixExpression(JetPrefixExpression expression, D data) { 169 return visitUnaryExpression(expression, data); 170 } 171 172 public R visitPostfixExpression(JetPostfixExpression expression, D data) { 173 return visitUnaryExpression(expression, data); 174 } 175 176 public R visitUnaryExpression(JetUnaryExpression expression, D data) { 177 return visitExpression(expression, data); 178 } 179 180 public R visitBinaryExpression(JetBinaryExpression expression, D data) { 181 return visitExpression(expression, data); 182 } 183 184// public R visitNewExpression(JetNewExpression expression, D data) { 185// return visitExpression(expression, data); 186// } 187// 188 public R visitReturnExpression(JetReturnExpression expression, D data) { 189 return visitLabelQualifiedExpression(expression, data); 190 } 191 192 public R visitLabelQualifiedExpression(JetLabelQualifiedExpression expression, D data) { 193 return visitExpression(expression, data); 194 } 195 196 public R visitThrowExpression(JetThrowExpression expression, D data) { 197 return visitExpression(expression, data); 198 } 199 200 public R visitBreakExpression(JetBreakExpression expression, D data) { 201 return visitLabelQualifiedExpression(expression, data); 202 } 203 204 public R visitContinueExpression(JetContinueExpression expression, D data) { 205 return visitLabelQualifiedExpression(expression, data); 206 } 207 208 public R visitIfExpression(JetIfExpression expression, D data) { 209 return visitExpression(expression, data); 210 } 211 212 public R visitWhenExpression(JetWhenExpression expression, D data) { 213 return visitExpression(expression, data); 214 } 215 216 public R visitTryExpression(JetTryExpression expression, D data) { 217 return visitExpression(expression, data); 218 } 219 220 public R visitForExpression(JetForExpression expression, D data) { 221 return visitLoopExpression(expression, data); 222 } 223 224 public R visitWhileExpression(JetWhileExpression expression, D data) { 225 return visitLoopExpression(expression, data); 226 } 227 228 public R visitDoWhileExpression(JetDoWhileExpression expression, D data) { 229 return visitLoopExpression(expression, data); 230 } 231 232 public R visitFunctionLiteralExpression(JetFunctionLiteralExpression expression, D data) { 233 return visitExpression(expression, data); 234 } 235 236 public R visitAnnotatedExpression(JetAnnotatedExpression expression, D data) { 237 return visitExpression(expression, data); 238 } 239 240 public R visitCallExpression(JetCallExpression expression, D data) { 241 return visitExpression(expression, data); 242 } 243 244 public R visitArrayAccessExpression(JetArrayAccessExpression expression, D data) { 245 return visitReferenceExpression(expression, data); 246 } 247 248 public R visitQualifiedExpression(JetQualifiedExpression expression, D data) { 249 return visitExpression(expression, data); 250 } 251 252 public R visitCallableReferenceExpression(JetCallableReferenceExpression expression, D data) { 253 return visitExpression(expression, data); 254 } 255 256 public R visitDotQualifiedExpression(JetDotQualifiedExpression expression, D data) { 257 return visitQualifiedExpression(expression, data); 258 } 259 260 public R visitSafeQualifiedExpression(JetSafeQualifiedExpression expression, D data) { 261 return visitQualifiedExpression(expression, data); 262 } 263 264 public R visitObjectLiteralExpression(JetObjectLiteralExpression expression, D data) { 265 return visitExpression(expression, data); 266 } 267 268 public R visitRootNamespaceExpression(JetRootNamespaceExpression expression, D data) { 269 return visitExpression(expression, data); 270 } 271 272 public R visitBlockExpression(JetBlockExpression expression, D data) { 273 return visitExpression(expression, data); 274 } 275 276 public R visitIdeTemplate(JetIdeTemplate expression, D data) { 277 return null; 278 } 279 280 public R visitCatchSection(JetCatchClause catchClause, D data) { 281 return visitJetElement(catchClause, data); 282 } 283 284 public R visitFinallySection(JetFinallySection finallySection, D data) { 285 return visitJetElement(finallySection, data); 286 } 287 288 public R visitTypeArgumentList(JetTypeArgumentList typeArgumentList, D data) { 289 return visitJetElement(typeArgumentList, data); 290 } 291 292 public R visitThisExpression(JetThisExpression expression, D data) { 293 return visitLabelQualifiedExpression(expression, data); 294 } 295 296 public R visitSuperExpression(JetSuperExpression expression, D data) { 297 return visitLabelQualifiedExpression(expression, data); 298 } 299 300 public R visitParenthesizedExpression(JetParenthesizedExpression expression, D data) { 301 return visitExpression(expression, data); 302 } 303 304 public R visitInitializerList(JetInitializerList list, D data) { 305 return visitJetElement(list, data); 306 } 307 308 public R visitAnonymousInitializer(JetClassInitializer initializer, D data) { 309 return visitDeclaration(initializer, data); 310 } 311 312 public R visitPropertyAccessor(JetPropertyAccessor accessor, D data) { 313 return visitDeclaration(accessor, data); 314 } 315 316 public R visitTypeConstraintList(JetTypeConstraintList list, D data) { 317 return visitJetElement(list, data); 318 } 319 320 public R visitTypeConstraint(JetTypeConstraint constraint, D data) { 321 return visitJetElement(constraint, data); 322 } 323 324 private R visitTypeElement(JetTypeElement type, D data) { 325 return visitJetElement(type, data); 326 } 327 328 public R visitUserType(JetUserType type, D data) { 329 return visitTypeElement(type, data); 330 } 331 332 public R visitFunctionType(JetFunctionType type, D data) { 333 return visitTypeElement(type, data); 334 } 335 336 public R visitSelfType(JetSelfType type, D data) { 337 return visitTypeElement(type, data); 338 } 339 340 public R visitBinaryWithTypeRHSExpression(JetBinaryExpressionWithTypeRHS expression, D data) { 341 return visitExpression(expression, data); 342 } 343 344 public R visitStringTemplateExpression(JetStringTemplateExpression expression, D data) { 345 return visitExpression(expression, data); 346 } 347 348 public R visitNamedDeclaration(JetNamedDeclaration declaration, D data) { 349 return visitDeclaration(declaration, data); 350 } 351 352 public R visitNullableType(JetNullableType nullableType, D data) { 353 return visitTypeElement(nullableType, data); 354 } 355 356 public R visitTypeProjection(JetTypeProjection typeProjection, D data) { 357 return visitJetElement(typeProjection, data); 358 } 359 360 public R visitWhenEntry(JetWhenEntry jetWhenEntry, D data) { 361 return visitJetElement(jetWhenEntry, data); 362 } 363 364 public R visitIsExpression(JetIsExpression expression, D data) { 365 return visitExpression(expression, data); 366 } 367 368 public R visitWhenConditionIsPattern(JetWhenConditionIsPattern condition, D data) { 369 return visitJetElement(condition, data); 370 } 371 372 public R visitWhenConditionInRange(JetWhenConditionInRange condition, D data) { 373 return visitJetElement(condition, data); 374 } 375 376 public R visitWhenConditionExpression(JetWhenConditionWithExpression condition, D data) { 377 return visitJetElement(condition, data); 378 } 379 380 public R visitObjectDeclaration(JetObjectDeclaration declaration, D data) { 381 return visitNamedDeclaration(declaration, data); 382 } 383 384 public R visitObjectDeclarationName(JetObjectDeclarationName declarationName, D data) { 385 return visitNamedDeclaration(declarationName, data); 386 } 387 388 public R visitStringTemplateEntry(JetStringTemplateEntry entry, D data) { 389 return visitJetElement(entry, data); 390 } 391 392 public R visitStringTemplateEntryWithExpression(JetStringTemplateEntryWithExpression entry, D data) { 393 return visitStringTemplateEntry(entry, data); 394 } 395 396 public R visitBlockStringTemplateEntry(JetBlockStringTemplateEntry entry, D data) { 397 return visitStringTemplateEntryWithExpression(entry, data); 398 } 399 400 public R visitSimpleNameStringTemplateEntry(JetSimpleNameStringTemplateEntry entry, D data) { 401 return visitStringTemplateEntryWithExpression(entry, data); 402 } 403 404 public R visitLiteralStringTemplateEntry(JetLiteralStringTemplateEntry entry, D data) { 405 return visitStringTemplateEntry(entry, data); 406 } 407 408 public R visitEscapeStringTemplateEntry(JetEscapeStringTemplateEntry entry, D data) { 409 return visitStringTemplateEntry(entry, data); 410 } 411}