private void doMoveClass(PsiSubstitutor substitutor, MemberInfo info) {
   PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(myProject);
   PsiClass aClass = (PsiClass) info.getMember();
   if (Boolean.FALSE.equals(info.getOverrides())) {
     final PsiReferenceList sourceReferenceList = info.getSourceReferenceList();
     LOG.assertTrue(sourceReferenceList != null);
     PsiJavaCodeReferenceElement ref =
         mySourceClass.equals(sourceReferenceList.getParent())
             ? RefactoringUtil.removeFromReferenceList(sourceReferenceList, aClass)
             : RefactoringUtil.findReferenceToClass(sourceReferenceList, aClass);
     if (ref != null && !myTargetSuperClass.isInheritor(aClass, false)) {
       RefactoringUtil.replaceMovedMemberTypeParameters(
           ref, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory);
       final PsiReferenceList referenceList =
           myIsTargetInterface
               ? myTargetSuperClass.getExtendsList()
               : myTargetSuperClass.getImplementsList();
       assert referenceList != null;
       referenceList.add(ref);
     }
   } else {
     RefactoringUtil.replaceMovedMemberTypeParameters(
         aClass, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory);
     fixReferencesToStatic(aClass);
     final PsiMember movedElement =
         (PsiMember)
             myTargetSuperClass.add(
                 convertClassToLanguage(aClass, myTargetSuperClass.getLanguage()));
     myMembersAfterMove.add(movedElement);
     aClass.delete();
   }
 }
示例#2
0
 /**
  * 判断条件是否永假的
  *
  * @param expr
  * @return
  */
 public static boolean isConditionAlwaysFalse(SQLExpr expr) {
   Object o = WallVisitorUtils.getValue(expr);
   if (Boolean.FALSE.equals(o)) {
     return true;
   }
   return false;
 }
  private static boolean supportNullValues(OIndex<?> index) {
    final ODocument metadata = index.getMetadata();
    if (metadata == null) return false;

    final Boolean ignoreNullValues = metadata.field("ignoreNullValues");
    return Boolean.FALSE.equals(ignoreNullValues);
  }
  public boolean processAction(final InputEvent e, ActionProcessor processor) {
    ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    final Project project = PlatformDataKeys.PROJECT.getData(myContext.getDataContext());
    final boolean dumb = project != null && DumbService.getInstance(project).isDumb();
    List<AnActionEvent> nonDumbAwareAction = new ArrayList<AnActionEvent>();
    for (final AnAction action : myContext.getActions()) {
      final Presentation presentation = myPresentationFactory.getPresentation(action);

      // Mouse modifiers are 0 because they have no any sense when action is invoked via keyboard
      final AnActionEvent actionEvent =
          processor.createEvent(
              e,
              myContext.getDataContext(),
              ActionPlaces.MAIN_MENU,
              presentation,
              ActionManager.getInstance());

      ActionUtil.performDumbAwareUpdate(action, actionEvent, true);

      if (dumb && !action.isDumbAware()) {
        if (Boolean.FALSE.equals(
            presentation.getClientProperty(ActionUtil.WOULD_BE_ENABLED_IF_NOT_DUMB_MODE))) {
          continue;
        }

        nonDumbAwareAction.add(actionEvent);
        continue;
      }

      if (!presentation.isEnabled()) {
        continue;
      }

      processor.onUpdatePassed(e, action, actionEvent);

      ((DataManagerImpl.MyDataContext) myContext.getDataContext())
          .setEventCount(IdeEventQueue.getInstance().getEventCount(), this);
      actionManager.fireBeforeActionPerformed(action, actionEvent.getDataContext(), actionEvent);
      Component component =
          PlatformDataKeys.CONTEXT_COMPONENT.getData(actionEvent.getDataContext());
      if (component != null && !component.isShowing()) {
        return true;
      }

      processor.performAction(e, action, actionEvent);
      actionManager.fireAfterActionPerformed(action, actionEvent.getDataContext(), actionEvent);
      return true;
    }

    if (!nonDumbAwareAction.isEmpty()) {
      showDumbModeWarningLaterIfNobodyConsumesEvent(
          e, nonDumbAwareAction.toArray(new AnActionEvent[nonDumbAwareAction.size()]));
    }

    return false;
  }
  private void doMoveClass(PsiSubstitutor substitutor, GrMemberInfo info) {
    GroovyPsiElementFactory elementFactory = GroovyPsiElementFactory.getInstance(myProject);
    GrTypeDefinition aClass = (GrTypeDefinition) info.getMember();
    if (Boolean.FALSE.equals(info.getOverrides())) {
      final GrReferenceList sourceReferenceList = info.getSourceReferenceList();
      LOG.assertTrue(sourceReferenceList != null);
      GrCodeReferenceElement ref =
          mySourceClass.equals(sourceReferenceList.getParent())
              ? removeFromReferenceList(sourceReferenceList, aClass)
              : findReferenceToClass(sourceReferenceList, aClass);
      if (ref != null && !myTargetSuperClass.isInheritor(aClass, false)) {
        replaceMovedMemberTypeParameters(
            ref, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory);
        GrReferenceList referenceList;
        if (myTargetSuperClass.isInterface()) {
          referenceList = myTargetSuperClass.getExtendsClause();
          if (referenceList == null) {
            GrExtendsClause newClause =
                GroovyPsiElementFactory.getInstance(myProject).createExtendsClause();
            PsiElement anchor =
                myTargetSuperClass.getTypeParameterList() != null
                    ? myTargetSuperClass.getTypeParameterList()
                    : myTargetSuperClass.getNameIdentifierGroovy();
            referenceList = (GrReferenceList) myTargetSuperClass.addAfter(newClause, anchor);
            addSpacesAround(referenceList);
          }
        } else {
          referenceList = myTargetSuperClass.getImplementsClause();

          if (referenceList == null) {
            GrImplementsClause newClause =
                GroovyPsiElementFactory.getInstance(myProject).createImplementsClause();
            PsiElement anchor =
                myTargetSuperClass.getExtendsClause() != null
                    ? myTargetSuperClass.getExtendsClause()
                    : myTargetSuperClass.getTypeParameterList() != null
                        ? myTargetSuperClass.getTypeParameterList()
                        : myTargetSuperClass.getNameIdentifierGroovy();
            referenceList = (GrReferenceList) myTargetSuperClass.addAfter(newClause, anchor);
            addSpacesAround(referenceList);
          }
        }

        assert referenceList != null;
        referenceList.add(ref);
      }
    } else {
      replaceMovedMemberTypeParameters(
          aClass, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory);
      // fixReferencesToStatic(aClass, movedMembers);
      PsiMember movedElement = (PsiMember) myTargetSuperClass.addAfter(aClass, null);
      // movedElement = (PsiMember)CodeStyleManager.getInstance(myProject).reformat(movedElement);
      myMembersAfterMove.add(movedElement);
      deleteMemberWithDocComment(aClass);
    }
  }
示例#6
0
 /**
  * oneway调用,只发送请求,不接收返回结果.
  *
  * @param callable
  */
 public void asyncCall(Runnable runable) {
   try {
     setAttachment(Constants.RETURN_KEY, Boolean.FALSE.toString());
     runable.run();
   } catch (Throwable e) {
     // FIXME 异常是否应该放在future中?
     throw new RpcException("oneway call error ." + e.getMessage(), e);
   } finally {
     removeAttachment(Constants.RETURN_KEY);
   }
 }
示例#7
0
  public void run() {
    Deque<VisitingContext> stack = new ArrayDeque<>();

    stack.add(new VisitingContext(rootNode));
    boolean goOn = stack.peek().hasNext();

    if (goOn) {
      do {
        Map.Entry<String, JsonValue> current = stack.peek().nextElement();

        if (!(current.getValue() instanceof JsonStructure)) {
          String key = stack.peek().getNSPrefix() + current.getKey();
          String value = null;
          JsonValue jsonValue = current.getValue();
          switch (jsonValue.getValueType()) {
            case NULL:
              value = null;
              break;
            case FALSE:
              value = Boolean.FALSE.toString();
              break;
            case TRUE:
              Boolean.TRUE.toString();
              break;
            case NUMBER:
              value = jsonValue.toString();
              break;
            case STRING:
              value = ((JsonString) jsonValue).getString();
              break;
            default:
              throw new ConfigException("Internal failure while processing JSON document.");
          }

          targetStore.put(key, value);
        } else if (current.getValue() instanceof JsonObject) {
          String key = stack.peek().getNSPrefix() + current.getKey();
          JsonObject node = (JsonObject) current.getValue();
          stack.push(new VisitingContext(node, key));
        } else if (current.getValue() instanceof JsonArray) {
          throw new ConfigException("Arrays are not supported at the moment.");
        } else {
          throw new ConfigException("Internal failure while processing JSON document.");
        }

        goOn = stack.peek().hasNext();

        while (!goOn && stack.size() > 0) {
          stack.remove();
          goOn = (stack.size() > 0) && stack.peek().hasNext();
        }
      } while (goOn);
    }
  }
  private int attemptPrecompiledScriptExecute(
      CommandLine commandLine,
      String scriptName,
      String env,
      GantBinding binding,
      List<File> allScripts) {
    console.updateStatus("Running pre-compiled script");

    // Must be called before the binding is initialised.
    setRunningEnvironment(commandLine, env);

    // Get Gant to load the class by name using our class loader.
    ScriptBindingInitializer bindingInitializer =
        new ScriptBindingInitializer(
            commandLine, classLoader, settings, pluginPathSupport, isInteractive);
    Gant gant = new Gant(bindingInitializer.initBinding(binding, scriptName), classLoader);

    try {
      loadScriptClass(gant, scriptName);
    } catch (ScriptNotFoundException e) {
      if (!isInteractive || InteractiveMode.isActive()) {
        throw e;
      }
      scriptName = fixScriptName(scriptName, allScripts);
      if (scriptName == null) {
        throw e;
      }

      try {
        loadScriptClass(gant, scriptName);
      } catch (ScriptNotFoundException ce) {
        return executeScriptWithCaching(commandLine, scriptName, env);
      }

      // at this point if they were calling a script that has a non-default
      // env (e.g. war or test-app) it wouldn't have been correctly set, so
      // set it now, but only if they didn't specify the env (e.g. "grails test war" -> "grails test
      // war")

      if (Boolean.TRUE.toString().equals(System.getProperty(Environment.DEFAULT))) {
        commandLine.setCommand(GrailsNameUtils.getScriptName(scriptName));
        env = commandLine.lookupEnvironmentForCommand();
        binding.setVariable("grailsEnv", env);
        settings.setGrailsEnv(env);
        System.setProperty(Environment.KEY, env);
        settings.setDefaultEnv(false);
        System.setProperty(Environment.DEFAULT, Boolean.FALSE.toString());
      }
    }

    return executeWithGantInstance(gant, DO_NOTHING_CLOSURE, binding).exitCode;
  }
 public static boolean checkedInterfacesContain(
     Collection<? extends MemberInfoBase<? extends PsiMember>> memberInfos, PsiMethod psiMethod) {
   for (MemberInfoBase<? extends PsiMember> memberInfo : memberInfos) {
     if (memberInfo.isChecked()
         && memberInfo.getMember() instanceof PsiClass
         && Boolean.FALSE.equals(memberInfo.getOverrides())) {
       if (((PsiClass) memberInfo.getMember()).findMethodBySignature(psiMethod, true) != null) {
         return true;
       }
     }
   }
   return false;
 }
  /** Bases on presence of notifications! */
  public ThreeState isAuthenticatedFor(final VirtualFile vf) {
    final WorkingCopy wcCopy = myRootsToWorkingCopies.getWcRoot(vf);
    if (wcCopy == null) return ThreeState.UNSURE;

    // check there's no cancellation yet
    final boolean haveCancellation = getStateFor(wcCopy.getUrl());
    if (haveCancellation) return ThreeState.NO;

    final Boolean keptResult = myCopiesPassiveResults.get(wcCopy.getUrl());
    if (Boolean.TRUE.equals(keptResult)) return ThreeState.YES;
    if (Boolean.FALSE.equals(keptResult)) return ThreeState.NO;

    // check have credentials
    final boolean calculatedResult = passiveValidation(myVcs.getProject(), wcCopy.getUrl());
    myCopiesPassiveResults.put(wcCopy.getUrl(), calculatedResult);
    return calculatedResult ? ThreeState.YES : ThreeState.NO;
  }
  private static boolean shouldRenderAttribute(Object attributeVal) {

    if (attributeVal instanceof String) {
      return true;
    } else if (attributeVal instanceof Boolean && Boolean.FALSE.equals(attributeVal)) {
      return false;
    } else if (attributeVal instanceof Integer && (Integer) attributeVal == Integer.MIN_VALUE) {
      return false;
    } else if (attributeVal instanceof Double && (Double) attributeVal == Double.MIN_VALUE) {
      return false;
    } else if (attributeVal instanceof Character
        && (Character) attributeVal == Character.MIN_VALUE) {
      return false;
    } else if (attributeVal instanceof Float && (Float) attributeVal == Float.MIN_VALUE) {
      return false;
    } else if (attributeVal instanceof Short && (Short) attributeVal == Short.MIN_VALUE) {
      return false;
    } else if (attributeVal instanceof Byte && (Byte) attributeVal == Byte.MIN_VALUE) {
      return false;
    } else if (attributeVal instanceof Long && (Long) attributeVal == Long.MIN_VALUE) {
      return false;
    }
    return true;
  }
示例#12
0
  public void parse(LinkedList<String> args, boolean forceDebug) {
    assemblerOptions = new AssemblerOptions();
    assemblerOptions.parse(args);
    if (assemblerOptions.outStream == System.out) throw new RuntimeException();
    if (Boolean.TRUE.equals(assemblerOptions.readable)) throw new RuntimeException();
    assemblerOptions.readable = false;
    if (forceDebug) {
      if (Boolean.FALSE.equals(assemblerOptions.debugInfo)) throw new RuntimeException();
      assemblerOptions.debugInfo = true;
    }
    assemblerOptions.normalize();

    Iterator<String> iterator = args.iterator();
    while (iterator.hasNext()) {
      String arg = iterator.next();
      if (arg.startsWith("--page=")) {
        pageSizeExponent = Integer.parseInt(arg.substring("--page=".length()));
        iterator.remove();
      } else if (arg.equals("--fancy")) {
        fancyIoSupport = true;
        iterator.remove();
      }
    }
  }