当前位置: 首页>>代码示例>>Java>>正文


Java ProgressManager.checkCanceled方法代码示例

本文整理汇总了Java中com.intellij.openapi.progress.ProgressManager.checkCanceled方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressManager.checkCanceled方法的具体用法?Java ProgressManager.checkCanceled怎么用?Java ProgressManager.checkCanceled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.progress.ProgressManager的用法示例。


在下文中一共展示了ProgressManager.checkCanceled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execCancelable

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Nullable
public static <T> T execCancelable(@NotNull final Callable<T> callable) {
  final Future<T> future = ApplicationManager.getApplication().executeOnPooledThread(callable);

  while (!future.isCancelled() && !future.isDone()) {
    ProgressManager.checkCanceled();
    TimeoutUtil.sleep(500);
  }
  T result = null;
  try {
    result = future.get();
  }
  catch (InterruptedException | ExecutionException e) {
    LOG.warn(e.getMessage());
  }
  return result;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:18,代码来源:StudyUtils.java

示例2: processSameNamedClasses

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
private static boolean processSameNamedClasses(Processor<PsiClass> consumer, List<PsiClass> sameNamedClasses, final VirtualFile jarFile) {
  // if there is a class from the same jar, prefer it
  boolean sameJarClassFound = false;

  if (jarFile != null && sameNamedClasses.size() > 1) {
    for (PsiClass sameNamedClass : sameNamedClasses) {
      ProgressManager.checkCanceled();
      boolean fromSameJar = Comparing.equal(getJarFile(sameNamedClass), jarFile);
      if (fromSameJar) {
        sameJarClassFound = true;
        if (!consumer.process(sameNamedClass)) return false;
      }
    }
  }

  return sameJarClassFound || ContainerUtil.process(sameNamedClasses, consumer);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaDirectInheritorsSearcher.java

示例3: processTextOccurrence

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Override
public boolean processTextOccurrence(@NotNull PsiElement element, int offsetInElement, @NotNull final Processor<PsiReference> consumer) {
  if (!myTarget.isValid()) {
    return false;
  }

  final List<PsiReference> references = ourReferenceService.getReferences(element,
                                                                          new PsiReferenceService.Hints(myTarget, offsetInElement));
  //noinspection ForLoopReplaceableByForEach
  for (int i = 0; i < references.size(); i++) {
    PsiReference ref = references.get(i);
    ProgressManager.checkCanceled();
    if (ReferenceRange.containsOffsetInElement(ref, offsetInElement) && ref.isReferenceTo(myTarget) && !consumer.process(ref)) {
      return false;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SingleTargetRequestResultProcessor.java

示例4: visitDeclarationStatement

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Override
public void visitDeclarationStatement(PsiDeclarationStatement statement) {
  startElement(statement);
  int pc = myCurrentFlow.getSize();
  PsiElement[] elements = statement.getDeclaredElements();
  for (PsiElement element : elements) {
    ProgressManager.checkCanceled();
    if (element instanceof PsiClass) {
      element.accept(this);
    }
    else if (element instanceof PsiVariable) {
      processVariable((PsiVariable)element);
    }
  }
  if (pc == myCurrentFlow.getSize()) {
    // generate at least one instruction for declaration
    emitEmptyInstruction();
  }
  finishElement(statement);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ControlFlowAnalyzer.java

示例5: checkAccessStaticLevels

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
protected static void checkAccessStaticLevels(@NotNull List<CandidateInfo> conflicts, boolean checkAccessible) {
  int conflictsCount = conflicts.size();

  int maxCheckLevel = -1;
  int[] checkLevels = new int[conflictsCount];
  int index = 0;
  for (final CandidateInfo conflict : conflicts) {
    ProgressManager.checkCanceled();
    final MethodCandidateInfo method = (MethodCandidateInfo)conflict;
    final int level = checkAccessible ? getCheckAccessLevel(method) : getCheckStaticLevel(method);
    checkLevels[index++] = level;
    maxCheckLevel = Math.max(maxCheckLevel, level);
  }

  for (int i = conflictsCount - 1; i >= 0; i--) {
    // check for level
    if (checkLevels[i] < maxCheckLevel) {
      conflicts.remove(i);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaMethodsConflictResolver.java

示例6: visitResourceList

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Override
public void visitResourceList(final PsiResourceList resourceList) {
  startElement(resourceList);

  for (PsiResourceListElement resource : resourceList) {
    ProgressManager.checkCanceled();
    if (resource instanceof PsiResourceVariable) {
      processVariable((PsiVariable)resource);
    }
    else if (resource instanceof PsiResourceExpression) {
      ((PsiResourceExpression)resource).getExpression().accept(this);
    }
  }

  finishElement(resourceList);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ControlFlowAnalyzer.java

示例7: checkFile

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
  if (!(file instanceof PropertiesFile)) return null;
  final List<IProperty> properties = ((PropertiesFile)file).getProperties();
  final List<ProblemDescriptor> descriptors = new SmartList<ProblemDescriptor>();
  for (IProperty property : properties) {
    ProgressManager.checkCanceled();
    final PropertyImpl propertyImpl = (PropertyImpl)property;
    for (ASTNode node : ContainerUtil.ar(propertyImpl.getKeyNode(), propertyImpl.getValueNode())) {
      if (node != null) {
        PsiElement key = node.getPsi();
        TextRange textRange = getTrailingSpaces(key, myIgnoreVisibleSpaces);
        if (textRange != null) {
          descriptors.add(manager.createProblemDescriptor(key, textRange, "Trailing spaces", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true, new RemoveTrailingSpacesFix(myIgnoreVisibleSpaces)));
        }
      }
    }
  }
  return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TrailingSpacesInPropertyInspection.java

示例8: getEffectiveRetro

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
public static @Nullable SchemaEntityTagDecl getEffectiveRetro(@NotNull SchemaValueTypeRef valueTypeRef) {
  if (!canHaveRetro(valueTypeRef)) return null;

  SchemaEntityTagDecl defaultTag = getRetroTag(valueTypeRef);
  if (defaultTag != null) return defaultTag;

  SchemaFieldDecl fieldDecl = PsiTreeUtil.getParentOfType(valueTypeRef, SchemaFieldDecl.class);
  if (fieldDecl != null) {
    List<SchemaFieldDecl> overridenFields = getOverridenFields(fieldDecl);

    for (SchemaFieldDecl overridenField : overridenFields) {
      ProgressManager.checkCanceled();
      defaultTag = getRetroTag(overridenField.getValueTypeRef());
      if (defaultTag != null) return defaultTag;
    }
  }

  return null;
  // todo handle lists/maps?
}
 
开发者ID:SumoLogic,项目名称:epigraph,代码行数:21,代码来源:TypeMembers.java

示例9: addUsedVariables

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
private void addUsedVariables(@NotNull List<PsiVariable> array, @NotNull PsiElement scope) {
  if (scope instanceof PsiReferenceExpression) {
    PsiVariable variable = getUsedVariable((PsiReferenceExpression)scope);
    if (variable != null) {
      if (!array.contains(variable)) {
        array.add(variable);
      }
    }
  }

  PsiElement[] children = scope.getChildren();
  for (PsiElement child : children) {
    ProgressManager.checkCanceled();
    addUsedVariables(array, child);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ControlFlowAnalyzer.java

示例10: checkCanceled

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
void checkCanceled() {
    if (project.isOpen()) {
        // The project is closed if we are in test mode.
        // In tests we can't check if the user canceled the scan, since we don't have the ProgressManager service.
        ProgressManager.checkCanceled();
    }
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:8,代码来源:ScanManager.java

示例11: writeFileImpl

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
public static void writeFileImpl(String folder, @NonNls String fileName, CharSequence buf) throws IOException {
  ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  final String fullPath = folder + File.separator + fileName;

  if (indicator != null) {
    ProgressManager.checkCanceled();
    indicator.setText(InspectionsBundle.message("inspection.export.generating.html.for", fullPath));
  }

  FileWriter writer = null;
  try {
    File folderFile = new File(folder);
    folderFile.mkdirs();
    new File(fullPath).getParentFile().mkdirs();
    writer = new FileWriter(fullPath);
    writer.write(buf.toString().toCharArray());
  }
  finally {
    if (writer != null) {
      try {
        writer.close();
      }
      catch (IOException e) {
        //Cannot do anything in case of exception
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:HTMLExporter.java

示例12: convert

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
/**
 * Converts an equation over asm keys into equation over small hash keys.
 */
@NotNull
static DirectionResultPair convert(@NotNull Equation<Key, Value> equation, @NotNull MessageDigest md) {
  ProgressManager.checkCanceled();

  Result<Key, Value> rhs = equation.rhs;
  HResult hResult;
  if (rhs instanceof Final) {
    hResult = new HFinal(((Final<Key, Value>)rhs).value);
  }
  else {
    Pending<Key, Value> pending = (Pending<Key, Value>)rhs;
    Set<Product<Key, Value>> sumOrigin = pending.sum;
    HComponent[] components = new HComponent[sumOrigin.size()];
    int componentI = 0;
    for (Product<Key, Value> prod : sumOrigin) {
      HKey[] intProd = new HKey[prod.ids.size()];
      int idI = 0;
      for (Key key : prod.ids) {
        intProd[idI] = asmKey(key, md);
        idI++;
      }
      HComponent intIdComponent = new HComponent(prod.value, intProd);
      components[componentI] = intIdComponent;
      componentI++;
    }
    hResult = new HPending(components);
  }
  return new DirectionResultPair(mkDirectionKey(equation.id.direction), hResult);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:BytecodeAnalysisConverter.java

示例13: collectPatternMatches

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
private static boolean collectPatternMatches(IndexPattern indexPattern,
                                             CharSequence chars,
                                             int commentStart,
                                             int commentEnd,
                                             PsiFile file,
                                             TextRange range,
                                             Processor<IndexPatternOccurrence> consumer,
                                             TIntArrayList matches
                                             ) {
  Pattern pattern = indexPattern.getPattern();
  if (pattern != null) {
    ProgressManager.checkCanceled();

    CharSequence input = new CharSequenceSubSequence(chars, commentStart, commentEnd);
    Matcher matcher = pattern.matcher(input);
    while (true) {
      //long time1 = System.currentTimeMillis();
      boolean found = matcher.find();
      //long time2 = System.currentTimeMillis();
      //System.out.println("scanned text of length " + (lexer.getTokenEnd() - lexer.getTokenStart() + " in " + (time2 - time1) + " ms"));

      if (!found) break;
      int start = matcher.start() + commentStart;
      int end = matcher.end() + commentStart;
      if (start != end) {
        if ((range == null || range.getStartOffset() <= start && end <= range.getEndOffset()) && matches.indexOf(start) == -1) {
          matches.add(start);
          if (!consumer.process(new IndexPatternOccurrenceImpl(file, start, end, indexPattern))) {
            return false;
          }
        }
      }

      ProgressManager.checkCanceled();
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:IndexPatternSearcher.java

示例14: checkValidity

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
@Nullable
protected String checkValidity() {
  ProgressManager.checkCanceled();
  final DomParentStrategy parentStrategy = getParentStrategy();
  String error = parentStrategy.checkValidity();
  if (error != null) {
    return "Strategy: " + error;
  }

  final long modCount = myManager.getPsiModificationCount();
  if (myLastModCount == modCount) {
    return null;
  }

  final XmlElement xmlElement = parentStrategy.getXmlElement();
  if (xmlElement != null) {
    final DomInvocationHandler actual = myManager.getDomHandler(xmlElement);
    if (!equals(actual)) {
      return "element changed: " + this.toStringEx() + "!=" + (actual == null ? null : actual.toStringEx());
    }
    myLastModCount = modCount;
    return null;
  }

  final DomInvocationHandler parent = getParentHandler();
  if (parent == null) {
    return "no parent: " + getDomElementType();
  }

  error = parent.checkValidity();
  if (error != null) {
    return "parent: " + error;
  }

  myLastModCount = modCount;
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:DomInvocationHandler.java

示例15: acceptGroovyChildren

import com.intellij.openapi.progress.ProgressManager; //导入方法依赖的package包/类
public static void acceptGroovyChildren(PsiElement parent, GroovyElementVisitor visitor) {
  PsiElement child = parent.getFirstChild();
  while (child != null) {
    ProgressManager.checkCanceled();
    if (child instanceof GroovyPsiElement) {
      ((GroovyPsiElement) child).accept(visitor);
    }

    child = child.getNextSibling();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GroovyPsiElementImpl.java


注:本文中的com.intellij.openapi.progress.ProgressManager.checkCanceled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。