use of com.intellij.util.CollectConsumer in project intellij-community by JetBrains.
the class JsonSchemaConfigurable method doValidation.
private void doValidation() throws ConfigurationException {
final File file = new File(myProject.getBasePath(), myView.getSchemaSubPath());
VirtualFile vFile = null;
if (!file.exists() || (vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file)) == null) {
throw new ConfigurationException((!StringUtil.isEmptyOrSpaces(myDisplayName) ? (myDisplayName + ": ") : "") + "Schema file does not exist");
}
final String filename = file.getName();
if (StringUtil.isEmptyOrSpaces(myDisplayName))
throw new ConfigurationException(filename + ": Schema name is empty");
if (StringUtil.isEmptyOrSpaces(myView.getSchemaSubPath()))
throw new ConfigurationException(filename + ": Schema path is empty");
final CollectConsumer<String> collectConsumer = new CollectConsumer<>();
final JsonSchemaService service = JsonSchemaService.Impl.get(myProject);
if (service != null && !service.isSchemaFile(vFile, collectConsumer)) {
final String message;
if (collectConsumer.getResult().isEmpty())
message = filename + ": Can not read JSON schema from file (Unknown reason)";
else
message = filename + ": Can not read JSON schema from file: " + StringUtil.join(collectConsumer.getResult(), "; ");
logErrorForUser(message);
throw new RuntimeConfigurationWarning(message);
}
}
use of com.intellij.util.CollectConsumer in project intellij-community by JetBrains.
the class GrUnresolvedAccessChecker method shouldHighlightAsUnresolved.
private static boolean shouldHighlightAsUnresolved(@NotNull GrReferenceExpression referenceExpression) {
if (GrHighlightUtil.isDeclarationAssignment(referenceExpression))
return false;
GrExpression qualifier = referenceExpression.getQualifier();
if (qualifier != null && qualifier.getType() == null && !isRefToPackage(qualifier))
return false;
if (qualifier != null && referenceExpression.getDotTokenType() == GroovyTokenTypes.mMEMBER_POINTER && referenceExpression.multiResolve(false).length > 0) {
return false;
}
if (!GroovyUnresolvedHighlightFilter.shouldHighlight(referenceExpression))
return false;
CollectConsumer<PomTarget> consumer = new CollectConsumer<>();
for (PomDeclarationSearcher searcher : PomDeclarationSearcher.EP_NAME.getExtensions()) {
searcher.findDeclarationsAt(referenceExpression, 0, consumer);
if (!consumer.getResult().isEmpty())
return false;
}
return true;
}
use of com.intellij.util.CollectConsumer in project intellij-community by JetBrains.
the class GotoActionItemProvider method processTopHits.
private static boolean processTopHits(String pattern, Processor<MatchedValue> consumer, DataContext dataContext) {
Project project = CommonDataKeys.PROJECT.getData(dataContext);
final CollectConsumer<Object> collector = new CollectConsumer<>();
for (SearchTopHitProvider provider : SearchTopHitProvider.EP_NAME.getExtensions()) {
if (provider instanceof OptionsTopHitProvider.CoveredByToggleActions)
continue;
if (provider instanceof OptionsTopHitProvider && !((OptionsTopHitProvider) provider).isEnabled(project))
continue;
if (provider instanceof OptionsTopHitProvider && !StringUtil.startsWith(pattern, "#")) {
String prefix = "#" + ((OptionsTopHitProvider) provider).getId() + " ";
provider.consumeTopHits(prefix + pattern, collector, project);
}
provider.consumeTopHits(pattern, collector, project);
}
Collection<Object> result = collector.getResult();
return processItems(pattern, JBIterable.from(result).filter(Comparable.class), consumer);
}
Aggregations