use of com.google.dart.server.generated.AnalysisServer in project intellij-plugins by JetBrains.
the class DartAnalysisServerService method analysis_getHover.
@NotNull
public List<HoverInformation> analysis_getHover(@NotNull final VirtualFile file, final int _offset) {
final String filePath = FileUtil.toSystemDependentName(file.getPath());
final List<HoverInformation> result = Lists.newArrayList();
final AnalysisServer server = myServer;
if (server == null) {
return HoverInformation.EMPTY_LIST;
}
final CountDownLatch latch = new CountDownLatch(1);
final int offset = getOriginalOffset(file, _offset);
server.analysis_getHover(filePath, offset, new GetHoverConsumer() {
@Override
public void computedHovers(HoverInformation[] hovers) {
Collections.addAll(result, hovers);
latch.countDown();
}
@Override
public void onError(RequestError error) {
logError("analysis_getHover()", filePath, error);
latch.countDown();
}
});
awaitForLatchCheckingCanceled(server, latch, GET_HOVER_TIMEOUT);
return result;
}
use of com.google.dart.server.generated.AnalysisServer in project intellij-plugins by JetBrains.
the class DartAnalysisServerService method edit_organizeDirectives.
@Nullable
public SourceFileEdit edit_organizeDirectives(@NotNull final String _filePath) {
final String filePath = FileUtil.toSystemDependentName(_filePath);
final Ref<SourceFileEdit> resultRef = new Ref<>();
final AnalysisServer server = myServer;
if (server == null)
return null;
final CountDownLatch latch = new CountDownLatch(1);
server.edit_organizeDirectives(filePath, new OrganizeDirectivesConsumer() {
@Override
public void computedEdit(final SourceFileEdit edit) {
resultRef.set(edit);
latch.countDown();
}
@Override
public void onError(final RequestError error) {
if (RequestErrorCode.FILE_NOT_ANALYZED.equals(error.getCode()) || RequestErrorCode.ORGANIZE_DIRECTIVES_ERROR.equals(error.getCode())) {
LOG.info(getShortErrorMessage("edit_organizeDirectives()", filePath, error));
} else {
logError("edit_organizeDirectives()", filePath, error);
}
latch.countDown();
}
});
awaitForLatchCheckingCanceled(server, latch, EDIT_ORGANIZE_DIRECTIVES_TIMEOUT);
if (latch.getCount() > 0) {
LOG.info("edit_organizeDirectives() took too long for file " + filePath);
}
return resultRef.get();
}
use of com.google.dart.server.generated.AnalysisServer in project intellij-plugins by JetBrains.
the class DartAnalysisServerService method updateRoots.
public boolean updateRoots(@NotNull final List<String> includedRoots, @NotNull final List<String> excludedRoots) {
AnalysisServer server = myServer;
if (server == null) {
return false;
}
if (LOG.isDebugEnabled()) {
LOG.debug("analysis_setAnalysisRoots, included:\n" + StringUtil.join(includedRoots, ",\n") + "\nexcluded:\n" + StringUtil.join(excludedRoots, ",\n"));
}
server.analysis_setAnalysisRoots(includedRoots, excludedRoots, null);
return true;
}
use of com.google.dart.server.generated.AnalysisServer in project intellij-plugins by JetBrains.
the class DartAnalysisServerService method waitForAnalysisToComplete_TESTS_ONLY.
public void waitForAnalysisToComplete_TESTS_ONLY(@NotNull final VirtualFile file) {
assert ApplicationManager.getApplication().isUnitTestMode();
final AnalysisServer server = myServer;
if (server == null)
return;
final CountDownLatch latch = new CountDownLatch(1);
server.analysis_getErrors(FileUtil.toSystemDependentName(file.getPath()), new GetErrorsConsumer() {
@Override
public void computedErrors(AnalysisError[] errors) {
latch.countDown();
}
@Override
public void onError(RequestError requestError) {
latch.countDown();
LOG.error(requestError.getMessage());
}
});
awaitForLatchCheckingCanceled(server, latch, ANALYSIS_IN_TESTS_TIMEOUT / TESTS_TIMEOUT_COEFF);
assert latch.getCount() == 0 : "Analysis did't complete in " + ANALYSIS_IN_TESTS_TIMEOUT + "ms.";
}
Aggregations