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.

IntertypeMemberTypeFinder.java 2.1KB

14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* *******************************************************************
  2. * Copyright (c) 2010 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Andy Clement - SpringSource
  11. * ******************************************************************/
  12. package org.aspectj.ajdt.internal.compiler.lookup;
  13. import java.util.HashSet;
  14. import java.util.Set;
  15. import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
  16. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ITypeFinder;
  17. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
  18. import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
  19. /**
  20. * The member finder looks after intertype declared inner classes on a type, there is one member finder per type that was hit by an
  21. * new inner type declaration.
  22. *
  23. * @author Andy Clement
  24. * @since 1.6.9
  25. */
  26. public class IntertypeMemberTypeFinder implements ITypeFinder {
  27. // Target that has these new types
  28. public SourceTypeBinding targetTypeBinding;
  29. // The new types declared onto the target
  30. private Set<ReferenceBinding> intertypeMemberTypes = new HashSet<>();
  31. public void addInterTypeMemberType(ReferenceBinding binding) {
  32. intertypeMemberTypes.add(binding);
  33. // ReferenceBinding[] rbs = targetTypeBinding.memberTypes();
  34. // ReferenceBinding[] newRbs = new ReferenceBinding[rbs.length + 1];
  35. // System.arraycopy(rbs, 0, newRbs, 1, rbs.length);
  36. // newRbs[0] = binding;
  37. // (targetTypeBinding).memberTypes = newRbs;
  38. }
  39. public ReferenceBinding getMemberType(char[] memberTypeName) {
  40. for (ReferenceBinding intertypeMemberType : intertypeMemberTypes) {
  41. if (CharOperation.equals(intertypeMemberType.sourceName, memberTypeName)) {
  42. return intertypeMemberType;
  43. }
  44. }
  45. return null;
  46. }
  47. public ReferenceBinding[] getMemberTypes() {
  48. ReferenceBinding[] array = new ReferenceBinding[intertypeMemberTypes.size()];
  49. return intertypeMemberTypes.toArray(array);
  50. }
  51. }