Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed keystroke delay (#26) #201

Merged
merged 2 commits into from
Oct 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public class JDTUtils {
private static Set<String> SILENCED_CODEGENS = Collections.singleton("lombok");

public static final String DEFAULT_PROJECT_NAME = "jdt.java-project";

private static final int COMPILATION_UNIT_UPDATE_TIMEOUT = 3000;

/**
* Given the uri returns a {@link ICompilationUnit}. May return null if it can
Expand Down Expand Up @@ -117,7 +119,14 @@ public static ICompilationUnit resolveCompilationUnit(URI uri) {
if (resource.getFileExtension() != null) {
String name = resource.getName();
if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(name)) {
return JavaCore.createCompilationUnitFrom(resource);
ICompilationUnit unit = JavaCore.createCompilationUnitFrom(resource);
try {
// Give underlying resource time to catch up
// (timeout at COMPILATION_UNIT_UPDATE_TIMEOUT milliseconds).
long endTime = System.currentTimeMillis() + COMPILATION_UNIT_UPDATE_TIMEOUT;
while (!unit.isConsistent() && System.currentTimeMillis() < endTime) { }
} catch (JavaModelException e) { }
return unit;
}
}
return null;
Expand Down