本文整理匯總了Java中com.intellij.openapi.util.Ref.set方法的典型用法代碼示例。如果您正苦於以下問題:Java Ref.set方法的具體用法?Java Ref.set怎麽用?Java Ref.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.util.Ref
的用法示例。
在下文中一共展示了Ref.set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findValidSdkPath
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
private static void findValidSdkPath(@NotNull Ref<File> pathRef) {
Sdk jdk = IdeSdks.getJdk();
String jdkPath = jdk != null ? jdk.getHomePath() : null;
SelectSdkDialog dialog = new SelectSdkDialog(jdkPath, null);
dialog.setModal(true);
if (!dialog.showAndGet()) {
String msg = "An Android SDK is needed to continue. Would you like to try again?";
if (Messages.showYesNoDialog(msg, ERROR_DIALOG_TITLE, null) == Messages.YES) {
findValidSdkPath(pathRef);
}
return;
}
final File path = new File(dialog.getAndroidHome());
if (!isValidAndroidSdkPath(path)) {
String format = "The path\n'%1$s'\ndoes not refer to a valid Android SDK. Would you like to try again?";
if (Messages.showYesNoDialog(String.format(format, path.getPath()), ERROR_DIALOG_TITLE, null) == Messages.YES) {
findValidSdkPath(pathRef);
}
return;
}
pathRef.set(path);
}
示例2: getChildren
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Override
public int getChildren(@NotNull final ASTNode astNode, @NotNull final Ref<ASTNode[]> into) {
ASTNode child = astNode.getFirstChildNode();
if (child == null) return 0;
ASTNode[] store = into.get();
if (store == null) {
store = new ASTNode[10];
into.set(store);
}
int count = 0;
while (child != null) {
if (count >= store.length) {
ASTNode[] newStore = new ASTNode[count * 3 / 2];
System.arraycopy(store, 0, newStore, 0, count);
into.set(newStore);
store = newStore;
}
store[count++] = child;
child = child.getTreeNext();
}
return count;
}
示例3: doSetupConfigFromContext
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Override
protected boolean doSetupConfigFromContext(
BlazeCommandRunConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
PsiFile file = getMainFile(context);
if (file == null) {
return false;
}
TargetInfo binaryTarget = getTargetLabel(file);
if (binaryTarget == null) {
return false;
}
configuration.setTargetInfo(binaryTarget);
sourceElement.set(file);
BlazeCommandRunConfigurationCommonState handlerState =
configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.RUN);
configuration.setGeneratedName();
return true;
}
示例4: isInstrumented
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
private static boolean isInstrumented(JpsModule m, final String classPath) {
File file = new File(JpsJavaExtensionService.getInstance().getOutputDirectory(m, false), classPath);
assertTrue(file.getAbsolutePath() + " not found", file.exists());
final Ref<Boolean> instrumented = Ref.create(false);
ClassVisitor visitor = new ClassVisitor(Opcodes.ASM5) {
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals("$$$setupUI$$$")) {
instrumented.set(true);
}
return null;
}
};
try {
ClassReader reader = new ClassReader(FileUtil.loadFileBytes(file));
reader.accept(visitor, 0);
return instrumented.get();
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
示例5: getAllAndroidDependencies
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@NotNull
private static List<AndroidFacet> getAllAndroidDependencies(@NotNull Module module,
boolean androidLibrariesOnly,
Ref<List<WeakReference<AndroidFacet>>> listRef) {
List<WeakReference<AndroidFacet>> refs = listRef.get();
if (refs == null) {
final List<AndroidFacet> facets = new ArrayList<AndroidFacet>();
collectAllAndroidDependencies(module, androidLibrariesOnly, facets, new HashSet<AndroidFacet>());
refs = ContainerUtil.map(ContainerUtil.reverse(facets), new Function<AndroidFacet, WeakReference<AndroidFacet>>() {
@Override
public WeakReference<AndroidFacet> fun(AndroidFacet facet) {
return new WeakReference<AndroidFacet>(facet);
}
});
listRef.set(refs);
}
return dereference(refs);
}
示例6: dirExists
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
private static boolean dirExists(@NotNull final SvnVcs vcs, @NotNull final SVNURL url) throws SvnBindException {
final Ref<SvnBindException> excRef = new Ref<SvnBindException>();
final Ref<Boolean> resultRef = new Ref<Boolean>(Boolean.TRUE);
final Runnable taskImpl = new Runnable() {
public void run() {
try {
vcs.getInfo(url, SVNRevision.HEAD);
}
catch (SvnBindException e) {
if (e.contains(SVNErrorCode.RA_ILLEGAL_URL)) {
resultRef.set(Boolean.FALSE);
}
else {
excRef.set(e);
}
}
}
};
final Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(taskImpl, "Checking target folder", true, vcs.getProject());
}
else {
taskImpl.run();
}
if (!excRef.isNull()) throw excRef.get();
return resultRef.get();
}
示例7: test_rollback_of_checkout_branch_as_new_branch_should_delete_branches
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
public void test_rollback_of_checkout_branch_as_new_branch_should_delete_branches() {
branchWithCommit(myRepositories, "feature");
touch("feature.txt", "feature_content");
git("add feature.txt");
git("commit -m feature_changes");
git("checkout master");
unmergedFiles(myCommunity);
final Ref<Boolean> rollbackProposed = Ref.create(false);
GitBranchWorker brancher = new GitBranchWorker(myProject, myPlatformFacade, myGit, new TestUiHandler() {
@Override
public boolean showUnmergedFilesMessageWithRollback(@NotNull String operationName, @NotNull String rollbackProposal) {
rollbackProposed.set(true);
return true;
}
});
brancher.checkoutNewBranchStartingFrom("newBranch", "feature", myRepositories);
assertTrue("Rollback was not proposed if unmerged files prevented checkout in the second repository", rollbackProposed.get());
assertCurrentBranch("master");
for (GitRepository repository : myRepositories) {
assertFalse("Branch 'newBranch' should have been deleted on rollback",
ContainerUtil.exists(git(repository, "branch").split("\n"), new Condition<String>() {
@Override
public boolean value(String s) {
return s.contains("newBranch");
}
}));
}
}
示例8: getCssClass
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
/**
* Resolves a CssClass PSI element given a CSS filename and class name
*
* @param cssFileNameLiteralParent element which contains a require'd style sheet file
* @param cssClass the CSS class to get including the "."
* @param referencedStyleSheet ref to set to the style sheet that any matching CSS class is declared in
* @return the matching CSS class, or <code>null</code> in case the class is unknown
*/
public static CssClass getCssClass(PsiElement cssFileNameLiteralParent, String cssClass, Ref<StylesheetFile> referencedStyleSheet) {
StylesheetFile stylesheetFile = resolveStyleSheetFile(cssFileNameLiteralParent);
if (stylesheetFile != null) {
referencedStyleSheet.set(stylesheetFile);
return getCssClass(stylesheetFile, cssClass);
} else {
referencedStyleSheet.set(null);
return null;
}
}
示例9: resolveStyleSheetFile
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
/**
* Gets the style sheet, if any, that the specified element resolves to
*
* @param element element used to resolve
* @param stylesheetFileRef the ref to set the resolved sheet on
* @return true if the element resolves to a style sheet file, false otherwise
*/
private static boolean resolveStyleSheetFile(PsiElement element, Ref<StylesheetFile> stylesheetFileRef) {
for (PsiReference reference : element.getReferences()) {
final PsiElement fileReference = reference.resolve();
if (fileReference instanceof StylesheetFile) {
stylesheetFileRef.set((StylesheetFile) fileReference);
return true;
}
}
return false;
}
示例10: buildOneLineMismatchDescription
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
private static String buildOneLineMismatchDescription(@NotNull PsiExpressionList list,
@NotNull MethodCandidateInfo candidateInfo,
@NotNull Ref<PsiElement> elementToHighlight) {
final PsiExpression[] expressions = list.getExpressions();
final PsiMethod resolvedMethod = candidateInfo.getElement();
final PsiSubstitutor substitutor = candidateInfo.getSubstitutor();
final PsiParameter[] parameters = resolvedMethod.getParameterList().getParameters();
if (expressions.length == parameters.length && parameters.length > 1) {
int idx = -1;
for (int i = 0; i < expressions.length; i++) {
PsiExpression expression = expressions[i];
if (!TypeConversionUtil.areTypesAssignmentCompatible(substitutor.substitute(parameters[i].getType()), expression)) {
if (idx != -1) {
idx = -1;
break;
}
else {
idx = i;
}
}
}
if (idx > -1) {
final PsiExpression wrongArg = expressions[idx];
final PsiType argType = wrongArg.getType();
if (argType != null) {
elementToHighlight.set(wrongArg);
final String message = JavaErrorMessages
.message("incompatible.call.types", idx + 1, substitutor.substitute(parameters[idx].getType()).getCanonicalText(), argType.getCanonicalText());
return XmlStringUtil.wrapInHtml("<body>" + XmlStringUtil.escapeString(message) +
" <a href=\"#assignment/" + XmlStringUtil.escapeString(createMismatchedArgumentsHtmlTooltip(candidateInfo, list)) + "\"" +
(UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "") +
">" + DaemonBundle.message("inspection.extended.description") + "</a></body>");
}
}
}
return null;
}
示例11: doSetupConfigFromContext
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Override
protected boolean doSetupConfigFromContext(
BlazeCommandRunConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
TestLocation location = getSingleJUnitTestClass(context);
if (location == null) {
return false;
}
sourceElement.set(location.testClass);
configuration.setTargetInfo(location.blazeTarget);
BlazeCommandRunConfigurationCommonState handlerState =
configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
String testFilter = getTestFilter(location.testClass);
if (testFilter == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.TEST);
// remove old test filter flag if present
List<String> flags = new ArrayList<>(handlerState.getBlazeFlagsState().getRawFlags());
flags.removeIf((flag) -> flag.startsWith(BlazeFlags.TEST_FILTER));
flags.add(BlazeFlags.TEST_FILTER + "=" + testFilter);
handlerState.getBlazeFlagsState().setRawFlags(flags);
String name =
new BlazeConfigurationNameBuilder(configuration)
.setTargetString(location.testClass.getName())
.build();
configuration.setName(name);
configuration.setNameChangedByUser(true); // don't revert to generated name
return true;
}
示例12: doSetupConfigFromContext
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Override
protected boolean doSetupConfigFromContext(
BlazeCommandRunConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
TestLocation testLocation = testLocation(context);
if (testLocation == null) {
return false;
}
configuration.setTargetInfo(testLocation.target);
sourceElement.set(testLocation.sourceElement());
BlazeCommandRunConfigurationCommonState handlerState =
configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
if (handlerState == null) {
return false;
}
handlerState.getCommandState().setCommand(BlazeCommandName.TEST);
// remove conflicting flags from initial configuration
List<String> flags = new ArrayList<>(handlerState.getBlazeFlagsState().getRawFlags());
flags.removeIf((flag) -> flag.startsWith(BlazeFlags.TEST_FILTER));
String testFilter = testLocation.testFilter();
if (testFilter != null) {
flags.add(testFilter);
}
handlerState.getBlazeFlagsState().setRawFlags(flags);
BlazeConfigurationNameBuilder nameBuilder = new BlazeConfigurationNameBuilder(configuration);
nameBuilder.setTargetString(testLocation.targetString());
configuration.setName(nameBuilder.build());
configuration.setNameChangedByUser(true); // don't revert to generated name
return true;
}
示例13: preprocessUsages
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Override
protected boolean preprocessUsages(@NotNull Ref<UsageInfo[]> refUsages) {
MultiMap<PsiElement, String> conflictDescriptions = new MultiMap<PsiElement, String>();
for (ChangeSignatureUsageProcessor usageProcessor : ChangeSignatureUsageProcessor.EP_NAME.getExtensions()) {
final MultiMap<PsiElement, String> conflicts = usageProcessor.findConflicts(myChangeInfo, refUsages);
for (PsiElement key : conflicts.keySet()) {
Collection<String> collection = conflictDescriptions.get(key);
if (collection.isEmpty()) collection = new HashSet<String>();
collection.addAll(conflicts.get(key));
conflictDescriptions.put(key, collection);
}
}
final UsageInfo[] usagesIn = refUsages.get();
RenameUtil.addConflictDescriptions(usagesIn, conflictDescriptions);
Set<UsageInfo> usagesSet = new HashSet<UsageInfo>(Arrays.asList(usagesIn));
RenameUtil.removeConflictUsages(usagesSet);
if (!conflictDescriptions.isEmpty()) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
throw new ConflictsInTestsException(conflictDescriptions.values());
}
ConflictsDialog dialog = prepareConflictsDialog(conflictDescriptions, usagesIn);
if (!dialog.showAndGet()) {
if (dialog.isShowConflicts()) prepareSuccessful();
return false;
}
}
refUsages.set(usagesSet.toArray(new UsageInfo[usagesSet.size()]));
prepareSuccessful();
return true;
}
示例14: show
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Override
public <T extends PsiElement> T show(@NotNull String errorTitle, @Nullable String selectedTemplateName,
@NotNull final FileCreator<T> creator) {
final Ref<T> created = Ref.create(null);
myDialog.getKindCombo().setSelectedName(selectedTemplateName);
myDialog.myCreator = new ElementCreator(myProject, errorTitle) {
@Override
protected PsiElement[] create(String newName) throws Exception {
final T element = creator.createFile(myDialog.getEnteredName(), myDialog.getKindCombo().getSelectedName());
created.set(element);
if (element != null) {
return new PsiElement[]{element};
}
return PsiElement.EMPTY_ARRAY;
}
@Override
protected String getActionName(String newName) {
return creator.getActionName(newName, myDialog.getKindCombo().getSelectedName());
}
};
myDialog.show();
if (myDialog.getExitCode() == OK_EXIT_CODE) {
return created.get();
}
return null;
}
示例15: doSetupConfigFromContext
import com.intellij.openapi.util.Ref; //導入方法依賴的package包/類
@Override
protected boolean doSetupConfigFromContext(
BlazeCommandRunConfiguration configuration,
ConfigurationContext context,
Ref<PsiElement> sourceElement) {
AbstractTestLocation location = getAbstractLocation(context);
if (location == null) {
return false;
}
sourceElement.set(location.method != null ? location.method : location.abstractClass);
configuration.setName(configName(location.abstractClass, location.method));
configuration.setNameChangedByUser(true);
return true;
}