本文整理汇总了Java中com.intellij.openapi.util.Ref.isNull方法的典型用法代码示例。如果您正苦于以下问题:Java Ref.isNull方法的具体用法?Java Ref.isNull怎么用?Java Ref.isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.Ref
的用法示例。
在下文中一共展示了Ref.isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentFileRevisionHash
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
@Nullable
private static String getCurrentFileRevisionHash(@NotNull final Project project, @NotNull final VirtualFile file) {
final Ref<GitRevisionNumber> ref = new Ref<GitRevisionNumber>();
ProgressManager.getInstance().run(new Task.Modal(project, "Getting last revision", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
ref.set((GitRevisionNumber)GitHistoryUtils.getCurrentRevision(project, VcsUtil.getFilePath(file), "HEAD"));
}
catch (VcsException e) {
LOG.warn(e);
}
}
@Override
public void onCancel() {
throw new ProcessCanceledException();
}
});
if (ref.isNull()) return null;
return ref.get().getRev();
}
示例2: actionPerformed
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
@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);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:MarkLocallyDeletedTreeConflictResolvedAction.java
示例3: serializeUrl
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
private static String serializeUrl(final String url, final Ref<Boolean> withUserInfo) {
if (Boolean.FALSE.equals(withUserInfo.get())) {
return url;
}
try {
final SVNURL svnurl = SVNURL.parseURIEncoded(url);
if (withUserInfo.isNull()) {
final String userInfo = svnurl.getUserInfo();
withUserInfo.set((userInfo != null) && (userInfo.length() > 0));
}
if (withUserInfo.get()) {
return SVNURL.create(svnurl.getProtocol(), null, svnurl.getHost(), SvnUtil.resolvePort(svnurl), svnurl.getURIEncodedPath(), true)
.toString();
}
}
catch (SVNException e) {
//
}
return url;
}
示例4: revert
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
public ChangeRange revert(ChangeRange reverse) throws IOException {
final Ref<Long> first = new Ref<Long>();
final Ref<Long> last = new Ref<Long>();
LocalHistoryFacade.Listener l = new LocalHistoryFacade.Listener() {
public void changeAdded(Change c) {
if (first.isNull()) first.set(c.getId());
last.set(c.getId());
}
};
myVcs.addListener(l, null);
try {
myVcs.accept(new UndoChangeRevertingVisitor(myGateway, myToChangeId, myFromChangeId));
}
catch (UndoChangeRevertingVisitor.RuntimeIOException e) {
throw (IOException)e.getCause();
}
finally {
myVcs.removeListener(l);
}
if (reverse != null) {
if (first.isNull()) first.set(reverse.myFromChangeId);
if (last.isNull()) last.set(reverse.myToChangeId);
}
return new ChangeRange(myGateway, myVcs, first.get(), last.get());
}
示例5: setupEditorForInjectedLanguage
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
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();
}
}
}
示例6: doMkdir
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
protected static void doMkdir(final SVNURL url, final String comment, final Project project) {
final Ref<Exception> exception = new Ref<Exception>();
Runnable command = new Runnable() {
public void run() {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.browser.creating", url.toString()));
}
SvnVcs vcs = SvnVcs.getInstance(project);
SvnTarget target = SvnTarget.fromURL(url);
try {
vcs.getFactoryFromSettings().createBrowseClient().createDirectory(target, comment, false);
}
catch (VcsException e) {
exception.set(e);
}
}
};
ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("progress.text.create.remote.folder"), false, project);
if (!exception.isNull()) {
Messages.showErrorDialog(exception.get().getMessage(), SvnBundle.message("message.text.error"));
}
}
示例7: haveCustomComponents
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
private static boolean haveCustomComponents(final GuiEditor editor) {
// quick & dirty check
if (editor.isFormInvalid()) {
return true;
}
final Ref<Boolean> result = new Ref<Boolean>();
FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.ComponentVisitor() {
public boolean visit(final IComponent component) {
if (component instanceof RadErrorComponent || !component.getComponentClassName().startsWith("javax.swing")) {
result.set(Boolean.TRUE);
return false;
}
return true;
}
});
return !result.isNull();
}
示例8: showUsageView
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
private void showUsageView(@NotNull Project project, final UsageInfo[] usageInfos, @NotNull AnalysisScope scope) {
final UsageTarget[] targets = UsageTarget.EMPTY_ARRAY;
final Ref<Usage[]> convertUsagesRef = new Ref<Usage[]>();
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
convertUsagesRef.set(UsageInfo2UsageAdapter.convert(usageInfos));
}
});
}
}, "Preprocess Usages", true, project)) return;
if (convertUsagesRef.isNull()) return;
final Usage[] usages = convertUsagesRef.get();
final UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setTabText("Infer Nullity Preview");
presentation.setShowReadOnlyStatusAsRed(true);
presentation.setShowCancelButton(true);
presentation.setUsagesString(RefactoringBundle.message("usageView.usagesText"));
final UsageView usageView = UsageViewManager.getInstance(project).showUsages(targets, usages, presentation, rerunFactory(project, scope));
final Runnable refactoringRunnable = applyRunnable(project, new Computable<UsageInfo[]>() {
@Override
public UsageInfo[] compute() {
final Set<UsageInfo> infos = UsageViewUtil.getNotExcludedUsageInfos(usageView);
return infos.toArray(new UsageInfo[infos.size()]);
}
});
String canNotMakeString = "Cannot perform operation.\nThere were changes in code after usages have been found.\nPlease perform operation search again.";
usageView.addPerformOperationAction(refactoringRunnable, INFER_NULLITY_ANNOTATIONS, canNotMakeString, INFER_NULLITY_ANNOTATIONS, false);
}
示例9: showUsageView
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
private void showUsageView(@NotNull Project project, final UsageInfo[] usageInfos, @NotNull AnalysisScope scope) {
final UsageTarget[] targets = UsageTarget.EMPTY_ARRAY;
final Ref<Usage[]> convertUsagesRef = new Ref<Usage[]>();
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
convertUsagesRef.set(UsageInfo2UsageAdapter.convert(usageInfos));
}
});
}
}, "Preprocess usages", true, project)) return;
if (convertUsagesRef.isNull()) return;
final Usage[] usages = convertUsagesRef.get();
final UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setTabText("Infer Nullity Preview");
presentation.setShowReadOnlyStatusAsRed(true);
presentation.setShowCancelButton(true);
presentation.setUsagesString(RefactoringBundle.message("usageView.usagesText"));
final UsageView usageView = UsageViewManager.getInstance(project).showUsages(targets, usages, presentation, rerunFactory(project, scope));
final Runnable refactoringRunnable = applyRunnable(project, new Computable<UsageInfo[]>() {
@Override
public UsageInfo[] compute() {
final Set<UsageInfo> infos = UsageViewUtil.getNotExcludedUsageInfos(usageView);
return infos.toArray(new UsageInfo[infos.size()]);
}
});
String canNotMakeString = "Cannot perform operation.\nThere were changes in code after usages have been found.\nPlease perform operation search again.";
usageView.addPerformOperationAction(refactoringRunnable, INFER_NULLITY_ANNOTATIONS, canNotMakeString, INFER_NULLITY_ANNOTATIONS, false);
}
示例10: bindToElement
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
@Override
public PsiElement bindToElement(@NotNull final PsiElement element) throws IncorrectOperationException {
final Ref<IncorrectOperationException> ref = new Ref<IncorrectOperationException>();
PsiElement bindElement =
referenceBindToElement(this, element, getSuperBindToElementFunction(ref), getSuperElementRenameFunction(ref));
if (!ref.isNull()) {
throw ref.get();
}
return bindElement;
}
示例11: performCopyFrom
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
public void performCopyFrom(final DirDiffElementImpl element) {
final DiffElement<?> target = element.getTarget();
if (target != null) {
final String path = element.getParentNode().getPath();
if (target instanceof BackgroundOperatingDiffElement) {
final Ref<String> errorMessage = new Ref<String>();
final Ref<DiffElement> diff = new Ref<DiffElement>();
Runnable onFinish = new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!myDisposed) {
refreshElementAfterCopyFrom(element, diff.get());
if (!errorMessage.isNull()) {
reportException(errorMessage.get());
}
}
}
};
((BackgroundOperatingDiffElement)target).copyTo(mySrc, errorMessage, diff, onFinish, element.getSource(), path);
}
else {
final AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
try {
final DiffElement<?> diffElement = target.copyTo(mySrc, path);
refreshElementAfterCopyFrom(element, diffElement);
}
finally {
token.finish();
}
}
}
}
示例12: queueAndWaitTask
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
public <V> V queueAndWaitTask(final Callable<V> task) throws Throwable {
final Ref<V> resultRef = new Ref<V>();
final Ref<Throwable> throwableRef = new Ref<Throwable>();
final Semaphore taskSemaphore = new Semaphore();
taskSemaphore.down();
queueTask(new Runnable() {
@Override
public void run() {
try {
resultRef.set(task.call());
}
catch (Throwable e) {
throwableRef.set(e);
LOG.error(e);
}
finally {
taskSemaphore.up();
}
}
});
taskSemaphore.waitFor();
if (!throwableRef.isNull()) {
throw throwableRef.get();
}
return resultRef.get();
}
示例13: release
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
public void release() {
int line = getLine();
if (line < 0) {
return;
}
final Document document = getDocument();
if (document == null) return;
MarkupModelEx markup = (MarkupModelEx)DocumentMarkupModel.forDocument(document, myProject, true);
final Document markupDocument = markup.getDocument();
if (markupDocument.getLineCount() <= line) return;
final int startOffset = markupDocument.getLineStartOffset(line);
final int endOffset = markupDocument.getLineEndOffset(line);
final Ref<RangeHighlighterEx> found = new Ref<RangeHighlighterEx>();
markup.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor<RangeHighlighterEx>() {
@Override
public boolean process(RangeHighlighterEx highlighter) {
GutterMark renderer = highlighter.getGutterIconRenderer();
if (renderer instanceof MyGutterIconRenderer && ((MyGutterIconRenderer)renderer).myBookmark == Bookmark.this) {
found.set(highlighter);
return false;
}
return true;
}
});
if (!found.isNull()) found.get().dispose();
}
示例14: doImportProject
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
private void doImportProject() {
AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(myProject, getExternalSystemId());
final ExternalProjectSettings projectSettings = getCurrentExternalProjectSettings();
projectSettings.setExternalProjectPath(getProjectPath());
Set<ExternalProjectSettings> projects = ContainerUtilRt.newHashSet(systemSettings.getLinkedProjectsSettings());
projects.remove(projectSettings);
projects.add(projectSettings);
systemSettings.setLinkedProjectsSettings(projects);
final Ref<Couple<String>> error = Ref.create();
ExternalSystemUtil.refreshProjects(
new ImportSpecBuilder(myProject, getExternalSystemId())
.use(ProgressExecutionMode.MODAL_SYNC)
.callback(new ExternalProjectRefreshCallback() {
@Override
public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
if (externalProject == null) {
System.err.println("Got null External project after import");
return;
}
ServiceManager.getService(ProjectDataManager.class).importData(externalProject, myProject, true);
System.out.println("External project was successfully imported");
}
@Override
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
error.set(Couple.of(errorMessage, errorDetails));
}
})
);
if (!error.isNull()) {
String failureMsg = "Import failed: " + error.get().first;
if (StringUtil.isNotEmpty(error.get().second)) {
failureMsg += "\nError details: \n" + error.get().second;
}
fail(failureMsg);
}
}
示例15: buildInternalVisitor
import com.intellij.openapi.util.Ref; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildInternalVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new JavaElementVisitor() {
@Override
public void visitMethodCallExpression(final PsiMethodCallExpression expression) {
final Project project = expression.getProject();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
final PsiReferenceExpression methodRef = expression.getMethodExpression();
if (!GET_CHILDREN_METHOD_NAME.equals(methodRef.getReferenceName())) return;
final PsiElement methodElement = methodRef.resolve();
if (!(methodElement instanceof PsiMethod)) return;
final PsiMethod method = (PsiMethod)methodElement;
final PsiClass aClass = method.getContainingClass();
final PsiClass virtualFileClass = facade.findClass(VIRTUAL_FILE_CLASS_NAME, GlobalSearchScope.allScope(project));
if (!InheritanceUtil.isInheritorOrSelf(aClass, virtualFileClass, true)) return;
final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
if (containingMethod == null) return;
final String containingMethodName = containingMethod.getName();
final Ref<Boolean> result = Ref.create();
containingMethod.accept(new JavaRecursiveElementVisitor() {
@Override
public void visitMethodCallExpression(final PsiMethodCallExpression expression2) {
if (expression2 != expression &&
containingMethodName.equals(expression2.getMethodExpression().getReferenceName()) &&
expression2.resolveMethod() == containingMethod) {
result.set(Boolean.TRUE);
}
}
});
if (!result.isNull()) {
holder.registerProblem(expression, MESSAGE);
}
}
};
}