Search in sources :

Example 6 with ProcessCanceledException

use of com.intellij.openapi.progress.ProcessCanceledException in project intellij-community by JetBrains.

the class SvnProtocolsTest method testHistoryImpl.

private void testHistoryImpl(String s) throws VcsException {
    final VcsHistoryProvider provider = myVcs.getVcsHistoryProvider();
    final VcsAppendableHistoryPartnerAdapter partner = new VcsAppendableHistoryPartnerAdapter() {

        @Override
        public void acceptRevision(VcsFileRevision revision) {
            super.acceptRevision(revision);
            if (getSession().getRevisionList().size() > 1) {
                throw new ProcessCanceledException();
            }
        }
    };
    try {
        provider.reportAppendableHistory(VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(s, true), partner);
    } catch (ProcessCanceledException e) {
    //ok
    }
    final List<VcsFileRevision> list = partner.getSession().getRevisionList();
    Assert.assertTrue(!list.isEmpty());
}
Also used : VcsHistoryProvider(com.intellij.openapi.vcs.history.VcsHistoryProvider) VcsAppendableHistoryPartnerAdapter(com.intellij.openapi.vcs.history.VcsAppendableHistoryPartnerAdapter) VcsFileRevision(com.intellij.openapi.vcs.history.VcsFileRevision) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 7 with ProcessCanceledException

use of com.intellij.openapi.progress.ProcessCanceledException in project intellij-community by JetBrains.

the class FormMergerTreeStructureProvider method modify.

@NotNull
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
    if (parent.getValue() instanceof Form)
        return children;
    // Optimization. Check if there are any forms at all.
    boolean formsFound = false;
    for (AbstractTreeNode node : children) {
        if (node.getValue() instanceof PsiFile) {
            PsiFile file = (PsiFile) node.getValue();
            if (file.getFileType() == StdFileTypes.GUI_DESIGNER_FORM) {
                formsFound = true;
                break;
            }
        }
    }
    if (!formsFound)
        return children;
    Collection<AbstractTreeNode> result = new LinkedHashSet<>(children);
    ProjectViewNode[] copy = children.toArray(new ProjectViewNode[children.size()]);
    for (ProjectViewNode element : copy) {
        PsiClass psiClass = null;
        if (element.getValue() instanceof PsiClass) {
            psiClass = (PsiClass) element.getValue();
        } else if (element.getValue() instanceof PsiClassOwner) {
            final PsiClass[] psiClasses = ((PsiClassOwner) element.getValue()).getClasses();
            if (psiClasses.length == 1) {
                psiClass = psiClasses[0];
            }
        }
        if (psiClass == null)
            continue;
        String qName = psiClass.getQualifiedName();
        if (qName == null)
            continue;
        List<PsiFile> forms;
        try {
            forms = FormClassIndex.findFormsBoundToClass(myProject, qName);
        } catch (ProcessCanceledException e) {
            continue;
        }
        Collection<BasePsiNode<? extends PsiElement>> formNodes = findFormsIn(children, forms);
        if (!formNodes.isEmpty()) {
            Collection<PsiFile> formFiles = convertToFiles(formNodes);
            Collection<BasePsiNode<? extends PsiElement>> subNodes = new ArrayList<>();
            //noinspection unchecked
            subNodes.add((BasePsiNode<? extends PsiElement>) element);
            subNodes.addAll(formNodes);
            result.add(new FormNode(myProject, new Form(psiClass, formFiles), settings, subNodes));
            result.remove(element);
            result.removeAll(formNodes);
        }
    }
    return result;
}
Also used : AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) BasePsiNode(com.intellij.ide.projectView.impl.nodes.BasePsiNode) ProjectViewNode(com.intellij.ide.projectView.ProjectViewNode) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with ProcessCanceledException

use of com.intellij.openapi.progress.ProcessCanceledException in project intellij-community by JetBrains.

the class XmlInstanceValidator method doValidation.

public static void doValidation(@NotNull final XmlDocument doc, final Validator.ValidationHost host, final XmlFile descriptorFile) {
    try {
        final Schema schema = RngParser.getCachedSchema(descriptorFile);
        if (schema == null) {
            // did not manage to get a compiled schema. no validation...
            return;
        }
        final ErrorHandler eh = MyErrorHandler.create(doc, host);
        if (eh == null) {
            return;
        }
        final PropertyMapBuilder builder = new PropertyMapBuilder();
        builder.put(ValidateProperty.ERROR_HANDLER, eh);
        final ContentHandler handler = schema.createValidator(builder.toPropertyMap()).getContentHandler();
        doc.accept(new Psi2SaxAdapter(handler));
    } catch (ProcessCanceledException e) {
        throw e;
    } catch (RuntimeException e) {
        LOG.error(e);
    } catch (Exception e) {
        LOG.info(e);
    }
}
Also used : ErrorHandler(org.xml.sax.ErrorHandler) Schema(com.thaiopensource.validate.Schema) PropertyMapBuilder(com.thaiopensource.util.PropertyMapBuilder) ContentHandler(org.xml.sax.ContentHandler) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) SAXParseException(org.xml.sax.SAXParseException) SAXException(org.xml.sax.SAXException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 9 with ProcessCanceledException

use of com.intellij.openapi.progress.ProcessCanceledException in project kotlin by JetBrains.

the class ExpressionCodegen method genQualified.

private StackValue genQualified(StackValue receiver, KtElement selector, KtVisitor<StackValue, StackValue> visitor) {
    if (tempVariables.containsKey(selector)) {
        throw new IllegalStateException("Inconsistent state: expression saved to a temporary variable is a selector");
    }
    if (!(selector instanceof KtBlockExpression)) {
        markStartLineNumber(selector);
    }
    try {
        if (selector instanceof KtExpression) {
            StackValue samValue = genSamInterfaceValue((KtExpression) selector, visitor);
            if (samValue != null) {
                return samValue;
            }
        }
        StackValue stackValue = selector.accept(visitor, receiver);
        RuntimeAssertionInfo runtimeAssertionInfo = null;
        if (selector instanceof KtExpression) {
            runtimeAssertionInfo = bindingContext.get(JvmBindingContextSlices.RUNTIME_ASSERTION_INFO, (KtExpression) selector);
        }
        if (BuiltinSpecialBridgesKt.isValueArgumentForCallToMethodWithTypeCheckBarrier(selector, bindingContext))
            return stackValue;
        return genNotNullAssertions(state, stackValue, runtimeAssertionInfo);
    } catch (ProcessCanceledException e) {
        throw e;
    } catch (CompilationException e) {
        throw e;
    } catch (Throwable error) {
        String message = error.getMessage();
        throw new CompilationException(message != null ? message : "null", error, selector);
    }
}
Also used : RuntimeAssertionInfo(org.jetbrains.kotlin.resolve.jvm.RuntimeAssertionInfo) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 10 with ProcessCanceledException

use of com.intellij.openapi.progress.ProcessCanceledException in project intellij-community by JetBrains.

the class BaseSplitter method excludeByPattern.

@NotNull
protected static List<TextRange> excludeByPattern(String text, TextRange range, @NotNull Pattern toExclude, int groupToInclude) {
    List<TextRange> toCheck = new SmartList<>();
    int from = range.getStartOffset();
    int till;
    boolean addLast = true;
    Matcher matcher = toExclude.matcher(StringUtil.newBombedCharSequence(range.substring(text), 500));
    try {
        while (matcher.find()) {
            checkCancelled();
            TextRange found = matcherRange(range, matcher);
            till = found.getStartOffset();
            if (range.getEndOffset() - found.getEndOffset() < MIN_RANGE_LENGTH) {
                addLast = false;
            }
            if (!badSize(from, till)) {
                toCheck.add(new TextRange(from, till));
            }
            if (groupToInclude > 0) {
                TextRange contentFound = matcherRange(range, matcher, groupToInclude);
                if (badSize(contentFound.getEndOffset(), contentFound.getStartOffset())) {
                    toCheck.add(TextRange.create(contentFound));
                }
            }
            from = found.getEndOffset();
        }
        till = range.getEndOffset();
        if (badSize(from, till)) {
            return toCheck;
        }
        if (addLast) {
            toCheck.add(new TextRange(from, till));
        }
        return toCheck;
    } catch (ProcessCanceledException e) {
        return Collections.singletonList(range);
    }
}
Also used : Matcher(java.util.regex.Matcher) TextRange(com.intellij.openapi.util.TextRange) SmartList(com.intellij.util.SmartList) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)175 NotNull (org.jetbrains.annotations.NotNull)45 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)41 VirtualFile (com.intellij.openapi.vfs.VirtualFile)38 Project (com.intellij.openapi.project.Project)28 Nullable (org.jetbrains.annotations.Nullable)23 IOException (java.io.IOException)20 Task (com.intellij.openapi.progress.Task)16 File (java.io.File)16 Document (com.intellij.openapi.editor.Document)14 Ref (com.intellij.openapi.util.Ref)13 PsiFile (com.intellij.psi.PsiFile)12 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)11 Logger (com.intellij.openapi.diagnostic.Logger)10 StringUtil (com.intellij.openapi.util.text.StringUtil)9 ContainerUtil (com.intellij.util.containers.ContainerUtil)9 ArrayList (java.util.ArrayList)9 NonNls (org.jetbrains.annotations.NonNls)9 ProgressManager (com.intellij.openapi.progress.ProgressManager)8 java.util (java.util)8