本文整理匯總了Java中com.intellij.util.Function.fun方法的典型用法代碼示例。如果您正苦於以下問題:Java Function.fun方法的具體用法?Java Function.fun怎麽用?Java Function.fun使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.util.Function
的用法示例。
在下文中一共展示了Function.fun方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createSingleFolderDescriptor
import com.intellij.util.Function; //導入方法依賴的package包/類
@NotNull
private static FileChooserDescriptor createSingleFolderDescriptor(@NotNull String title, @NotNull final Function<File, Void> validation) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) {
@Override
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
for (VirtualFile virtualFile : files) {
File file = virtualToIoFile(virtualFile);
validation.fun(file);
}
}
};
if (SystemInfo.isMac) {
descriptor.withShowHiddenFiles(true);
}
descriptor.setTitle(title);
return descriptor;
}
示例2: editAction
import com.intellij.util.Function; //導入方法依賴的package包/類
@NotNull
public CheckBoxListModelEditor<T> editAction(final @NotNull Function<T, T> consumer) {
final Runnable action = new Runnable() {
@Override
public void run() {
T item = getSelectedItem();
if (item != null) {
T newItem = consumer.fun(item);
if (newItem != null) {
list.updateItem(item, newItem, StringUtil.notNullize(toNameConverter.fun(newItem)));
}
list.requestFocus();
}
}
};
toolbarDecorator.setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
action.run();
}
});
EditSourceOnDoubleClickHandler.install(list, action);
return this;
}
示例3: processProject
import com.intellij.util.Function; //導入方法依賴的package包/類
private static <T> boolean processProject(MavenDomProjectModel projectDom,
MavenProject mavenProjectOrNull,
Processor<T> processor,
Project project,
Function<? super MavenDomProfile, T> domProfileFunction,
Function<? super MavenDomProjectModel, T> projectDomFunction) {
if (processProfilesXml(MavenDomUtil.getVirtualFile(projectDom), mavenProjectOrNull, processor, project, domProfileFunction)) {
return true;
}
if (processProfiles(projectDom.getProfiles(), mavenProjectOrNull, processor, domProfileFunction)) return true;
T t = projectDomFunction.fun(projectDom);
return t == null ? false : processor.process(t);
}
示例4: map
import com.intellij.util.Function; //導入方法依賴的package包/類
@Nullable
@Contract("null, _ -> null; !null, _ -> !null")
protected static <T, V> Iterator<V> map(@Nullable final List<T> list, @NotNull final Function<T, V> mapping) {
if (list == null) return null;
final Iterator<T> it = list.iterator();
return new Iterator<V>() {
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
public V next() {
return mapping.fun(it.next());
}
@Override
public void remove() {
}
};
}
示例5: processUnsuccessfulSelections
import com.intellij.util.Function; //導入方法依賴的package包/類
private void processUnsuccessfulSelections(final Object[] toSelect, Function<Object, Object> restore, Set<Object> originallySelected) {
final Set<Object> selected = myUi.getSelectedElements();
boolean wasFullyRejected = false;
if (toSelect.length > 0 && !selected.isEmpty() && !originallySelected.containsAll(selected)) {
final Set<Object> successfulSelections = new HashSet<Object>();
ContainerUtil.addAll(successfulSelections, toSelect);
successfulSelections.retainAll(selected);
wasFullyRejected = successfulSelections.isEmpty();
} else if (selected.isEmpty() && originallySelected.isEmpty()) {
wasFullyRejected = true;
}
if (wasFullyRejected && !selected.isEmpty()) return;
for (Object eachToSelect : toSelect) {
if (!selected.contains(eachToSelect)) {
restore.fun(eachToSelect);
}
}
}
示例6: getType
import com.intellij.util.Function; //導入方法依賴的package包/類
@Nullable
public <T extends GroovyPsiElement> PsiType getType(@NotNull T element, @NotNull Function<T, PsiType> calculator) {
PsiType type = myCalculatedTypes.get(element);
if (type == null) {
RecursionGuard.StackStamp stamp = ourGuard.markStack();
type = calculator.fun(element);
if (type == null) {
type = UNKNOWN_TYPE;
}
if (stamp.mayCacheNow()) {
type = ConcurrencyUtil.cacheOrGet(myCalculatedTypes, element, type);
} else {
final PsiType alreadyInferred = myCalculatedTypes.get(element);
if (alreadyInferred != null) {
type = alreadyInferred;
}
}
}
if (!type.isValid()) {
error(element, type);
}
return UNKNOWN_TYPE == type ? null : type;
}
示例7: createProblemDescriptors
import com.intellij.util.Function; //導入方法依賴的package包/類
@Nullable
private static <T> T createProblemDescriptors(final DomElementProblemDescriptor problemDescriptor,
final Function<Pair<TextRange, PsiElement>, T> creator) {
final Pair<TextRange, PsiElement> range = ((DomElementProblemDescriptorImpl)problemDescriptor).getProblemRange();
return range == DomElementProblemDescriptorImpl.NO_PROBLEM ? null : creator.fun(range);
}
示例8: navigateToStep
import com.intellij.util.Function; //導入方法依賴的package包/類
/**
* Allows to ask current wizard to move to the desired step.
*
* @param filter closure that allows to indicate target step - is called with each of registered steps and is expected
* to return <code>true</code> for the step to go to
* @return <code>true</code> if current wizard is navigated to the target step; <code>false</code> otherwise
*/
public boolean navigateToStep(@NotNull Function<Step, Boolean> filter) {
for (int i = 0, myStepsSize = mySteps.size(); i < myStepsSize; i++) {
ModuleWizardStep step = mySteps.get(i);
if (filter.fun(step) != Boolean.TRUE) {
continue;
}
// Update current step.
myCurrentStep = i;
updateStep();
return true;
}
return false;
}
示例9: showTextAreaDialog
import com.intellij.util.Function; //導入方法依賴的package包/類
/**
* Shows dialog with text area to edit long strings that don't fit in text field.
*/
public static void showTextAreaDialog(final JTextField textField,
final @Nls(capitalization = Nls.Capitalization.Title) String title,
@NonNls final String dimensionServiceKey,
final Function<String, List<String>> parser,
final Function<List<String>, String> lineJoiner) {
if (isApplicationInUnitTestOrHeadless()) {
ourTestImplementation.show(title);
}
else {
final JTextArea textArea = new JTextArea(10, 50);
UIUtil.addUndoRedoActions(textArea);
textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);
List<String> lines = parser.fun(textField.getText());
textArea.setText(StringUtil.join(lines, "\n"));
InsertPathAction.copyFromTo(textField, textArea);
final DialogBuilder builder = new DialogBuilder(textField);
builder.setDimensionServiceKey(dimensionServiceKey);
builder.setCenterPanel(ScrollPaneFactory.createScrollPane(textArea));
builder.setPreferredFocusComponent(textArea);
String rawText = title;
if (StringUtil.endsWithChar(rawText, ':')) {
rawText = rawText.substring(0, rawText.length() - 1);
}
builder.setTitle(rawText);
builder.addOkAction();
builder.addCancelAction();
builder.setOkOperation(new Runnable() {
@Override
public void run() {
textField.setText(lineJoiner.fun(Arrays.asList(StringUtil.splitByLines(textArea.getText()))));
builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
}
});
builder.show();
}
}
示例10: setItems
import com.intellij.util.Function; //導入方法依賴的package包/類
public void setItems(final List<T> items, @Nullable Function<T, String> converter) {
clear();
for (T item : items) {
String text = converter != null ? converter.fun(item) : item.toString();
addItem(item, text, false);
}
}
示例11: computeSize
import com.intellij.util.Function; //導入方法依賴的package包/類
private Dimension computeSize(Function<JComponent, Dimension> transform, int tabCount) {
Dimension size = new Dimension();
for (TabInfo each : myVisibleInfos) {
final JComponent c = each.getComponent();
if (c != null) {
final Dimension eachSize = transform.fun(c);
size.width = Math.max(eachSize.width, size.width);
size.height = Math.max(eachSize.height, size.height);
}
}
addHeaderSize(size, tabCount);
return size;
}
示例12: ListSpeedSearch
import com.intellij.util.Function; //導入方法依賴的package包/類
public ListSpeedSearch(final JList component, final Function<Object, String> convertor) {
this(component, new Convertor<Object, String>() {
@Override
public String convert(Object o) {
return convertor.fun(o);
}
});
}
示例13: getDocumentationForElement
import com.intellij.util.Function; //導入方法依賴的package包/類
@Nullable
public static String getDocumentationForElement(Object element) {
for (final Function<Object, String> function : ourDocumentationProviders) {
final String s = function.fun(element);
if (s != null) {
return s;
}
}
return null;
}
示例14: getColorForObject
import com.intellij.util.Function; //導入方法依賴的package包/類
@Nullable
public static <T> Color getColorForObject(T object, Project project, @NotNull Function<T, PsiElement> converter) {
Color color = null;
final PsiElement psi = converter.fun(object);
if (psi != null) {
if (!psi.isValid()) return null;
final VirtualFile file = PsiUtilCore.getVirtualFile(psi);
if (file != null) {
color = FileColorManager.getInstance(project).getFileColor(file);
} else if (psi instanceof PsiDirectory) {
color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
} else if (psi instanceof PsiDirectoryContainer) {
final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
for (PsiDirectory dir : dirs) {
Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
if (c != null && color == null) {
color = c;
} else if (c != null) {
color = null;
break;
}
}
}
}
return color == null ? null : ColorUtil.softer(color);
}
示例15: checkReferenceRange
import com.intellij.util.Function; //導入方法依賴的package包/類
@Nullable
private PsiReference checkReferenceRange(PsiElement element, Function<Integer, PsiReference> fn) {
final int start = myReferenceRangeMarker.getStartOffset() - element.getTextRange().getStartOffset();
final int end = myReferenceRangeMarker.getEndOffset() - element.getTextRange().getStartOffset();
final PsiReference reference = fn.fun(start);
if (reference == null) {
return null;
}
final TextRange rangeInElement = reference.getRangeInElement();
if (rangeInElement.getStartOffset() != start || rangeInElement.getEndOffset() != end) {
return null;
}
return reference;
}