You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TypeVisitor.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.server.widgetsetutils.metadata;
  17. import com.google.gwt.core.ext.TreeLogger;
  18. import com.google.gwt.core.ext.UnableToCompleteException;
  19. import com.google.gwt.core.ext.typeinfo.JClassType;
  20. import com.google.gwt.core.ext.typeinfo.JMethod;
  21. import com.google.gwt.core.ext.typeinfo.JType;
  22. import com.google.gwt.core.ext.typeinfo.NotFoundException;
  23. import com.google.gwt.core.ext.typeinfo.TypeOracle;
  24. public abstract class TypeVisitor {
  25. public void init(TypeOracle oracle) throws NotFoundException {
  26. // Default does nothing
  27. }
  28. public void visitConnector(TreeLogger logger, JClassType type,
  29. ConnectorBundle bundle) throws UnableToCompleteException {
  30. // Default does nothing
  31. }
  32. public void visitClientRpc(TreeLogger logger, JClassType type,
  33. ConnectorBundle bundle) throws UnableToCompleteException {
  34. // Default does nothing
  35. }
  36. public void visitServerRpc(TreeLogger logger, JClassType type,
  37. ConnectorBundle bundle) throws UnableToCompleteException {
  38. // Default does nothing
  39. }
  40. protected JMethod findInheritedMethod(JClassType type, String methodName,
  41. JType... params) {
  42. JClassType currentType = type;
  43. while (currentType != null) {
  44. JMethod method = currentType.findMethod(methodName, params);
  45. if (method != null) {
  46. return method;
  47. }
  48. currentType = currentType.getSuperclass();
  49. }
  50. JClassType[] interfaces = type.getImplementedInterfaces();
  51. for (JClassType iface : interfaces) {
  52. JMethod method = iface.findMethod(methodName, params);
  53. if (method != null) {
  54. return method;
  55. }
  56. }
  57. return null;
  58. }
  59. }