Java 类com.intellij.openapi.util.Ref 实例源码

项目:AppleScript-IDEA    文件:AppleScriptConfigurationProducer.java   
@Override
protected boolean setupConfigurationFromContext(AppleScriptRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
  PsiElement elem = context.getPsiLocation();
  PsiFile file = elem != null ? elem.getContainingFile() : null;
  if (file == null) return false;
  boolean shouldSetUp = file.getFileType() == AppleScriptFileType.INSTANCE;
  VirtualFile vFile = file.getVirtualFile();
  String scriptPath = vFile != null ? file.getVirtualFile().getPath() : null;
  if (scriptPath != null) {
    configuration.setScriptPath(scriptPath);
    String[] parts = scriptPath.split("/");
    if (parts.length > 0) {
      configuration.setName(parts[parts.length - 1]);
    }
  }
  return shouldSetUp;
}
项目:bamboo-soy    文件:EnterHandler.java   
@Override
public Result preprocessEnter(
    @NotNull PsiFile psiFile,
    @NotNull Editor editor,
    @NotNull Ref<Integer> caretOffset,
    @NotNull Ref<Integer> caretOffsetChange,
    @NotNull DataContext dataContext,
    @Nullable EditorActionHandler originalHandler) {
  if (psiFile instanceof SoyFile && isBetweenSiblingTags(psiFile, caretOffset.get())) {
    if (originalHandler != null) {
      originalHandler.execute(editor, dataContext);
    }
    return Result.Default;
  }
  return Result.Continue;
}
项目:educational-plugin    文件:PyEduPluginConfigurator.java   
@Override
public PsiDirectory createTaskContent(@NotNull Project project,
                                      @NotNull Task task,
                                      @Nullable IdeView view,
                                      @NotNull PsiDirectory parentDirectory,
                                      @NotNull Course course) {
  final Ref<PsiDirectory> taskDirectory = new Ref<>();
  ApplicationManager.getApplication().runWriteAction(() -> {
    String taskDirName = EduNames.TASK + task.getIndex();
    taskDirectory.set(DirectoryUtil.createSubdirectories(taskDirName, parentDirectory, "\\/"));
    if (taskDirectory.isNull()) return;

    if (course.isAdaptive() && !task.getTaskFiles().isEmpty()) {
      createTaskFilesFromText(task, taskDirectory.get());
    }
    else {
      createFilesFromTemplates(project, view, taskDirectory.get());
    }
  });
  return taskDirectory.get();
}
项目:educational-plugin    文件:EduStepicUpdater.java   
public void scheduleCourseListUpdate(Application application) {
  if (!checkNeeded()) {
    return;
  }
  application.getMessageBus().connect(application).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
    @Override
    public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {

      long timeToNextCheck = StudySettings.getInstance().getLastTimeChecked() + CHECK_INTERVAL - System.currentTimeMillis();
      if (timeToNextCheck <= 0) {
        myCheckRunnable.run();
      }
      else {
        queueNextCheck(timeToNextCheck);
      }
    }
  });
}
项目:educational-plugin    文件:CCUtils.java   
@Nullable
public static VirtualFile generateFolder(@NotNull Project project, @NotNull Module module, String name) {
  VirtualFile generatedRoot = getGeneratedFilesFolder(project, module);
  if (generatedRoot == null) {
    return null;
  }

  final Ref<VirtualFile> folder = new Ref<>(generatedRoot.findChild(name));
  //need to delete old folder
  ApplicationManager.getApplication().runWriteAction(() -> {
    try {
      if (folder.get() != null) {
        folder.get().delete(null);
      }
      folder.set(generatedRoot.createChildDirectory(null, name));
    }
    catch (IOException e) {
      LOG.info("Failed to generate folder " + name, e);
    }
  });
  return folder.get();
}
项目:manifold-ij    文件:HotSwapComponent.java   
private Map<DebuggerSession, Map<String, HotSwapFile>> scanForModifiedClassesWithProgress( List<DebuggerSession> sessions, HotSwapProgressImpl progress )
{
  Ref<Map<DebuggerSession, Map<String, HotSwapFile>>> result = Ref.create( null );
  ProgressManager.getInstance().runProcess(
    () -> {
      try
      {
        result.set( scanForModifiedClasses( sessions, progress ) );
      }
      finally
      {
        progress.finished();
      }
    }, progress.getProgressIndicator() );
  return result.get();
}
项目:mule-intellij-plugins    文件:MuleApplicationConfigurationProducer.java   
@Override
protected boolean setupConfigurationFromContext(MuleConfiguration muleConfiguration, ConfigurationContext configurationContext, Ref<PsiElement> ref)
{
    final Location location = configurationContext.getLocation();
    if (location != null)
    {
        final boolean muleFile = MuleConfigUtils.isMuleFile(location.getPsiElement().getContainingFile());
        final Module module = configurationContext.getModule();
        if (muleFile && module != null)
        {
            muleConfiguration.setModule(module);
            muleConfiguration.setName(StringUtils.capitalize(module.getName()));
            return true;
        }
    }
    return false;
}
项目:intellij-ce-playground    文件:PropertiesParser.java   
private static CharSequence findKeyCharacters(LighterASTNode newNode, FlyweightCapableTreeStructure<LighterASTNode> structure) {
  Ref<LighterASTNode[]> childrenRef = Ref.create(null);
  int childrenCount = structure.getChildren(newNode, childrenRef);
  LighterASTNode[] children = childrenRef.get();

  try {
    for (int i = 0; i < children.length; ++i) {
      if (children[i].getTokenType() == PropertiesTokenTypes.KEY_CHARACTERS)
        return ((LighterASTTokenNode) children[i]).getText();
    }
    return null;
  }
  finally {
    structure.disposeChildren(children, childrenCount);
  }
}
项目:intellij-nette-tester    文件:TesterTestMethodRunConfigurationProducer.java   
@Override
protected boolean setupConfigurationFromContext(TesterTestMethodRunConfiguration runConfiguration, ConfigurationContext context, Ref<PsiElement> ref) {
    PsiElement element = context.getPsiLocation();
    Method method = PhpPsiUtil.getParentByCondition(element, parent -> parent instanceof Method);

    if (method != null && isValid(method)) {
        VirtualFile file = method.getContainingFile().getVirtualFile();
        ref.set(method);

        if (!FileTypeManager.getInstance().isFileOfType(file, ScratchFileType.INSTANCE)) {
            VirtualFile root = ProjectRootManager.getInstance(element.getProject()).getFileIndex().getContentRootForFile(file);
            if (root == null) {
                return false;
            }
        }

        PhpScriptRunConfiguration.Settings settings = runConfiguration.getSettings();
        settings.setPath(file.getPresentableUrl());
        runConfiguration.setMethod(method);
        runConfiguration.setName(runConfiguration.suggestedName());
        return true;
    }

    return false;
}
项目:intellij-ce-playground    文件:LatestExistentSearcher.java   
@NotNull
private LogEntryConsumer createHandler(@NotNull final Ref<Long> latest) {
  return new LogEntryConsumer() {
    @Override
    public void consume(final LogEntry logEntry) throws SVNException {
      final Map changedPaths = logEntry.getChangedPaths();
      for (Object o : changedPaths.values()) {
        final LogEntryPath path = (LogEntryPath)o;
        if ((path.getType() == 'D') && (myRelativeUrl.equals(path.getPath()))) {
          latest.set(logEntry.getRevision());
          throw new SVNException(SVNErrorMessage.UNKNOWN_ERROR_MESSAGE);
        }
      }
    }
  };
}
项目:intellij-ce-playground    文件:CvsRootAsStringConfigurationPanel.java   
public CvsRootAsStringConfigurationPanel(boolean readOnly, Ref<Boolean> isUpdating) {
  myIsUpdating = isUpdating;
  myCvsRoot.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      notifyListeners();
    }
  });

  myEditFieldByFieldButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      final CvsRootConfiguration cvsRootConfiguration =
        CvsApplicationLevelConfiguration.createNewConfiguration(CvsApplicationLevelConfiguration.getInstance());
      cvsRootConfiguration.CVS_ROOT = FormUtils.getFieldValue(myCvsRoot, false);
      final EditCvsConfigurationFieldByFieldDialog dialog = new EditCvsConfigurationFieldByFieldDialog(myCvsRoot.getText());
      if (dialog.showAndGet()) {
        myCvsRoot.setText(dialog.getConfiguration());
      }
    }
  });
  if (readOnly) {
    myCvsRoot.setEditable(false);
    myEditFieldByFieldButton.setEnabled(false);
  }
}
项目:intellij-ce-playground    文件:SelectLocationDialog.java   
@Nullable
private static SVNURL initRoot(final Project project, final SVNURL url) throws SvnBindException {
  final Ref<SVNURL> result = new Ref<SVNURL>();
  final Ref<SvnBindException> excRef = new Ref<SvnBindException>();

  ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    public void run() {
      try {
        result.set(SvnUtil.getRepositoryRoot(SvnVcs.getInstance(project), url));
      } catch (SvnBindException e) {
        excRef.set(e);
      }
    }
  }, "Detecting repository root", true, project);
  if (! excRef.isNull()) {
    throw excRef.get();
  }
  return result.get();
}
项目:intellij-ce-playground    文件:GitPushOperationSingleRepoTest.java   
public void test_dont_propose_to_update_if_force_push_is_rejected() throws IOException {
  final Ref<Boolean> dialogShown = Ref.create(false);
  myDialogManager.registerDialogHandler(GitRejectedPushUpdateDialog.class, new TestDialogHandler<GitRejectedPushUpdateDialog>() {
    @Override
    public int handleDialog(GitRejectedPushUpdateDialog dialog) {
      dialogShown.set(true);
      return DialogWrapper.CANCEL_EXIT_CODE;
    }
  });

  Pair<String, GitPushResult> remoteTipAndPushResult = forcePushWithReject();
  assertResult(REJECTED, -1, "master", "origin/master", remoteTipAndPushResult.second);
  assertFalse("Rejected push dialog should not be shown", dialogShown.get());
  cd(myParentRepo.getPath());
  assertEquals("The commit pushed from bro should be the last one", remoteTipAndPushResult.first, last());
}
项目:intellij-ce-playground    文件:FetchExtResourceAction.java   
private static VirtualFile findFileByPath(final String resPath, @Nullable final String dtdUrl, ProgressIndicator indicator) {
  final Ref<VirtualFile> ref = new Ref<VirtualFile>();
  ApplicationManager.getApplication().invokeAndWait(new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          ref.set(LocalFileSystem.getInstance().refreshAndFindFileByPath(resPath.replace(File.separatorChar, '/')));
          if (dtdUrl != null) {
            ExternalResourceManager.getInstance().addResource(dtdUrl, resPath);
          }
        }
      });
    }
  }, indicator.getModalityState());
  return ref.get();
}
项目:intellij-ce-playground    文件:LightPlatformCodeInsightTestCase.java   
private static void setupEditorForInjectedLanguage() {
  if (myEditor != null) {
    final Ref<EditorWindow> editorWindowRef = new Ref<EditorWindow>();
    myEditor.getCaretModel().runForEachCaret(new CaretAction() {
      @Override
      public void perform(Caret caret) {
        Editor editor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(myEditor, myFile);
        if (caret == myEditor.getCaretModel().getPrimaryCaret() && editor instanceof EditorWindow) {
          editorWindowRef.set((EditorWindow)editor);
        }
      }
    });
    if (!editorWindowRef.isNull()) {
      myEditor = editorWindowRef.get();
      myFile = editorWindowRef.get().getInjectedFile();
    }
  }
}
项目:intellij-ce-playground    文件:TestPackage.java   
protected GlobalSearchScope filterScope(final JUnitConfiguration.Data data) throws CantRunException {
  final Ref<CantRunException> ref = new Ref<CantRunException>();
  final GlobalSearchScope aPackage = ApplicationManager.getApplication().runReadAction(new Computable<GlobalSearchScope>() {
    @Override
    public GlobalSearchScope compute() {
      try {
        return PackageScope.packageScope(getPackage(data), true);
      }
      catch (CantRunException e) {
        ref.set(e);
        return null;
      }
    }
  });
  final CantRunException exception = ref.get();
  if (exception != null) throw exception;
  return aPackage;
}
项目:intellij-ce-playground    文件:CommittedChangesCache.java   
public void hasCachesForAnyRoot(@Nullable final Consumer<Boolean> continuation) {
  myTaskQueue.run(new Runnable() {
    @Override
    public void run() {
      final Ref<Boolean> success = new Ref<Boolean>();
      try {
        success.set(hasCachesWithEmptiness(false));
      }
      catch (ProcessCanceledException e) {
        success.set(true);
      }
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          continuation.consume(success.get());
        }
      }, myProject.getDisposed());
    }
  });
}
项目:intellij-ce-playground    文件:TempDirTestFixtureImpl.java   
@Override
@Nullable
public VirtualFile getFile(@NotNull final String path) {

  final Ref<VirtualFile> result = new Ref<VirtualFile>(null);
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      try {
        final String fullPath = myTempDir.getCanonicalPath().replace(File.separatorChar, '/') + "/" + path;
        final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(fullPath);
        result.set(file);
      }
      catch (IOException e) {
        Assert.fail("Cannot find " + path + ": " + e);
      }
    }
  });
  return result.get();
}
项目:intellij-ce-playground    文件:PyTypingTypeProvider.java   
@Nullable
public Ref<PyType> getParameterType(@NotNull PyNamedParameter param, @NotNull PyFunction func, @NotNull TypeEvalContext context) {
  final PyAnnotation annotation = param.getAnnotation();
  if (annotation != null) {
    // XXX: Requires switching from stub to AST
    final PyExpression value = annotation.getValue();
    if (value != null) {
      final PyType type = getType(value, context);
      if (type != null) {
        final PyType optionalType = getOptionalTypeFromDefaultNone(param, type, context);
        return Ref.create(optionalType != null ? optionalType : type);
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:GrChangeSignatureConflictSearcher.java   
public MultiMap<PsiElement, String> findConflicts(Ref<UsageInfo[]> refUsages) {
  MultiMap<PsiElement, String> conflictDescriptions = new MultiMap<PsiElement, String>();
  addMethodConflicts(conflictDescriptions);
  UsageInfo[] usagesIn = refUsages.get();
  RenameUtil.addConflictDescriptions(usagesIn, conflictDescriptions);
  Set<UsageInfo> usagesSet = new HashSet<UsageInfo>(Arrays.asList(usagesIn));
  RenameUtil.removeConflictUsages(usagesSet);
  if (myChangeInfo.isVisibilityChanged()) {
    try {
      addInaccessibilityDescriptions(usagesSet, conflictDescriptions);
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
  }

  return conflictDescriptions;
}
项目:intellij-ce-playground    文件:PlatformProjectConfigurator.java   
@Override
public void configureProject(final Project project, @NotNull final VirtualFile baseDir, final Ref<Module> moduleRef) {
  final ModuleManager moduleManager = ModuleManager.getInstance(project);
  final Module[] modules = moduleManager.getModules();
  if (modules.length == 0) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        String moduleName = baseDir.getName().replace(":", "");     // correct module name when opening root of drive as project (RUBY-5181)
        String imlName = baseDir.getPath() + "/.idea/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION;
        ModuleTypeManager instance = ModuleTypeManager.getInstance();
        String id = instance == null ? "unknown" : instance.getDefaultModuleType().getId();
        final Module module = moduleManager.newModule(imlName, id);
        ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
        ModifiableRootModel rootModel = rootManager.getModifiableModel();
        if (rootModel.getContentRoots().length == 0) {
          rootModel.addContentEntry(baseDir);
        }
        rootModel.inheritSdk();
        rootModel.commit();
        moduleRef.set(module);
      }
    });
  }
}
项目:intellij-ce-playground    文件:ModuleTestCase.java   
@Nullable
protected Module loadAllModulesUnder(@NotNull VirtualFile rootDir, @Nullable final Consumer<Module> moduleConsumer) {
  final Ref<Module> result = Ref.create();

  VfsUtilCore.visitChildrenRecursively(rootDir, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!file.isDirectory() && file.getName().endsWith(ModuleFileType.DOT_DEFAULT_EXTENSION)) {
        ModuleImpl module = (ModuleImpl)loadModule(file.getPath());
        if (moduleConsumer != null) {
          moduleConsumer.consume(module);
        }
        result.setIfNull(module);
      }
      return true;
    }
  });

  return result.get();
}
项目:intellij-ce-playground    文件:MoveFieldAssignmentToInitializerAction.java   
private static boolean isValidAsFieldInitializer(final PsiExpression initializer, final PsiModifierListOwner ctrOrInitializer) {
  if (initializer == null) return false;
  final Ref<Boolean> result = new Ref<Boolean>(Boolean.TRUE);
  initializer.accept(new JavaRecursiveElementWalkingVisitor() {
    @Override
    public void visitReferenceExpression(PsiReferenceExpression expression) {
      PsiElement resolved = expression.resolve();
      if (resolved == null) return;
      if (PsiTreeUtil.isAncestor(ctrOrInitializer, resolved, false) && !PsiTreeUtil.isAncestor(initializer, resolved, false)) {
        // resolved somewhere inside constructor but outside initializer
        result.set(Boolean.FALSE);
      }
    }
  });
  return result.get().booleanValue();
}
项目:intellij-ce-playground    文件:PyFunctionImpl.java   
@Nullable
private PyType getReturnType(@NotNull TypeEvalContext context) {
  for (PyTypeProvider typeProvider : Extensions.getExtensions(PyTypeProvider.EP_NAME)) {
    final Ref<PyType> returnTypeRef = typeProvider.getReturnType(this, context);
    if (returnTypeRef != null) {
      final PyType returnType = returnTypeRef.get();
      if (returnType != null) {
        returnType.assertValid(typeProvider.toString());
      }
      return returnType;
    }
  }
  final PyType docStringType = getReturnTypeFromDocString();
  if (docStringType != null) {
    docStringType.assertValid("from docstring");
    return docStringType;
  }
  if (context.allowReturnTypes(this)) {
    final Ref<? extends PyType> yieldTypeRef = getYieldStatementType(context);
    if (yieldTypeRef != null) {
      return yieldTypeRef.get();
    }
    return getReturnStatementType(context);
  }
  return null;
}
项目:intellij-ce-playground    文件:GitPushOperationSingleRepoTest.java   
public void test_warn_if_silently_rebasing_over_merge() throws IOException {
  generateUnpushedMergedCommitProblem();

  myGitSettings.setAutoUpdateIfPushRejected(true);
  myGitSettings.setUpdateType(UpdateMethod.REBASE);

  final Ref<Boolean> rebaseOverMergeProblemDetected = Ref.create(false);
  myDialogManager.registerMessageHandler(new TestMessageHandler() {
    @Override
    public int handleMessage(@NotNull String description) {
      rebaseOverMergeProblemDetected.set(description.contains(GitRebaseOverMergeProblem.DESCRIPTION));
      return Messages.CANCEL;
    }
  });
  push("master", "origin/master");
  assertTrue(rebaseOverMergeProblemDetected.get());
}
项目:intellij-ce-playground    文件:AndroidTestConfigurationProducer.java   
private boolean setupMethodConfiguration(AndroidTestRunConfiguration configuration,
                                                PsiElement element,
                                                ConfigurationContext context,
                                                Ref<PsiElement> sourceElement) {
  PsiMethod elementMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);

  while (elementMethod != null) {
    if (isTestMethod(elementMethod)) {
      PsiClass c = elementMethod.getContainingClass();
      setupConfiguration(configuration, elementMethod, context, sourceElement);
      assert c != null;
      configuration.TESTING_TYPE = AndroidTestRunConfiguration.TEST_METHOD;
      configuration.CLASS_NAME = c.getQualifiedName();
      configuration.METHOD_NAME = elementMethod.getName();
      configuration.setGeneratedName();
      return true;
    }
    elementMethod = PsiTreeUtil.getParentOfType(elementMethod, PsiMethod.class);
  }
  return false;
}
项目:intellij    文件:BlazeGoBinaryConfigurationProducer.java   
@Override
protected boolean doSetupConfigFromContext(
    BlazeCommandRunConfiguration configuration,
    ConfigurationContext context,
    Ref<PsiElement> sourceElement) {
  PsiFile file = getMainFile(context);
  if (file == null) {
    return false;
  }
  TargetInfo binaryTarget = getTargetLabel(file);
  if (binaryTarget == null) {
    return false;
  }
  configuration.setTargetInfo(binaryTarget);
  sourceElement.set(file);

  BlazeCommandRunConfigurationCommonState handlerState =
      configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
  if (handlerState == null) {
    return false;
  }
  handlerState.getCommandState().setCommand(BlazeCommandName.RUN);
  configuration.setGeneratedName();
  return true;
}
项目:intellij-ce-playground    文件:CommittedChangesCache.java   
private static List<CommittedChangeList> writeChangesInReadAction(final ChangesCacheFile cacheFile,
                                                                  final List<CommittedChangeList> newChanges) throws IOException {
  // ensure that changes are loaded before taking read action, to avoid stalling UI
  for(CommittedChangeList changeList: newChanges) {
    changeList.getChanges();
  }
  final Ref<IOException> ref = new Ref<IOException>();
  final List<CommittedChangeList> savedChanges = ApplicationManager.getApplication().runReadAction(new Computable<List<CommittedChangeList>>() {
    @Override
    public List<CommittedChangeList> compute() {
      try {
        return cacheFile.writeChanges(newChanges);    // skip duplicates;
      }
      catch (IOException e) {
        ref.set(e);
        return null;
      }
    }
  });
  if (!ref.isNull()) {
    throw ref.get();
  }
  return savedChanges;
}
项目:intellij-ce-playground    文件:AndroidCompileUtil.java   
private static void unexcludeRootIfNecessary(@NotNull VirtualFile root,
                                             @NotNull ModifiableRootModel model,
                                             @NotNull Ref<Boolean> modelChangedFlag) {
  Set<VirtualFile> excludedRoots = new HashSet<VirtualFile>(Arrays.asList(model.getExcludeRoots()));
  VirtualFile excludedRoot = root;
  while (excludedRoot != null && !excludedRoots.contains(excludedRoot)) {
    excludedRoot = excludedRoot.getParent();
  }
  if (excludedRoot == null) {
    return;
  }
  Set<VirtualFile> rootsToExclude = new HashSet<VirtualFile>();
  collectChildrenRecursively(excludedRoot, root, rootsToExclude);
  ContentEntry contentEntry = findContentEntryForRoot(model, excludedRoot);
  if (contentEntry != null) {
    if (contentEntry.removeExcludeFolder(excludedRoot.getUrl())) {
      modelChangedFlag.set(true);
    }
    for (VirtualFile rootToExclude : rootsToExclude) {
      if (!excludedRoots.contains(rootToExclude)) {
        contentEntry.addExcludeFolder(rootToExclude);
        modelChangedFlag.set(true);
      }
    }
  }
}
项目:intellij-ce-playground    文件:MarkLocallyDeletedTreeConflictResolvedAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final MyLocallyDeletedChecker locallyDeletedChecker = new MyLocallyDeletedChecker(e);
  if (! locallyDeletedChecker.isEnabled()) return;

  final String markText = SvnBundle.message("action.mark.tree.conflict.resolved.confirmation.title");
  final Project project = locallyDeletedChecker.getProject();
  final int result = Messages.showYesNoDialog(project,
                                              SvnBundle.message("action.mark.tree.conflict.resolved.confirmation.text"), markText,
                                              Messages.getQuestionIcon());
  if (result == Messages.YES) {
    final Ref<VcsException> exception = new Ref<VcsException>();
    ProgressManager
      .getInstance().run(new Task.Backgroundable(project, markText, true, BackgroundFromStartOption.getInstance()) {
      public void run(@NotNull ProgressIndicator indicator) {
        resolveLocallyDeletedTextConflict(locallyDeletedChecker, exception);
      }
    });
    if (! exception.isNull()) {
      AbstractVcsHelper.getInstance(project).showError(exception.get(), markText);
    }
  }
}
项目:intellij-ce-playground    文件:PyQtTypeProvider.java   
@Override
public Ref<PyType> getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) {
  if (PyNames.INIT.equals(callable.getName()) && callable instanceof PyFunction) {
    final PyFunction function = (PyFunction)callable;
    final PyClass containingClass = function.getContainingClass();
    if (containingClass != null && ourQt4Signal.equals(containingClass.getName())) {
      final String classQName = containingClass.getQualifiedName();
      if (classQName != null) {
        final QualifiedName name = QualifiedName.fromDottedString(classQName);
        final String qtVersion = name.getComponents().get(0);
        final PyClass aClass = PyClassNameIndex.findClass(qtVersion + "." + ourQtBoundSignal, function.getProject());
        if (aClass != null) {
          final PyType type = new PyClassTypeImpl(aClass, false);
          return Ref.create(type);
        }
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:InstrumentationTargetPackageConverter.java   
@Nullable
private PsiElement resolveInner() {
  final String value = getValue();

  if (value.length() == 0) {
    return null;
  }
  final Ref<PsiElement> result = Ref.create();

  processApkPackageAttrs(new Processor<GenericAttributeValue<String>>() {
    @Override
    public boolean process(GenericAttributeValue<String> domValue) {
      if (value.equals(domValue.getValue())) {
        final XmlAttributeValue xmlValue = domValue.getXmlAttributeValue();

        if (xmlValue != null) {
          result.set(xmlValue);
          return false;
        }
      }
      return true;
    }
  });
  return result.get();
}
项目:intellij-ce-playground    文件:AndroidCompileUtil.java   
private static void markRootAsGenerated(ModifiableRootModel model, VirtualFile root, Ref<Boolean> modelChangedFlag) {
  final ContentEntry contentEntry = findContentEntryForRoot(model, root);

  if (contentEntry == null) {
    return;
  }
  for (SourceFolder sourceFolder : contentEntry.getSourceFolders()) {
    if (root.equals(sourceFolder.getFile())) {
      final JavaSourceRootProperties props = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
      if (props != null) {
        props.setForGeneratedSources(true);
        modelChangedFlag.set(true);
        break;
      }
    }
  }
}
项目:intellij-ce-playground    文件:PivotalTrackerRepository.java   
private static Comment[] parseComments(Element notes) {
  if (notes == null) return Comment.EMPTY_ARRAY;
  final List<Comment> result = new ArrayList<Comment>();
  //noinspection unchecked
  for (Element note : (List<Element>)notes.getChildren("note")) {
    final String text = note.getChildText("text");
    if (text == null) continue;
    final Ref<Date> date = new Ref<Date>();
    try {
      date.set(parseDate(note, "noted_at"));
    } catch (ParseException e) {
      LOG.warn(e);
    }
    final String author = note.getChildText("author");
    result.add(new SimpleComment(date.get(), author, text));
  }
  return result.toArray(new Comment[result.size()]);
}
项目:intellij-ce-playground    文件:DuplicatesImpl.java   
public static void invoke(final Project project, final MatchProvider provider) {
  final List<Match> duplicates = provider.getDuplicates();
  int idx = 0;
  final Ref<Boolean> showAll = new Ref<Boolean>();
  final String confirmDuplicatePrompt = getConfirmationPrompt(provider, duplicates);
  for (final Match match : duplicates) {
    final PsiFile file = match.getFile();
    final VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile == null || !virtualFile.isValid()) return;
    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) return;
    final Editor editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, virtualFile), false);
    LOG.assertTrue(editor != null);
    if (!match.getMatchStart().isValid() || !match.getMatchEnd().isValid()) continue;
    if (replaceMatch(project, provider, match, editor, ++idx, duplicates.size(), showAll, confirmDuplicatePrompt, false)) return;
  }
}
项目:intellij-ce-playground    文件:XmlAutoPopupHandler.java   
private static boolean doCompleteIfNeeded(int offset, PsiFile file, PsiElement lastElement) {
  final Ref<Boolean> isRelevantLanguage = new Ref<Boolean>();
  final Ref<Boolean> isAnt = new Ref<Boolean>();
  String text = lastElement.getText();
  final int len = offset - lastElement.getTextRange().getStartOffset();
  if (len < text.length()) {
    text = text.substring(0, len);
  }
  if (text.equals("<") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt) ||
      text.equals(" ") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt) ||
      text.endsWith("${") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt) && isAnt.get().booleanValue() ||
      text.endsWith("@{") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt) && isAnt.get().booleanValue() ||
      text.endsWith("</") && isLanguageRelevant(lastElement, file, isRelevantLanguage, isAnt)) {
    return true;
  }

  return false;
}
项目:intellij-ce-playground    文件:ProjectJdksConfigurable.java   
@Override
public void apply() throws ConfigurationException {
  final Ref<ConfigurationException> exceptionRef = Ref.create();
  try {
    ProjectJdksConfigurable.super.apply();
    boolean modifiedJdks = false;
    for (int i = 0; i < myRoot.getChildCount(); i++) {
      final NamedConfigurable configurable = ((MyNode)myRoot.getChildAt(i)).getConfigurable();
      if (configurable.isModified()) {
        configurable.apply();
        modifiedJdks = true;
      }
    }

    if (myProjectJdksModel.isModified() || modifiedJdks) {
      myProjectJdksModel.apply(ProjectJdksConfigurable.this);
    }
    myProjectJdksModel.setProjectSdk(getSelectedJdk());
  }
  catch (ConfigurationException e) {
    exceptionRef.set(e);
  }
  if (!exceptionRef.isNull()) {
    throw exceptionRef.get();
  }
}
项目:intellij-ce-playground    文件:CvsUpdateEnvironment.java   
private static UpdateSettingsOnCvsConfiguration createSettingsAndUpdateContext(final CvsConfiguration cvsConfiguration,
                                                                               @NotNull final Ref<SequentialUpdatesContext> contextRef) {
  if (contextRef.get() != null) {
    final CvsSequentialUpdateContext cvsContext = (CvsSequentialUpdateContext) contextRef.get();
    contextRef.set(null);
    return cvsContext.getConfiguration();
  }

  if ((! cvsConfiguration.CLEAN_COPY) && cvsConfiguration.UPDATE_DATE_OR_REVISION_SETTINGS.overridesDefault() &&
      (cvsConfiguration.MERGING_MODE != CvsConfiguration.DO_NOT_MERGE)) {
    // split into 2 updates
    final UpdateSettingsOnCvsConfiguration secondUpdate = new UpdateSettingsOnCvsConfiguration(
        cvsConfiguration.PRUNE_EMPTY_DIRECTORIES, cvsConfiguration.MERGING_MODE, cvsConfiguration.MERGE_WITH_BRANCH1_NAME,
        cvsConfiguration.MERGE_WITH_BRANCH2_NAME, cvsConfiguration.CREATE_NEW_DIRECTORIES, cvsConfiguration.UPDATE_KEYWORD_SUBSTITUTION,
        new DateOrRevisionSettings(), cvsConfiguration.MAKE_NEW_FILES_READONLY, cvsConfiguration.CLEAN_COPY, cvsConfiguration.RESET_STICKY);
    contextRef.set(new CvsSequentialUpdateContext(secondUpdate, cvsConfiguration.UPDATE_DATE_OR_REVISION_SETTINGS.asString()));

    return new UpdateSettingsOnCvsConfiguration(
        cvsConfiguration.PRUNE_EMPTY_DIRECTORIES, CvsConfiguration.DO_NOT_MERGE, null, null, cvsConfiguration.CREATE_NEW_DIRECTORIES,
        cvsConfiguration.UPDATE_KEYWORD_SUBSTITUTION, cvsConfiguration.UPDATE_DATE_OR_REVISION_SETTINGS,
        cvsConfiguration.MAKE_NEW_FILES_READONLY, cvsConfiguration.CLEAN_COPY, cvsConfiguration.RESET_STICKY);
  } else {
    // usual way
    return new UpdateSettingsOnCvsConfiguration(cvsConfiguration, cvsConfiguration.CLEAN_COPY, cvsConfiguration.RESET_STICKY);
  }
}
项目:intellij-ce-playground    文件:PyUnreachableCodeInspection.java   
public static boolean hasAnyInterruptedControlFlowPaths(@NotNull PsiElement element) {
  final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
  if (owner != null) {
    final ControlFlow flow = ControlFlowCache.getControlFlow(owner);
    final Instruction[] instructions = flow.getInstructions();
    final int start = ControlFlowUtil.findInstructionNumberByElement(instructions, element);
    if (start >= 0) {
      final Ref<Boolean> resultRef = Ref.create(false);
      ControlFlowUtil.iteratePrev(start, instructions, new Function<Instruction, ControlFlowUtil.Operation>() {
        @Override
        public ControlFlowUtil.Operation fun(Instruction instruction) {
          if (instruction.allPred().isEmpty() && !isFirstInstruction(instruction)) {
            resultRef.set(true);
            return ControlFlowUtil.Operation.BREAK;
          }
          return ControlFlowUtil.Operation.NEXT;
        }
      });
      return resultRef.get();
    }
  }
  return false;
}
项目:hybris-integration-intellij-idea-plugin    文件:DefaultVirtualFileSystemService.java   
@Override
@Nullable
public File findFileByNameInDirectory(
    @NotNull final File directory,
    @NotNull final String fileName,
    @Nullable final TaskProgressProcessor<File> progressListenerProcessor
) throws InterruptedException {
    Validate.notNull(directory);
    Validate.isTrue(directory.isDirectory());
    Validate.notNull(fileName);

    final Ref<File> result = Ref.create();
    final Ref<Boolean> interrupted = Ref.create(false);

    FileUtil.processFilesRecursively(directory, file -> {
        if (progressListenerProcessor != null && !progressListenerProcessor.shouldContinue(directory)) {
            interrupted.set(true);
            return false;
        }
        if (StringUtils.endsWith(file.getAbsolutePath(), fileName)) {
            result.set(file);
            return false;
        }
        return true;
    });

    if (interrupted.get()) {
        throw new InterruptedException("Modules scanning has been interrupted.");
    }
    return result.get();
}