Skip to content

Commit

Permalink
Add super class in reference context
Browse files Browse the repository at this point in the history
  • Loading branch information
jShiwaniGupta committed Oct 24, 2024
1 parent 23eb1b8 commit f5bb110
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ private Set<String> findReferencedClasses(CompilationUnitTree compilationUnit) {
for (Tree tree : compilationUnit.getTypeDecls()) {
if (tree instanceof ClassTree) {
ClassTree classTree = (ClassTree) tree;
Tree superclass = classTree.getExtendsClause();
if (superclass != null) {
referencedClasses.add(superclass.toString());
}
for (Tree member : classTree.getMembers()) {
if (member instanceof VariableTree) {
VariableTree variable = (VariableTree) member;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@
*/
public class ProjectClassListener {

private Project project;
private final Project project;

private Map<FileObject, ClassData> classDatas;
private Set<FileObject> pending = new HashSet<>();
private final Map<FileObject, ClassData> classDatas;
private final Set<DataObject> pendingDO = new HashSet<>();

public ProjectClassListener(Project project, Map<FileObject, ClassData> classDatas) {
this.project = project;
this.classDatas = classDatas;
}

public Set<FileObject> getPending() {
return pending;

public Set<DataObject> getPendingDataObject() {
return pendingDO;
}

public void register() {
Expand Down Expand Up @@ -62,7 +63,7 @@ public void register() {
DataObject[] modifiedObjects = registry.getModified();
for (DataObject dataObj : modifiedObjects) {
if (FileUtil.isParentOf(javaFolder2, dataObj.getPrimaryFile())) {
pending.add(dataObj.getPrimaryFile());
pendingDO.add(dataObj);
classDatas.remove(dataObj.getPrimaryFile());
System.out.println("Modified DataObject: " + dataObj.getName());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ private static void scanFolder(FileObject folder, Map<FileObject, ClassData> cla
}
}

public static void scanJavaFile(DataObject javaFile, Map<FileObject, ClassData> classList) throws IOException {
scanJavaFile(javaFile.getPrimaryFile(), classList) ;
}
public static void scanJavaFile(FileObject javaFile, Map<FileObject, ClassData> classList) throws IOException {
JavaSource javaSource = JavaSource.forFileObject(javaFile);

Expand Down Expand Up @@ -257,10 +260,10 @@ public static List<ClassData> getClassData(FileObject fileObject, Set<String> fi
projectClassListeners.put(key, projectClassListener);
}
if (projectClassListeners.get(key) != null) {
Iterator<FileObject> iterator = projectClassListeners.get(key).getPending().iterator();
Iterator<DataObject> iterator = projectClassListeners.get(key).getPendingDataObject().iterator();
while (iterator.hasNext()) {
FileObject javaFile = iterator.next();
if (javaFile.equals(fileObject)) {
DataObject javaFile = iterator.next();
if (javaFile.getPrimaryFile().equals(fileObject)) {
// Ignore current editor
System.out.println("Ignoring " + fileObject.getName());
} else {
Expand Down

0 comments on commit f5bb110

Please sign in to comment.