本文整理匯總了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);
}
}
};
}