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.

AjTypeConstants.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.ajdt.internal.compiler.lookup;
  13. import org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
  14. import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference;
  15. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
  16. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
  17. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
  18. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
  19. public class AjTypeConstants {
  20. public static final char[] ORG = "org".toCharArray();
  21. public static final char[] ASPECTJ = "aspectj".toCharArray();
  22. public static final char[] RUNTIME = "runtime".toCharArray();
  23. public static final char[] LANG = "lang".toCharArray();
  24. public static final char[] INTERNAL = "internal".toCharArray();
  25. // Constant compound names
  26. public static final char[][] ORG_ASPECTJ_LANG_JOINPOINT =
  27. new char[][] {ORG, ASPECTJ, LANG, "JoinPoint".toCharArray()};
  28. public static final char[][] ORG_ASPECTJ_LANG_JOINPOINT_STATICPART =
  29. new char[][] {ORG, ASPECTJ, LANG, "JoinPoint".toCharArray(), "StaticPart".toCharArray()};
  30. public static final char[][] ORG_ASPECTJ_RUNTIME_INTERNAL_AROUNDCLOSURE =
  31. new char[][] {ORG, ASPECTJ, RUNTIME, INTERNAL, "AroundClosure".toCharArray()};
  32. public static final char[][] ORG_ASPECTJ_RUNTIME_INTERNAL_CONVERSIONS =
  33. new char[][] {ORG, ASPECTJ, RUNTIME, INTERNAL, "Conversions".toCharArray()};
  34. public static TypeReference getJoinPointType() {
  35. return new QualifiedTypeReference(ORG_ASPECTJ_LANG_JOINPOINT, new long[10]);
  36. }
  37. public static TypeReference getJoinPointStaticPartType() {
  38. return new QualifiedTypeReference(ORG_ASPECTJ_LANG_JOINPOINT_STATICPART, new long[10]);
  39. }
  40. public static TypeReference getAroundClosureType() {
  41. return new QualifiedTypeReference(ORG_ASPECTJ_RUNTIME_INTERNAL_AROUNDCLOSURE, new long[10]);
  42. }
  43. public static ReferenceBinding getConversionsType(Scope scope) {
  44. return (ReferenceBinding)scope.getType(
  45. ORG_ASPECTJ_RUNTIME_INTERNAL_CONVERSIONS,
  46. ORG_ASPECTJ_RUNTIME_INTERNAL_CONVERSIONS.length);
  47. }
  48. public static MethodBinding getConversionMethodToObject(Scope scope, TypeBinding fromType) {
  49. String name = new String(fromType.sourceName()) + "Object";
  50. return getConversionsType(scope).getMethods(name.toCharArray())[0];
  51. }
  52. public static MethodBinding getConversionMethodFromObject(Scope scope, TypeBinding toType) {
  53. String name = new String(toType.sourceName()) + "Value";
  54. return getConversionsType(scope).getMethods(name.toCharArray())[0];
  55. }
  56. }