本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}