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


Java Stack.isEmpty方法代码示例

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


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

示例1: allOperandsAreLiterals

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
public static boolean allOperandsAreLiterals(@Nullable final PsiExpression expression) {
  if (expression == null) return false;
  if (expression instanceof PsiLiteralExpression) return true;
  if (expression instanceof PsiPolyadicExpression) {
    Stack<PsiExpression> stack = new Stack<PsiExpression>();
    stack.add(expression);
    while (!stack.isEmpty()) {
      PsiExpression psiExpression = stack.pop();
      if (psiExpression instanceof PsiPolyadicExpression) {
        PsiPolyadicExpression binaryExpression = (PsiPolyadicExpression)psiExpression;
        for (PsiExpression op : binaryExpression.getOperands()) {
          stack.push(op);
        }
      }
      else if (!(psiExpression instanceof PsiLiteralExpression)) {
        return false;
      }
    }
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DfaPsiUtil.java

示例2: calculateSiblingMethods

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
public static Set<PsiMethod> calculateSiblingMethods(PsiMethod method) {
    final Set<PsiMethod> siblingMethods = new HashSet<PsiMethod>();
    final Stack<PsiMethod> pendingMethods = new Stack<PsiMethod>();
    pendingMethods.add(method);
    while(!pendingMethods.isEmpty())
    {
        final PsiMethod methodToAnalyze = pendingMethods.pop();
        siblingMethods.add(methodToAnalyze);
      final Iterable<PsiMethod> overridingMethods = OverridingMethodsSearch.search(methodToAnalyze, false);
        for (PsiMethod overridingMethod : overridingMethods) {
            if (!siblingMethods.contains(overridingMethod) &&
                    !pendingMethods.contains(overridingMethod)) {
                pendingMethods.add(overridingMethod);
            }
        }
        final PsiMethod[] superMethods = methodToAnalyze.findSuperMethods();
        for (PsiMethod superMethod : superMethods) {
            if (!siblingMethods.contains(superMethod) &&
                    !pendingMethods.contains(superMethod)) {
                pendingMethods.add(superMethod);
            }
        }
    }
    return siblingMethods;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:MethodInheritanceUtils.java

示例3: visitPyParenthesizedExpression

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
@Override
public void visitPyParenthesizedExpression(final PyParenthesizedExpression expression) {
  final Stack<PsiElement> stack = new Stack<PsiElement>();
  stack.push(expression);
  while (!stack.isEmpty()) {
    PsiElement element = stack.pop();
    if (!(element instanceof PyTupleExpression)) {
      findProblem(element);
      if (element != null) {
        for (PsiElement psiElement : element.getChildren()) {
          stack.push(psiElement);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PyUnnecessaryBackslashInspection.java

示例4: isExceptionUsed

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
private static boolean isExceptionUsed(PyExceptPart node, String text) {
  Stack<PsiElement> stack = new Stack<PsiElement>();
  PyStatementList statementList = node.getStatementList();
  if (statementList != null) {
    for (PyStatement st : statementList.getStatements()) {
      stack.push(st);
      while (!stack.isEmpty()) {
        PsiElement e = stack.pop();
        if (e instanceof PyReferenceExpression) {
          PsiReference reference = e.getReference();
          if (reference != null) {
            PsiElement resolved = reference.resolve();
            if (resolved != null) {
              if (resolved.getText().equals(text))
                return true;
            }
          }
        }
        for (PsiElement psiElement : e.getChildren()) {
          stack.push(psiElement);
        }
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PyBroadExceptionInspection.java

示例5: removeBackSlash

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
public static void removeBackSlash(PsiElement parent) {
  if (parent != null) {
    Stack<PsiElement> stack = new Stack<PsiElement>();
    if (parent instanceof PyParenthesizedExpression)
      stack.push(((PyParenthesizedExpression)parent).getContainedExpression());
    else
      stack.push(parent);
    while (!stack.isEmpty()) {
      PsiElement el = stack.pop();
      PsiWhiteSpace[] children = PsiTreeUtil.getChildrenOfType(el, PsiWhiteSpace.class);
      if (children != null) {
        for (PsiWhiteSpace ws : children) {
          if (ws.getText().contains("\\")) {
            ws.delete();
          }
        }
      }
      for (PsiElement psiElement : el.getChildren()) {
        stack.push(psiElement);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RemoveUnnecessaryBackslashQuickFix.java

示例6: hasAssertOrYield

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
private static boolean hasAssertOrYield(PyStatementList list) {
  Stack<PsiElement> stack = new Stack<PsiElement>();
    if (list != null) {
      for (PyStatement st : list.getStatements()) {
        stack.push(st);
        while (!stack.isEmpty()) {
          PsiElement e = stack.pop();
          if (e instanceof PyAssertStatement || e instanceof PyYieldExpression) return true;
          for (PsiElement psiElement : e.getChildren()) {
            stack.push(psiElement);
          }
        }
      }
    }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PythonUnitTestUtil.java

示例7: fetch

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
@NotNull
@Override
protected List<RedmineProjectItem> fetch(@NotNull ProgressIndicator indicator) throws Exception {
  // Seems that Redmine always return its project hierarchy in DFS order.
  // So it's easy to find level of each project using stack of parents.
  Stack<RedmineProject> parents = new Stack<RedmineProject>();
  List<RedmineProjectItem> items = new ArrayList<RedmineProjectItem>();
  for (RedmineProject project : myRepository.fetchProjects()) {
    RedmineProject parentProject = project.getParent();
    if (parentProject == null) {
      items.add(new RedmineProjectItem(project, 0));
      parents.clear();
    }
    else {
      while (!parents.isEmpty() && !parents.peek().equals(parentProject)) {
        parents.pop();
      }
      items.add(new RedmineProjectItem(project, parents.size()));
    }
    parents.push(project);
  }
  return items;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:RedmineRepositoryEditor.java

示例8: ensureTheDataIsReadyToUse

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T> void ensureTheDataIsReadyToUse(@NotNull Collection<DataNode<T>> nodes) {
  Map<Key<?>, List<ProjectDataService<?, ?>>> servicesByKey = myServices.getValue();
  Stack<DataNode<T>> toProcess = ContainerUtil.newStack(nodes);
  while (!toProcess.isEmpty()) {
    DataNode<T> node = toProcess.pop();
    List<ProjectDataService<?, ?>> services = servicesByKey.get(node.getKey());
    if (services != null) {
      for (ProjectDataService<?, ?> service : services) {
        node.prepareData(service.getClass().getClassLoader());
      }
    }

    for (DataNode<?> dataNode : node.getChildren()) {
      toProcess.push((DataNode<T>)dataNode);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:ProjectDataManager.java

示例9: reevaluate

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
private boolean reevaluate(Project context) {
  this.context = context;
  boolean ret = false;
  if (isComplete()) {
    try {
      Stack<ASTNode> rpn = infixToRPN();
      String rpnString = LOG.isDebugEnabled() ? tokensToString(rpn) : null;
      ret = objectIsTrue(calculateRPN(rpn));
      if (LOG.isDebugEnabled()) {  // Don't create the strings unless we are debugging them...
        LOG.debug(toString() + " --> " + rpnString + " ==> " + (ret ? "true" : "false"));
      }
      if (!rpn.isEmpty()) {
        throw new CalculationException("Invalid Expression: Tokens left after calculating: " + rpn.toString());
      }
    } catch (CalculationException e) {
      String msg = "Error calculating conditional compiler expression '" + toString() + "'";
      // Add stack info if in debug mode.
      LOG.info( msg, LOG.isDebugEnabled() ? e : null );
    }
  }
  return ret;
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:23,代码来源:HaxeConditionalExpression.java

示例10: ensureTheDataIsReadyToUse

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T> void ensureTheDataIsReadyToUse(@Nonnull Collection<DataNode<T>> nodes) {
  Map<Key<?>, List<ProjectDataService<?, ?>>> servicesByKey = myServices.getValue();
  Stack<DataNode<T>> toProcess = ContainerUtil.newStack(nodes);
  while (!toProcess.isEmpty()) {
    DataNode<T> node = toProcess.pop();
    List<ProjectDataService<?, ?>> services = servicesByKey.get(node.getKey());
    if (services != null) {
      for (ProjectDataService<?, ?> service : services) {
        node.prepareData(service.getClass().getClassLoader());
      }
    }

    for (DataNode<?> dataNode : node.getChildren()) {
      toProcess.push((DataNode<T>)dataNode);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:ProjectDataManager.java

示例11: buildMethodDependencyInfo

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
@Nullable
private ArrangementEntryDependencyInfo buildMethodDependencyInfo(@NotNull final PsiMethod method,
                                                                 @NotNull Map<PsiMethod, ArrangementEntryDependencyInfo> cache) {
  JavaElementArrangementEntry entry = myMethodEntriesMap.get(method);
  if (entry == null) {
    return null;
  }
  ArrangementEntryDependencyInfo result = new ArrangementEntryDependencyInfo(entry);
  Stack<Pair<PsiMethod, ArrangementEntryDependencyInfo>> toProcess
    = new Stack<Pair<PsiMethod, ArrangementEntryDependencyInfo>>();
  toProcess.push(Pair.create(method, result));
  Set<PsiMethod> usedMethods = ContainerUtilRt.newHashSet();
  while (!toProcess.isEmpty()) {
    Pair<PsiMethod, ArrangementEntryDependencyInfo> pair = toProcess.pop();
    Set<PsiMethod> dependentMethods = myMethodDependencies.get(pair.first);
    if (dependentMethods == null) {
      continue;
    }
    usedMethods.add(pair.first);
    for (PsiMethod dependentMethod : dependentMethods) {
      if (usedMethods.contains(dependentMethod)) {
        // Prevent cyclic dependencies.
        return null;
      }
      JavaElementArrangementEntry dependentEntry = myMethodEntriesMap.get(dependentMethod);
      if (dependentEntry == null) {
        continue;
      }
      ArrangementEntryDependencyInfo dependentMethodInfo = cache.get(dependentMethod);
      if (dependentMethodInfo == null) {
        cache.put(dependentMethod, dependentMethodInfo = new ArrangementEntryDependencyInfo(dependentEntry));
      }
      Pair<PsiMethod, ArrangementEntryDependencyInfo> dependentPair = Pair.create(dependentMethod, dependentMethodInfo);
      pair.second.addDependentEntryInfo(dependentPair.second);
      toProcess.push(dependentPair);
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:JavaArrangementParseInfo.java

示例12: buildStubTreeFor

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
@NotNull
protected StubElement buildStubTreeFor(@NotNull ASTNode root, @NotNull StubElement parentStub) {
  Stack<StubElement> parentStubs = new Stack<StubElement>();
  Stack<ASTNode> parentNodes = new Stack<ASTNode>();
  parentNodes.push(root);
  parentStubs.push(parentStub);

  while (!parentStubs.isEmpty()) {
    StubElement stub = parentStubs.pop();
    ASTNode node = parentNodes.pop();
    IElementType nodeType = node.getElementType();

    if (nodeType instanceof IStubElementType) {
      final IStubElementType type = (IStubElementType)nodeType;

      if (type.shouldCreateStub(node)) {
        PsiElement element = node.getPsi();
        if (!(element instanceof StubBasedPsiElement)) {
          LOG.error("Non-StubBasedPsiElement requests stub creation. Stub type: " + type + ", PSI: " + element);
        }
        @SuppressWarnings("unchecked") StubElement s = type.createStub(element, stub);
        stub = s;
        LOG.assertTrue(stub != null, element);
      }
    }

    for (ASTNode childNode = node.getLastChildNode(); childNode != null; childNode = childNode.getTreePrev()) {
      if (!skipChildProcessingWhenBuildingStubs(node, childNode)) {
        parentNodes.push(childNode);
        parentStubs.push(stub);
      }
    }
  }

  return parentStub;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:DefaultStubBuilder.java

示例13: findLeftmostLParen

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
public static int findLeftmostLParen(HighlighterIterator iterator,
                                     IElementType lparenTokenType,
                                     CharSequence fileText,
                                     FileType fileType) {
  int lastLbraceOffset = -1;

  Stack<IElementType> braceStack = new Stack<IElementType>();
  for (; !iterator.atEnd(); iterator.retreat()) {
    final IElementType tokenType = iterator.getTokenType();

    if (isLBraceToken(iterator, fileText, fileType)) {
      if (!braceStack.isEmpty()) {
        IElementType topToken = braceStack.pop();
        if (!isPairBraces(tokenType, topToken, fileType)) {
          break; // unmatched braces
        }
      }
      else {
        if (tokenType == lparenTokenType) {
          lastLbraceOffset = iterator.getStart();
        }
        else {
          break;
        }
      }
    }
    else if (isRBraceToken(iterator, fileText, fileType)) {
      braceStack.push(iterator.getTokenType());
    }
  }

  return lastLbraceOffset;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:BraceMatchingUtil.java

示例14: findLeftLParen

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
public static int findLeftLParen(HighlighterIterator iterator,
                                     IElementType lparenTokenType,
                                     CharSequence fileText,
                                     FileType fileType) {
  int lastLbraceOffset = -1;

  Stack<IElementType> braceStack = new Stack<IElementType>();
  for (; !iterator.atEnd(); iterator.retreat()) {
    final IElementType tokenType = iterator.getTokenType();

    if (isLBraceToken(iterator, fileText, fileType)) {
      if (!braceStack.isEmpty()) {
        IElementType topToken = braceStack.pop();
        if (!isPairBraces(tokenType, topToken, fileType)) {
          break; // unmatched braces
        }
      }
      else {
        if (tokenType == lparenTokenType) {
          return iterator.getStart();
        }
        else {
          break;
        }
      }
    }
    else if (isRBraceToken(iterator, fileText, fileType)) {
      braceStack.push(iterator.getTokenType());
    }
  }

  return lastLbraceOffset;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:BraceMatchingUtil.java

示例15: findRightmostRParen

import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
public static int findRightmostRParen(HighlighterIterator iterator,
                                      IElementType rparenTokenType,
                                      CharSequence fileText,
                                      FileType fileType) {
  int lastRbraceOffset = -1;

  Stack<IElementType> braceStack = new Stack<IElementType>();
  for (; !iterator.atEnd(); iterator.advance()) {
    final IElementType tokenType = iterator.getTokenType();

    if (isRBraceToken(iterator, fileText, fileType)) {
      if (!braceStack.isEmpty()) {
        IElementType topToken = braceStack.pop();
        if (!isPairBraces(tokenType, topToken, fileType)) {
          break; // unmatched braces
        }
      }
      else {
        if (tokenType == rparenTokenType) {
          lastRbraceOffset = iterator.getStart();
        }
        else {
          break;
        }
      }
    }
    else if (isLBraceToken(iterator, fileText, fileType)) {
      braceStack.push(iterator.getTokenType());
    }
  }

  return lastRbraceOffset;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:BraceMatchingUtil.java


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