選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

DeclareDeclaration.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-v10.html
  8. *
  9. * Contributors:
  10. * Xerox/PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.ajdt.internal.compiler.ast;
  13. import org.aspectj.ajdt.internal.compiler.lookup.*;
  14. import org.aspectj.ajdt.internal.compiler.lookup.EclipseScope;
  15. import org.aspectj.weaver.*;
  16. import org.aspectj.weaver.AjAttribute;
  17. import org.aspectj.weaver.patterns.*;
  18. import org.aspectj.weaver.patterns.Declare;
  19. import org.eclipse.jdt.internal.compiler.*;
  20. import org.eclipse.jdt.internal.compiler.CompilationResult;
  21. import org.eclipse.jdt.internal.compiler.ast.*;
  22. import org.eclipse.jdt.internal.compiler.lookup.*;
  23. import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
  24. import org.eclipse.jdt.internal.compiler.parser.Parser;
  25. public class DeclareDeclaration extends MethodDeclaration {
  26. public Declare declare;
  27. /**
  28. * Constructor for IntraTypeDeclaration.
  29. */
  30. static int counter = 0; //XXX evil
  31. public DeclareDeclaration(CompilationResult result, Declare symbolicDeclare) {
  32. super(result);
  33. this.declare = symbolicDeclare;
  34. if (declare != null) {
  35. sourceStart = declare.getStart();
  36. sourceEnd = declare.getEnd();
  37. }
  38. //??? we might need to set parameters to be empty
  39. this.returnType = TypeReference.baseTypeReference(T_void, 0);
  40. this.selector = ("ajc$declare_"+counter++).toCharArray(); //??? performance
  41. }
  42. /**
  43. * A pointcut declaration exists in a classfile only as an attibute on the
  44. * class. Unlike advice and inter-type declarations, it has no corresponding
  45. * method.
  46. */
  47. public void generateCode(ClassScope classScope, ClassFile classFile) {
  48. classFile.extraAttributes.add(new EclipseAttributeAdapter(new AjAttribute.DeclareAttribute(declare)));
  49. return;
  50. }
  51. public void parseStatements(
  52. Parser parser,
  53. CompilationUnitDeclaration unit) {
  54. // do nothing
  55. }
  56. public void resolveStatements(ClassScope upperScope) {
  57. // do nothing
  58. }
  59. // public boolean finishResolveTypes(SourceTypeBinding sourceTypeBinding) {
  60. // // there's nothing for our super to resolve usefully
  61. // //if (!super.finishResolveTypes(sourceTypeBinding)) return false;
  62. //// if (declare == null) return true;
  63. ////
  64. //// EclipseScope scope = new EclipseScope(new FormalBinding[0], this.scope);
  65. ////
  66. //// declare.resolve(scope);
  67. //// return true;
  68. // }
  69. public void build(ClassScope classScope, CrosscuttingMembers xcut) {
  70. if (declare == null) return;
  71. EclipseScope scope = new EclipseScope(new FormalBinding[0], classScope);
  72. declare.resolve(scope);
  73. xcut.addDeclare(declare);
  74. //EclipseWorld world = EclipseWorld.fromScopeLookupEnvironment(classScope);
  75. //XXX need to work out the eclipse side of all this state
  76. //XXX world.addDeclare(world.resolve(EclipseWorld.fromBinding(classScope.referenceContext.binding)),
  77. //XXX declare, false);
  78. // binding = makeMethodBinding(classScope);
  79. // world.addTypeMunger(new EclipseNewMethodTypeMunger(binding));
  80. // //??? what do we need to know
  81. // munger = new NewMethodTypeMunger(
  82. // EclipseWorld.makeResolvedMember(binding.introducedMethod),
  83. // EclipseWorld.makeResolvedMember(super.binding), null);
  84. }
  85. public String toString(int tab) {
  86. if (declare == null) return tabString(tab) + "<declare>";
  87. else return tabString(tab) + declare.toString();
  88. }
  89. }