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());
}
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;
}
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);
}
}
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);
}
}
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);
}
}
Aggregations