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


Java Stack类代码示例

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


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

示例1: DfaMemoryStateImpl

import com.intellij.util.containers.Stack; //导入依赖的package包/类
protected DfaMemoryStateImpl(DfaMemoryStateImpl toCopy) {
  myFactory = toCopy.myFactory;
  myEphemeral = toCopy.myEphemeral;
  myDefaultVariableStates = toCopy.myDefaultVariableStates; // shared between all states
  
  myStack = new Stack<DfaValue>(toCopy.myStack);
  myDistinctClasses = new TLongHashSet(toCopy.myDistinctClasses.toArray());
  myUnknownVariables = ContainerUtil.newLinkedHashSet(toCopy.myUnknownVariables);

  myEqClasses = ContainerUtil.newArrayList(toCopy.myEqClasses);
  myIdToEqClassesIndices = new MyIdMap(toCopy.myIdToEqClassesIndices.size());
  toCopy.myIdToEqClassesIndices.forEachEntry(new TIntObjectProcedure<int[]>() {
    @Override
    public boolean execute(int id, int[] set) {
      myIdToEqClassesIndices.put(id, set);
      return true;
    }
  });
  myVariableStates = ContainerUtil.newLinkedHashMap(toCopy.myVariableStates);
  
  myCachedDistinctClassPairs = toCopy.myCachedDistinctClassPairs;
  myCachedNonTrivialEqClasses = toCopy.myCachedNonTrivialEqClasses;
  myCachedHash = toCopy.myCachedHash;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:DfaMemoryStateImpl.java

示例2: buildControlFlow

import com.intellij.util.containers.Stack; //导入依赖的package包/类
@Nullable
public ControlFlow buildControlFlow() {
  myCatchStack = new Stack<CatchDescriptor>();
  myCurrentFlow = new ControlFlow(myFactory);
  try {
    myCodeFragment.accept(this);
  }
  catch (CannotAnalyzeException e) {
    return null;
  }

  PsiElement parent = myCodeFragment.getParent();
  if (parent instanceof PsiLambdaExpression && myCodeFragment instanceof PsiExpression) {
    generateBoxingUnboxingInstructionFor((PsiExpression)myCodeFragment,
                                         LambdaUtil.getFunctionalInterfaceReturnType((PsiLambdaExpression)parent));
    addInstruction(new CheckReturnValueInstruction(myCodeFragment));
  }

  addInstruction(new ReturnInstruction(false, null));

  if (Registry.is("idea.dfa.live.variables.analysis")) {
    new LiveVariablesAnalyzer(myCurrentFlow, myFactory).flushDeadVariablesOnStatementFinish();
  }

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

示例3: 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

示例4: 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

示例5: initStateFrom

import com.intellij.util.containers.Stack; //导入依赖的package包/类
@Override
public synchronized void initStateFrom(@NotNull final ProgressIndicator indicator) {
  myRunning = indicator.isRunning();
  myCanceled = indicator.isCanceled();
  myFraction = indicator.getFraction();
  myIndeterminate = indicator.isIndeterminate();
  myText = indicator.getText();

  myText2 = indicator.getText2();

  myFraction = indicator.getFraction();

  if (indicator instanceof ProgressIndicatorStacked) {
    ProgressIndicatorStacked stacked = (ProgressIndicatorStacked)indicator;

    myNonCancelableCount = stacked.getNonCancelableCount();

    myTextStack = new Stack<String>(stacked.getTextStack());

    myText2Stack = new Stack<String>(stacked.getText2Stack());

    myFractionStack = new DoubleArrayList(stacked.getFractionStack());
  }
  myShouldStartActivity = false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AbstractProgressIndicatorBase.java

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: initStateFrom

import com.intellij.util.containers.Stack; //导入依赖的package包/类
@Override
public synchronized void initStateFrom(@NotNull final ProgressIndicator indicator) {
  myRunning = indicator.isRunning();
  myCanceled = indicator.isCanceled();
  myFraction = indicator.getFraction();
  myIndeterminate = indicator.isIndeterminate();
  myText = indicator.getText();

  myText2 = indicator.getText2();

  myFraction = indicator.getFraction();

  if (indicator instanceof ProgressIndicatorStacked) {
    ProgressIndicatorStacked stacked = (ProgressIndicatorStacked)indicator;

    myNonCancelableCount = stacked.getNonCancelableCount();

    myTextStack = new Stack<String>(stacked.getTextStack());

    myText2Stack = new Stack<String>(stacked.getText2Stack());

    myFractionStack = new DoubleArrayList(stacked.getFractionStack());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:AbstractProgressIndicatorBase.java

示例13: 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

示例14: 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

示例15: enterModal

import com.intellij.util.containers.Stack; //导入依赖的package包/类
public static void enterModal(Project project, Dialog dialog) {
  LOG.assertTrue(isDispatchThread(), "enterModal() should be invoked in event-dispatch thread");

  if (LOG.isDebugEnabled()) {
    LOG.debug("enterModal:" + dialog.getName() + " ; for project: " + project.getName());
  }

  if (project == null) {
    enterModal(dialog);
    return;
  }

  ourModalityStateMulticaster.getMulticaster().beforeModalityStateChanged(true);

  List<Dialog> modalEntitiesList = projectToModalEntities.getOrDefault(project, ContainerUtil.createLockFreeCopyOnWriteList());
  projectToModalEntities.put(project, modalEntitiesList);
  modalEntitiesList.add(dialog);

  Stack<ModalityState> modalEntitiesStack = projectToModalEntitiesStack.getOrDefault(project, new Stack<>(ModalityState.NON_MODAL));
  projectToModalEntitiesStack.put(project, modalEntitiesStack);
  modalEntitiesStack.push(new ModalityStateEx(ArrayUtil.toObjectArray(ourModalEntities)));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:LaterInvocator.java


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