@Nullable
 private InstructionImpl findInstruction(PsiElement element) {
   final Iterator<InstructionImpl> iterator = myProcessingStack.descendingIterator();
   while (iterator.hasNext()) {
     final InstructionImpl instruction = iterator.next();
     if (element.equals(instruction.getElement())) return instruction;
   }
   return null;
 }
예제 #2
0
 /**
  * @param path path to first element
  * @param pathTo path to second element
  * @return environment in which the generic parameters in the path to the first element are bound
  *     to those in the path to the second element, or null type on error
  */
 public static ResolvedName mapGenericParameters(
     final Deque<? extends INamedElement> path, final Deque<? extends INamedElement> pathTo) {
   // Construct an environment in which the current function's generic parameters
   // are bound to those of the eventual override.
   final Deque<List<? extends ResolvedName>> tableau =
       new LinkedList<>(ResolvedName.fromNamedElement(path.getLast()).tableau());
   final Iterator<? extends INamedElement> pathIt = path.descendingIterator();
   while (pathIt.hasNext()) {
     pathIt.next();
     tableau.removeLast();
   }
   CachedIterator<? extends INamedElement> itPathTo = null;
   CachedIterator<? extends IGenericParameter> itGPTo = null;
   boolean end = false;
   {
     // Initialise iterators into direct override's generic parameters.
     boolean foundValid = false;
     itPathTo = Iterators.cached(pathTo.iterator());
     while (!foundValid && itPathTo.hasItem()) {
       itGPTo = Iterators.cached(itPathTo.item().genericParameters().iterator());
       while (!foundValid && itGPTo.hasItem()) {
         foundValid = true;
         if (!foundValid) itGPTo.next();
       }
       if (!foundValid) itPathTo.next();
     }
     if (!foundValid) end = true;
   }
   for (final INamedElement elt : path) {
     final List<ResolvedName> row = new ArrayList<>();
     for (@SuppressWarnings("unused")
     final IGenericParameter genericParameter : elt.genericParameters()) {
       if (end) return null;
       row.add(ResolvedName.fromNamedElement(itGPTo.item()));
       {
         // Increment iterators into direct override's generic parameters.
         boolean init = true;
         boolean foundValid = false;
         if (!init) itPathTo = Iterators.cached(pathTo.iterator());
         while (!foundValid && itPathTo.hasItem()) {
           if (!init) itGPTo = Iterators.cached(itPathTo.item().genericParameters().iterator());
           while (!foundValid && itGPTo.hasItem()) {
             if (!init) foundValid = true;
             init = false;
             if (!foundValid) itGPTo.next();
           }
           if (!foundValid) itPathTo.next();
         }
         if (!foundValid) end = true;
       }
     }
     tableau.add(row);
   }
   if (!end) return null;
   return ResolvedName.newNameReference(path.getLast(), tableau);
 }
예제 #3
0
 /**
  * 执行真正的 保存 事件操作
  *
  * @param aggregate the aggregate to store
  */
 @Override
 protected void doSaveWithLock(T aggregate) {
   AggregateEventStream eventStream = aggregate.getUncommittedEvents();
   try {
     Iterator<EventStreamDecorator> iterator = eventStreamDecorators.descendingIterator();
     while (iterator.hasNext()) {
       eventStream =
           iterator.next().decorateForAppend(getTypeIdentifier(), aggregate, eventStream);
     }
     AggregateEventStore.appendEvents(getTypeIdentifier(), eventStream);
   } finally {
     IOUtils.closeQuietlyIfCloseable(eventStream);
   }
 }
 @Nullable
 private ExceptionInfo findCatch(PsiType thrownType) {
   final Iterator<ExceptionInfo> iterator = myCaughtExceptionInfos.descendingIterator();
   while (iterator.hasNext()) {
     final ExceptionInfo info = iterator.next();
     final GrCatchClause clause = info.myClause;
     final GrParameter parameter = clause.getParameter();
     if (parameter != null) {
       final PsiType type = parameter.getType();
       if (type.isAssignableFrom(thrownType)) return info;
     }
   }
   return null;
 }