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.

InterimCompilationResult.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 - initial API and implementation
  10. *******************************************************************************/
  11. package org.aspectj.ajdt.internal.compiler;
  12. import java.util.List;
  13. import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
  14. import org.aspectj.weaver.bcel.UnwovenClassFile;
  15. /**
  16. * Holds a compilation result produced by the Java compilation phase, ready for weaving in the weave phase. NOTE: This class defines
  17. * equality based solely on the fileName of the compiled file (not the bytecodes produced for example)
  18. */
  19. public class InterimCompilationResult {
  20. private CompilationResult result;
  21. private UnwovenClassFile[] unwovenClassFiles; // longer term would be nice not to have two copies of
  22. // the byte codes, one in result.classFiles and another
  23. // in unwovenClassFiles;
  24. public InterimCompilationResult(CompilationResult cr, IOutputClassFileNameProvider np) {
  25. result = cr;
  26. unwovenClassFiles = ClassFileBasedByteCodeProvider.unwovenClassFilesFor(result, np);
  27. }
  28. public InterimCompilationResult(CompilationResult cr, List<UnwovenClassFile> ucfList) {
  29. result = cr;
  30. unwovenClassFiles = new UnwovenClassFile[ucfList.size()];
  31. for (int i = 0; i < ucfList.size(); i++) {
  32. UnwovenClassFile element = ucfList.get(i);
  33. unwovenClassFiles[i] = element;
  34. AjClassFile ajcf = new AjClassFile(element.getClassNameAsChars(), element.getBytes());
  35. result.record(ajcf.fileName(), ajcf);
  36. }
  37. }
  38. public CompilationResult result() {
  39. return result;
  40. }
  41. public UnwovenClassFile[] unwovenClassFiles() {
  42. return unwovenClassFiles;
  43. }
  44. public String fileName() {
  45. return new String(result.fileName);
  46. }
  47. public boolean equals(Object other) {
  48. if (other == null || !(other instanceof InterimCompilationResult)) {
  49. return false;
  50. }
  51. InterimCompilationResult ir = (InterimCompilationResult) other;
  52. return fileName().equals(ir.fileName());
  53. }
  54. public int hashCode() {
  55. return fileName().hashCode();
  56. }
  57. }