Search in sources :

Example 1 with CollectConsumer

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);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ConfigurationException(com.intellij.openapi.options.ConfigurationException) CollectConsumer(com.intellij.util.CollectConsumer) RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) JsonSchemaService(com.jetbrains.jsonSchema.ide.JsonSchemaService)

Example 2 with CollectConsumer

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;
}
Also used : PomTarget(com.intellij.pom.PomTarget) CollectConsumer(com.intellij.util.CollectConsumer) PomDeclarationSearcher(com.intellij.pom.PomDeclarationSearcher)

Example 3 with CollectConsumer

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);
}
Also used : Project(com.intellij.openapi.project.Project) CollectConsumer(com.intellij.util.CollectConsumer) OptionsTopHitProvider(com.intellij.ide.ui.OptionsTopHitProvider) SearchTopHitProvider(com.intellij.ide.SearchTopHitProvider)

Aggregations

CollectConsumer (com.intellij.util.CollectConsumer)3 RuntimeConfigurationWarning (com.intellij.execution.configurations.RuntimeConfigurationWarning)1 SearchTopHitProvider (com.intellij.ide.SearchTopHitProvider)1 OptionsTopHitProvider (com.intellij.ide.ui.OptionsTopHitProvider)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PomDeclarationSearcher (com.intellij.pom.PomDeclarationSearcher)1 PomTarget (com.intellij.pom.PomTarget)1 JsonSchemaService (com.jetbrains.jsonSchema.ide.JsonSchemaService)1 File (java.io.File)1