Skip to content

Commit 24ef74e

Browse files
committed
Use bulk mode in class name completion
1 parent 8050602 commit 24ef74e

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

RSTALanguageSupport/src/main/java/org/fife/rsta/ac/java/JarReader.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,16 @@ public void getClassesInPackage(List<ClassFile> addTo, String[] pkgs,
127127
public List<ClassFile> getClassesWithNamesStartingWith(String prefix) {
128128
List<ClassFile> res = new ArrayList<>();
129129
String currentPkg = ""; // Don't use null; we're appending to it
130-
packageMap.getClassesWithNamesStartingWith(info, prefix, currentPkg,
131-
res);
130+
try {
131+
info.bulkClassFileCreationStart();
132+
try {
133+
packageMap.getClassesWithNamesStartingWith(info, prefix, currentPkg, res);
134+
} finally {
135+
info.bulkClassFileCreationEnd();
136+
}
137+
} catch (final IOException ioe) {
138+
ioe.printStackTrace();
139+
}
132140
return res;
133141
}
134142

RSTALanguageSupport/src/main/java/org/fife/rsta/ac/java/PackageMapNode.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ public void getClassesInPackage(LibraryInfo info, List<ClassFile> addTo,
356356

357357
/**
358358
* Method used to recursively scan our package map for classes whose names
359-
* start with a given prefix, ignoring case.
359+
* start with a given prefix, ignoring case.<p>
360+
*
361+
* Note: This method assumes you are fetching class files in bulk from the
362+
* {@code LibraryInfo} instance.
360363
*
361364
* @param prefix The prefix that the unqualified class names must match
362365
* (ignoring case).
@@ -387,7 +390,7 @@ void getClassesWithNamesStartingWith(LibraryInfo info, String prefix,
387390
if (cf==null) {
388391
String fqClassName = currentPkg + className + ".class";
389392
try {
390-
cf = info.createClassFile(fqClassName);
393+
cf = info.createClassFileBulk(fqClassName);
391394
cfEntry.setValue(cf); // Update the map
392395
} catch (IOException ioe) {
393396
ioe.printStackTrace();

RSTALanguageSupport/src/test/java/org/fife/rsta/ac/java/JarReaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void testGetClassesWithNamesStartingWith_matches() throws IOException {
4646
LibraryInfo mockInfo = Mockito.mock(LibraryInfo.class);
4747
doReturn(System.currentTimeMillis()).when(mockInfo).getLastModified();
4848
doReturn(packageMap).when(mockInfo).createPackageMap();
49-
when(mockInfo.createClassFile(anyString())).thenAnswer(input -> {
49+
when(mockInfo.createClassFileBulk(anyString())).thenAnswer(input -> {
5050
ClassFile cf = Mockito.mock(ClassFile.class);
5151
doReturn(input.getArgument(0)).when(cf).getClassName(anyBoolean());
5252
return cf;

0 commit comments

Comments
 (0)