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.

IHierarchy.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* *******************************************************************
  2. * Copyright (c) 2003,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 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. * Mik Kersten initial implementation
  11. * Andy Clement
  12. * ******************************************************************/
  13. package org.aspectj.asm;
  14. import java.io.Serializable;
  15. import java.util.HashMap;
  16. import java.util.Map;
  17. import java.util.Set;
  18. import org.aspectj.asm.internal.ProgramElement;
  19. import org.aspectj.bridge.ISourceLocation;
  20. /**
  21. * @author Mik Kersten
  22. * @author Andy Clement
  23. */
  24. public interface IHierarchy extends Serializable {
  25. IProgramElement NO_STRUCTURE = new ProgramElement(null, "<build to view structure>",
  26. IProgramElement.Kind.ERROR, null);
  27. IProgramElement getElement(String handle);
  28. IProgramElement getRoot();
  29. void setRoot(IProgramElement root);
  30. void addToFileMap(String canonicalFilePath, IProgramElement compilationUnitProgramElement);
  31. boolean removeFromFileMap(String canonicalFilePath);
  32. void setFileMap(Map<String, IProgramElement> fileMap);
  33. default void setFileMap(HashMap<String, IProgramElement> fileMap) {
  34. setFileMap((Map<String, IProgramElement>) fileMap);
  35. }
  36. IProgramElement findInFileMap(String key);
  37. Set<Map.Entry<String, IProgramElement>> getFileMapEntrySet();
  38. boolean isValid();
  39. IProgramElement findElementForHandle(String handle);
  40. IProgramElement findElementForHandleOrCreate(String handle, boolean create);
  41. /**
  42. * Returns the first match
  43. *
  44. * @param parent
  45. * @param kind not null
  46. * @return null if not found
  47. */
  48. IProgramElement findElementForSignature(IProgramElement parent, IProgramElement.Kind kind, String signature);
  49. /**
  50. * Returns the first match
  51. *
  52. * @param parent
  53. * @param kind not null
  54. * @return null if not found
  55. */
  56. IProgramElement findElementForLabel(IProgramElement parent, IProgramElement.Kind kind, String label);
  57. /**
  58. * @param packageName if null default package is searched
  59. * @param typeName can't be null
  60. */
  61. IProgramElement findElementForType(String packageName, String typeName);
  62. /**
  63. * @param sourceFile modified to '/' delimited path for consistency
  64. * @return a new structure node for the file if it was not found in the model
  65. */
  66. IProgramElement findElementForSourceFile(String sourceFile);
  67. /**
  68. * TODO: discriminate columns
  69. */
  70. IProgramElement findElementForSourceLine(ISourceLocation location);
  71. /**
  72. * Never returns null
  73. *
  74. * @param sourceFilePath canonicalized path for consistency
  75. * @param lineNumber if 0 or 1 the corresponding file node will be returned
  76. * @return a new structure node for the file if it was not found in the model
  77. */
  78. IProgramElement findElementForSourceLine(String sourceFilePath, int lineNumber);
  79. IProgramElement findElementForOffSet(String sourceFilePath, int lineNumber, int offSet);
  80. String getConfigFile();
  81. void setConfigFile(String configFile);
  82. void flushTypeMap();
  83. void flushHandleMap();
  84. void updateHandleMap(Set<String> deletedFiles);
  85. /**
  86. * For a specified node, check if any of the children more accurately represent the specified line.
  87. *
  88. * @param node where to start looking
  89. * @param lineno the line number
  90. * @return any closer match below 'node' or null if nothing is a more accurate match
  91. */
  92. IProgramElement findCloserMatchForLineNumber(IProgramElement node, int lineno);
  93. /**
  94. * Discover the node representing a particular source file.
  95. *
  96. * @param node where in the model to start looking (usually the root on the initial call)
  97. * @param sourcefilePath the source file being searched for
  98. * @return the node representing that source file or null if it cannot be found
  99. */
  100. IProgramElement findNodeForSourceFile(IProgramElement node, String sourcefilePath);
  101. }