本文整理汇总了Java中com.intellij.openapi.util.Ref类的典型用法代码示例。如果您正苦于以下问题:Java Ref类的具体用法?Java Ref怎么用?Java Ref使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Ref类属于com.intellij.openapi.util包,在下文中一共展示了Ref类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupConfigurationFromContext
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
@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;
}
示例2: preprocessEnter
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
@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;
}
示例3: 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();
}
示例4: scheduleCourseListUpdate
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
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);
}
}
});
}
示例5: 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();
}
示例6: 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();
}
示例7: setupConfigurationFromContext
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
@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;
}
示例8: findKeyCharacters
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
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);
}
}
示例9: setupConfigurationFromContext
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
@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;
}
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:26,代码来源:TesterTestMethodRunConfigurationProducer.java
示例10: createHandler
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
@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);
}
}
}
};
}
示例11: CvsRootAsStringConfigurationPanel
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
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);
}
}
示例12: initRoot
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
@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();
}
示例13: test_dont_propose_to_update_if_force_push_is_rejected
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
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());
}
示例14: findFileByPath
import com.intellij.openapi.util.Ref; //导入依赖的package包/类
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();
}
示例15: 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();
}
}
}