當前位置: 首頁>>代碼示例>>Java>>正文


Java Ref.get方法代碼示例

本文整理匯總了Java中com.intellij.openapi.util.Ref.get方法的典型用法代碼示例。如果您正苦於以下問題:Java Ref.get方法的具體用法?Java Ref.get怎麽用?Java Ref.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.util.Ref的用法示例。


在下文中一共展示了Ref.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createTaskContent

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@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();
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:22,代碼來源:PyEduPluginConfigurator.java

示例2: generateFolder

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@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();
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:23,代碼來源:CCUtils.java

示例3: scanForModifiedClassesWithProgress

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
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();
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:17,代碼來源:HotSwapComponent.java

示例4: findNode

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
private Object findNode(final String name) {
  final Ref<Object> node = new Ref<Object>();
  ((SimpleTree)myTree).accept(myBuilder, new SimpleNodeVisitor() {
    @Override
    public boolean accept(final SimpleNode simpleNode) {
      if (name.equals(simpleNode.toString())) {
        node.set(myBuilder.getOriginalNode(simpleNode));
        return true;
      } else {
        return false;
      }
    }
  });

  return node.get();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:FilteringTreeBuilderTest.java

示例5: calculatePreferredWidth

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
private int calculatePreferredWidth() {
  int lineCount = myLineWidths.size();
  int maxWidth = 0;
  for (int i = 0; i < lineCount; i++) {
    int width = myLineWidths.get(i);
    if (width == UNKNOWN_WIDTH) {
      final Ref<Boolean> approximateValue = new Ref<Boolean>(Boolean.FALSE);
      width = myView.getMaxWidthInLineRange(i, i, new Runnable() {
        @Override
        public void run() {
          approximateValue.set(Boolean.TRUE);
        }
      });
      if (approximateValue.get()) width = -width;
      myLineWidths.set(i, width);
    }
    maxWidth = Math.max(maxWidth, Math.abs(width));
  }
  return maxWidth;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:EditorSizeManager.java

示例6: getImportedStyleSheetFile

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
/**
 * Visits the containing file of the specified element to find a require to a style sheet file
 *
 * @param cssReferencingElement starting point for finding an imported style sheet file
 * @return the PSI file for the first imported style sheet file
 */
public static StylesheetFile getImportedStyleSheetFile(PsiElement cssReferencingElement) {
    final Ref<StylesheetFile> file = new Ref<>();
    cssReferencingElement.getContainingFile().accept(new PsiRecursiveElementVisitor() {
        @Override
        public void visitElement(PsiElement element) {
            if (file.get() != null) {
                return;
            }
            if (element instanceof JSLiteralExpression) {
                if (resolveStyleSheetFile(element, file)) return;
            }
            if(element instanceof ES6FromClause) {
                if (resolveStyleSheetFile(element, file)) return;
            }
            super.visitElement(element);
        }
    });
    return file.get();
}
 
開發者ID:jimkyndemeyer,項目名稱:react-css-modules-intellij-plugin,代碼行數:26,代碼來源:CssModulesUtil.java

示例7: scheduleTimeoutCheck

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
private void scheduleTimeoutCheck() {
  final Ref<Long> nextTime = Ref.create(Long.MAX_VALUE);
  synchronized (myLock) {
    if (myTimeoutHandlers.isEmpty()) return;
    myTimeoutHandlers.forEachValue(new TObjectProcedure<TimeoutHandler>() {
      public boolean execute(TimeoutHandler handler) {
        nextTime.set(Math.min(nextTime.get(), handler.myLastTime));
        return true;
      }
    });
  }
  final int delay = (int)(nextTime.get() - System.currentTimeMillis() + 100);
  LOG.debug("schedule timeout check in " + delay + "ms");
  if (delay > 10) {
    myTimeoutAlarm.cancelAllRequests();
    myTimeoutAlarm.addRequest(new Runnable() {
      public void run() {
        checkTimeout();
      }
    }, delay);
  }
  else {
    checkTimeout();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:ResponseProcessor.java

示例8: getReRunEnvironment

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
/**
 * Fetches "rerun" env from run action
 *
 * @param runAction action to fetch state from
 * @return state or null if not found
 */
@Nullable
public static ExecutionEnvironment getReRunEnvironment(@NotNull final AbstractRerunFailedTestsAction runAction) {
  final MyRunProfile profile = runAction.getRunProfile(new ExecutionEnvironment());
  if (profile == null) {
    return null;
  }
  final Ref<ExecutionEnvironment> stateRef = new Ref<ExecutionEnvironment>();
  UsefulTestCase.edt(new Runnable() {
    @Override
    public void run() {
      stateRef.set(ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), profile).build());
    }
  });
  return stateRef.get();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:RerunFailedActionsTestTools.java

示例9: findClass

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Override
public PsiClass findClass(@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope) {
  final Ref<PsiClass> result = Ref.create();
  processDirectories(StringUtil.getPackageName(qualifiedName), scope, new Processor<VirtualFile>() {
    @Override
    public boolean process(VirtualFile dir) {
      VirtualFile virtualFile = findChild(dir, StringUtil.getShortName(qualifiedName), myFileExtensions);
      final PsiFile file = virtualFile == null ? null : myManager.findFile(virtualFile);
      if (file instanceof PsiClassOwner) {
        final PsiClass[] classes = ((PsiClassOwner)file).getClasses();
        if (classes.length == 1) {
          result.set(classes[0]);
          return false;
        }
      }
      return true;
    }
  });
  return result.get();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:NonClasspathClassFinder.java

示例10: findModuleDependency

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
private static ModuleOrderEntry findModuleDependency(ModifiableRootModel rootModel, final String moduleName) {
  final Ref<ModuleOrderEntry> result = Ref.create(null);

  rootModel.orderEntries().forEach(new Processor<OrderEntry>() {
    @Override
    public boolean process(OrderEntry entry) {
      if (entry instanceof ModuleOrderEntry) {
        final ModuleOrderEntry moduleEntry = (ModuleOrderEntry)entry;
        final String name = moduleEntry.getModuleName();
        if (moduleName.equals(name)) {
          result.set(moduleEntry);
        }
      }
      return true;
    }
  });

  return result.get();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:AndroidFacetImporterBase.java

示例11: build

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
public void build(XmlBuilder builder) {
  PsiBuilder b = createBuilderAndParse();

  FlyweightCapableTreeStructure<LighterASTNode> structure = b.getLightTree();

  LighterASTNode root = structure.getRoot();
  root = structure.prepareForGetChildren(root);

  final Ref<LighterASTNode[]> childrenRef = Ref.create(null);
  final int count = structure.getChildren(root, childrenRef);
  LighterASTNode[] children = childrenRef.get();

  for (int i = 0; i < count; i++) {
    LighterASTNode child = children[i];
    final IElementType tt = child.getTokenType();
    if (tt == XmlElementType.XML_TAG || tt == XmlElementType.HTML_TAG) {
      processTagNode(b, structure, child, builder);
    }
    else if (tt == XmlElementType.XML_PROLOG) {
      processPrologNode(b, builder, structure, child);
    }
  }

  structure.disposeChildren(children, count);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:XmlBuilderDriver.java

示例12: findFileByNameInDirectory

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@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();
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:32,代碼來源:DefaultVirtualFileSystemService.java

示例13: getGeneratedFilesFolder

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
public static VirtualFile getGeneratedFilesFolder(@NotNull Project project, @NotNull Module module) {
  VirtualFile baseDir = project.getBaseDir();
  VirtualFile folder = baseDir.findChild(GENERATED_FILES_FOLDER);
  if (folder != null) {
    return folder;
  }
  final Ref<VirtualFile> generatedRoot = new Ref<>();
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      try {
        generatedRoot.set(baseDir.createChildDirectory(this, GENERATED_FILES_FOLDER));
        VirtualFile contentRootForFile =
          ProjectRootManager.getInstance(module.getProject()).getFileIndex().getContentRootForFile(generatedRoot.get());
        if (contentRootForFile == null) {
          return;
        }
        ModuleRootModificationUtil.updateExcludedFolders(module, contentRootForFile, Collections.emptyList(),
                                                         Collections.singletonList(generatedRoot.get().getUrl()));
      }
      catch (IOException e) {
        LOG.info("Failed to create folder for generated files", e);
      }
    }
  });
  return generatedRoot.get();
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:28,代碼來源:CCUtils.java

示例14: getAnnotationName

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Nullable
private static String getAnnotationName(@NotNull final PsiAnnotation annotation) {
    final Ref<String> qualifiedAnnotationName = new Ref<>();
    ApplicationManager.getApplication().runReadAction(() -> {
                String qualifiedName = annotation.getQualifiedName();
                qualifiedAnnotationName.set(qualifiedName);
            }
    );
    return qualifiedAnnotationName.get();
}
 
開發者ID:allure-framework,項目名稱:allure-idea,代碼行數:11,代碼來源:AllureInvalidFixtureInspection.java

示例15: showAuthDialog

import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Nullable
private AuthDialog showAuthDialog(final String url, final String login) {
  final Ref<AuthDialog> dialog = Ref.create();
  ApplicationManager.getApplication().invokeAndWait(new Runnable() {
    @Override
    public void run() {
      dialog.set(new AuthDialog(myProject, myTitle, "Enter credentials for " + url, login, null, true));
      dialog.get().show();
    }
  }, ModalityState.any());
  return dialog.get();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:GitHttpGuiAuthenticator.java


注:本文中的com.intellij.openapi.util.Ref.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。