本文整理汇总了Java中com.intellij.util.containers.Stack.push方法的典型用法代码示例。如果您正苦于以下问题:Java Stack.push方法的具体用法?Java Stack.push怎么用?Java Stack.push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.containers.Stack
的用法示例。
在下文中一共展示了Stack.push方法的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;
}
示例2: 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;
}
示例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);
}
}
}
}
}
示例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;
}
示例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);
}
}
}
}
示例6: 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);
}
}
}
示例7: 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);
}
}
}
示例8: 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)));
}
示例9: isCalledOnlyFrom
import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
private boolean isCalledOnlyFrom(RefJavaElement refElement, Stack<RefJavaElement> callStack) {
if (callStack.contains(this)) return refElement == this;
if (getInReferences().isEmpty()) return false;
if (refElement instanceof RefMethod) {
RefMethod refMethod = (RefMethod) refElement;
for (RefMethod refSuper : refMethod.getSuperMethods()) {
if (!refSuper.getInReferences().isEmpty()) return false;
}
if (refMethod.isConstructor()){
boolean unreachable = true;
for (RefElement refOut : refMethod.getOutReferences()){
unreachable &= !refOut.isReachable();
}
if (unreachable) return true;
}
}
callStack.push(this);
for (RefElement refCaller : getInReferences()) {
if (!((RefElementImpl)refCaller).isSuspicious() || !((RefJavaElementImpl)refCaller).isCalledOnlyFrom(refElement, callStack)) {
callStack.pop();
return false;
}
}
callStack.pop();
return true;
}
示例10: processAllSuperTypes
import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
public static void processAllSuperTypes(@NotNull PsiType type, @NotNull PsiTypeVisitor<PsiType> visitor, @NotNull Project project, @NotNull Set<PsiType> set) {
if (type instanceof PsiPrimitiveType) {
if (type.equals(PsiType.BOOLEAN) || type.equals(PsiType.VOID) || type.equals(PsiType.NULL)) return;
Stack<PsiType> stack = new Stack<PsiType>();
for (int i = PRIMITIVE_TYPES.length - 1; !PRIMITIVE_TYPES[i].equals(type); i--) {
stack.push(PRIMITIVE_TYPES[i]);
}
while(!stack.empty()) {
processType(stack.pop(), visitor, set);
}
}
else{
PsiManager manager = PsiManager.getInstance(project);
GlobalSearchScope resolveScope = type.getResolveScope();
if (resolveScope == null) resolveScope = GlobalSearchScope.allScope(project);
PsiClassType objectType = PsiType.getJavaLangObject(manager, resolveScope);
processType(objectType, visitor, set);
if (type instanceof PsiClassType) {
PsiType[] superTypes = type.getSuperTypes();
for (PsiType superType : superTypes) {
processType(superType, visitor, set);
processAllSuperTypes(superType, visitor, project, set);
}
}
}
}
示例11: visit
import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
public static void visit(@Nullable DataNode node, @NotNull Consumer<DataNode<?>> consumer) {
if(node == null) return;
Stack<DataNode> toProcess = ContainerUtil.newStack(node);
while (!toProcess.isEmpty()) {
DataNode<?> node0 = toProcess.pop();
consumer.consume(node0);
for (DataNode<?> child : node0.getChildren()) {
toProcess.push(child);
}
}
}
示例12: 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;
}
示例13: 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;
}
示例14: 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;
}
示例15: fillSubscriptions
import com.intellij.util.containers.Stack; //导入方法依赖的package包/类
/**
* finds subscriptions of keyword container, adds them to mySubscriptions
* @param function
*/
private static List<PySubscriptionExpression> fillSubscriptions(PyFunction function) {
List<PySubscriptionExpression> subscriptions = new ArrayList<PySubscriptionExpression>();
PyStatementList statementList = function.getStatementList();
Stack<PsiElement> stack = new Stack<PsiElement>();
PyParameter keywordContainer = getKeywordContainer(function);
if (keywordContainer != null) {
String keywordContainerName = keywordContainer.getName();
for (PyStatement st : statementList.getStatements()) {
stack.push(st);
while (!stack.isEmpty()) {
PsiElement e = stack.pop();
if (e instanceof PySubscriptionExpression) {
if (((PySubscriptionExpression)e).getOperand().getText().equals(keywordContainerName)) {
subscriptions.add((PySubscriptionExpression)e);
}
}
else {
for (PsiElement psiElement : e.getChildren()) {
stack.push(psiElement);
}
}
}
}
}
return subscriptions;
}