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

AjConstructorDeclaration.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*******************************************************************************
  2. * Copyright (c) 2004 IBM Corporation and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * IBM Corporation
  10. *******************************************************************************/
  11. package org.aspectj.ajdt.internal.compiler.ast;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import org.aspectj.weaver.AjAttribute;
  15. import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
  16. import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
  17. import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
  18. import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
  19. /**
  20. * Root class for all ConstructorDeclaration objects created by the parser.
  21. * Enables us to generate extra attributes in the method_info attribute
  22. * to support aspectj.
  23. */
  24. public class AjConstructorDeclaration extends ConstructorDeclaration {
  25. /**
  26. * @param compilationResult
  27. */
  28. public AjConstructorDeclaration(CompilationResult compilationResult) {
  29. super(compilationResult);
  30. }
  31. /* (non-Javadoc)
  32. * @see org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration#generateInfoAttributes(org.eclipse.jdt.internal.compiler.ClassFile)
  33. */
  34. protected int generateInfoAttributes(ClassFile classFile) {
  35. // add extra attributes into list then call 2-arg version of generateInfoAttributes...
  36. List extras = new ArrayList();
  37. addDeclarationStartLineAttribute(extras,classFile);
  38. return classFile.generateMethodInfoAttributes(binding,extras);
  39. }
  40. protected void addDeclarationStartLineAttribute(List extraAttributeList, ClassFile classFile) {
  41. if ((classFile.codeStream.generateAttributes & ClassFileConstants.ATTR_LINES)==0) return;
  42. int[] separators = compilationResult().lineSeparatorPositions;
  43. int declarationStartLine = 1;
  44. for (int i = 0; i < separators.length; i++) {
  45. if (sourceStart < separators[i]) break;
  46. declarationStartLine++;
  47. }
  48. extraAttributeList.add(
  49. new EclipseAttributeAdapter(new AjAttribute.MethodDeclarationLineNumberAttribute(declarationStartLine, this.sourceStart())));
  50. }
  51. }