本文整理汇总了Java中com.intellij.util.PairFunction类的典型用法代码示例。如果您正苦于以下问题:Java PairFunction类的具体用法?Java PairFunction怎么用?Java PairFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PairFunction类属于com.intellij.util包,在下文中一共展示了PairFunction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: paintEmptyText
import com.intellij.util.PairFunction; //导入依赖的package包/类
public void paintEmptyText(@NotNull final JComponent splitters, @NotNull Graphics g) {
UISettings.setupAntialiasing(g);
g.setColor(new JBColor(Gray._80, Gray._160));
g.setFont(JBUI.Fonts.label(16f));
UIUtil.TextPainter painter = new UIUtil.TextPainter().withLineSpacing(1.8f);
advertiseActions(splitters, painter);
painter.draw(g, new PairFunction<Integer, Integer, Couple<Integer>>() {
@Override
public Couple<Integer> fun(Integer width, Integer height) {
Dimension s = splitters.getSize();
int w = (s.width - width) / 2;
int h = s.height * 3 / 8; // fix vertical position @ golden ratio
return Couple.of(w, h);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EditorEmptyTextPainter.java
示例2: paint
import com.intellij.util.PairFunction; //导入依赖的package包/类
@Override
public void paint(Graphics g) {
boolean isDarkBackground = UIUtil.isUnderDarcula();
UISettings.setupAntialiasing(g);
g.setColor(new JBColor(isDarkBackground ? Gray._230 : Gray._80, Gray._160));
g.setFont(JBUI.Fonts.label(isDarkBackground ? 24f : 20f));
UIUtil.TextPainter painter = new UIUtil.TextPainter().withLineSpacing(1.5f);
painter.withShadow(true, new JBColor(Gray._200.withAlpha(100), Gray._0.withAlpha(255)));
painter.appendLine("No files are open");//.underlined(new JBColor(Gray._150, Gray._180));
painter.draw(g, new PairFunction<Integer, Integer, Couple<Integer>>() {
@Override
public Couple<Integer> fun(Integer width, Integer height) {
Dimension s = EmptyStatePanel.this.getSize();
return Couple.of((s.width - width) / 2, (s.height - height) / 2);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PreviewManagerImpl.java
示例3: generate
import com.intellij.util.PairFunction; //导入依赖的package包/类
@NotNull
public static <E> JBIterable<E> generate(@Nullable final E first1, @Nullable final E first2, @NotNull final PairFunction<? super E, ? super E, ? extends E> generator) {
if (first1 == null) return empty();
return new JBIterable<E>() {
@Override
public Iterator<E> iterator() {
return new JBIterator<E>() {
E cur1 = first1;
E cur2 = first2;
@Override
public E nextImpl() {
E result = cur1;
cur1 = cur2;
cur2 = generator.fun(result, cur2);
if (result == null) return stop();
return result;
}
};
}
};
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JBIterable.java
示例4: GutteredLanguageConsole
import com.intellij.util.PairFunction; //导入依赖的package包/类
public GutteredLanguageConsole(@NotNull String title,
@NotNull Project project,
@NotNull Language language,
@Nullable GutterContentProvider gutterContentProvider,
@Nullable final PairFunction<VirtualFile, Project, PsiFile> psiFileFactory) {
super(new Helper(project, new LightVirtualFile(title, language, "")) {
@NotNull
@Override
public PsiFile getFile() {
return psiFileFactory == null ? super.getFile() : psiFileFactory.fun(virtualFile, project);
}
});
this.gutterContentProvider = gutterContentProvider == null ? new BasicGutterContentProvider() : gutterContentProvider;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:LanguageConsoleBuilder.java
示例5: findScopesWithItemRef
import com.intellij.util.PairFunction; //导入依赖的package包/类
private static Map<String, XmlTag> findScopesWithItemRef(@Nullable PsiFile file) {
if (!(file instanceof XmlFile)) return Collections.emptyMap();
final Map<String, XmlTag> result = new THashMap<String, XmlTag>();
file.accept(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlTag(final XmlTag tag) {
super.visitXmlTag(tag);
XmlAttribute refAttr = tag.getAttribute(ITEM_REF);
if (refAttr != null && tag.getAttribute(ITEM_SCOPE) != null) {
getReferencesForAttributeValue(refAttr.getValueElement(), new PairFunction<String, Integer, PsiReference>() {
@Nullable
@Override
public PsiReference fun(String t, Integer v) {
result.put(t, tag);
return null;
}
});
}
}
});
return result;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:MicrodataUtil.java
示例6: getReferencesForAttributeValue
import com.intellij.util.PairFunction; //导入依赖的package包/类
public static PsiReference[] getReferencesForAttributeValue(@Nullable XmlAttributeValue element,
PairFunction<String, Integer, PsiReference> refFun) {
if (element == null) {
return PsiReference.EMPTY_ARRAY;
}
String text = element.getText();
String urls = StringUtil.unquoteString(text);
StringTokenizer tokenizer = new StringTokenizer(urls);
List<PsiReference> result = new ArrayList<PsiReference>();
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
int index = text.indexOf(token);
PsiReference ref = refFun.fun(token, index);
if (ref != null) {
result.add(ref);
}
}
return result.toArray(new PsiReference[result.size()]);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MicrodataUtil.java
示例7: getQualifierCastType
import com.intellij.util.PairFunction; //导入依赖的package包/类
@Nullable
private static PsiType getQualifierCastType(PsiJavaReference javaReference, CompletionParameters parameters) {
if (javaReference instanceof PsiReferenceExpression) {
final PsiReferenceExpression refExpr = (PsiReferenceExpression)javaReference;
final PsiExpression qualifier = refExpr.getQualifierExpression();
if (qualifier != null) {
final Project project = qualifier.getProject();
PsiType type = null;
final PairFunction<PsiExpression, CompletionParameters, PsiType> evaluator = refExpr.getContainingFile().getCopyableUserData(DYNAMIC_TYPE_EVALUATOR);
if (evaluator != null) {
type = evaluator.fun(qualifier, parameters);
}
if (type == null) {
type = GuessManager.getInstance(project).getControlFlowExpressionType(qualifier);
}
return type;
}
}
return null;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:JavaCompletionUtil.java
示例8: getReferencesForAttributeValue
import com.intellij.util.PairFunction; //导入依赖的package包/类
public static PsiReference[] getReferencesForAttributeValue(@Nullable XmlAttributeValue element,
PairFunction<String, Integer, PsiReference> refFun) {
if (element == null) {
return PsiReference.EMPTY_ARRAY;
}
String text = element.getText();
String urls = StringUtil.stripQuotesAroundValue(text);
StringTokenizer tokenizer = new StringTokenizer(urls);
List<PsiReference> result = new ArrayList<PsiReference>();
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
int index = text.indexOf(token);
PsiReference ref = refFun.fun(token, index);
if (ref != null) {
result.add(ref);
}
}
return result.toArray(new PsiReference[result.size()]);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:MicrodataUtil.java
示例9: calcBinary
import com.intellij.util.PairFunction; //导入依赖的package包/类
@Nullable
public static Object calcBinary(IElementType elementType, Object p1, Object p2)
{
Couple<Class> key = Couple.<Class>of(p1.getClass(), p2.getClass());
Map<IElementType, PairFunction<Object, Object, Object>> map = ourOperators.get(key);
if(map == null)
{
return null;
}
PairFunction<Object, Object, Object> function = map.get(elementType);
if(function == null)
{
return null;
}
return function.fun(p1, p2);
}
开发者ID:consulo,项目名称:consulo-csharp,代码行数:19,代码来源:OperatorEvaluator.java
示例10: processParameterList
import com.intellij.util.PairFunction; //导入依赖的package包/类
private static void processParameterList(final DotNetParameterListOwner declaration, StringBuilder builder, char p1, char p2)
{
builder.append(p1);
StubBlockUtil.join(builder, declaration.getParameters(), new PairFunction<StringBuilder, DotNetParameter, Void>()
{
@Nullable
@Override
@RequiredReadAction
public Void fun(StringBuilder t, DotNetParameter v)
{
appendAttributeList(t, v);
processModifierList(t, v);
DotNetTypeRef typeRef = v.toTypeRef(false);
appendTypeRef(declaration, t, typeRef);
if(typeRef != CSharpStaticTypeRef.__ARGLIST_TYPE)
{
t.append(" ");
appendValidName(t, v.getName());
appendInitializer(t, v);
}
return null;
}
}, ", ");
builder.append(p2);
}
开发者ID:consulo,项目名称:consulo-csharp,代码行数:26,代码来源:CSharpStubBuilderVisitor.java
示例11: showCheckboxMessageDialog
import com.intellij.util.PairFunction; //导入依赖的package包/类
public static int showCheckboxMessageDialog(String message,
String title,
@Nonnull String[] options,
String checkboxText,
final boolean checked,
final int defaultOptionIndex,
final int focusedOptionIndex,
Icon icon,
@Nullable final PairFunction<Integer, JCheckBox, Integer> exitFunc) {
if (isApplicationInUnitTestOrHeadless()) {
return ourTestImplementation.show(message);
}
else {
TwoStepConfirmationDialog dialog =
new TwoStepConfirmationDialog(message, title, options, checkboxText, checked, defaultOptionIndex, focusedOptionIndex, icon, exitFunc);
dialog.show();
return dialog.getExitCode();
}
}
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:Messages.java
示例12: jumpTo
import com.intellij.util.PairFunction; //导入依赖的package包/类
private <T> void jumpTo(@Nonnull final T commitId,
@Nonnull final PairFunction<GraphTableModel, T, Integer> rowGetter,
@Nonnull final SettableFuture<Boolean> future) {
if (future.isCancelled()) return;
GraphTableModel model = getTable().getModel();
int row = rowGetter.fun(model, commitId);
if (row >= 0) {
myMainFrame.getGraphTable().jumpToRow(row);
future.set(true);
}
else if (model.canRequestMore()) {
model.requestToLoadMore(() -> jumpTo(commitId, rowGetter, future));
}
else if (!myVisiblePack.isFull()) {
invokeOnChange(() -> jumpTo(commitId, rowGetter, future));
}
else {
commitNotFound(commitId.toString());
future.set(false);
}
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:VcsLogUiImpl.java
示例13: getReferencesForAttributeValue
import com.intellij.util.PairFunction; //导入依赖的package包/类
public static PsiReference[] getReferencesForAttributeValue(@Nullable XmlAttributeValue element, PairFunction<String, Integer, PsiReference> refFun)
{
if(element == null)
{
return PsiReference.EMPTY_ARRAY;
}
String text = element.getText();
String urls = StringUtil.unquoteString(text);
StringTokenizer tokenizer = new StringTokenizer(urls);
List<PsiReference> result = new ArrayList<>();
while(tokenizer.hasMoreTokens())
{
String token = tokenizer.nextToken();
int index = text.indexOf(token);
PsiReference ref = refFun.fun(token, index);
if(ref != null)
{
result.add(ref);
}
}
return result.toArray(new PsiReference[result.size()]);
}
开发者ID:consulo,项目名称:consulo-xml,代码行数:23,代码来源:MicrodataUtil.java
示例14: getQualifierCastType
import com.intellij.util.PairFunction; //导入依赖的package包/类
@Nullable
private static PsiType getQualifierCastType(PsiJavaReference javaReference, CompletionParameters parameters)
{
if(javaReference instanceof PsiReferenceExpression)
{
final PsiReferenceExpression refExpr = (PsiReferenceExpression) javaReference;
final PsiExpression qualifier = refExpr.getQualifierExpression();
if(qualifier != null)
{
final Project project = qualifier.getProject();
PsiType type = null;
final PairFunction<PsiExpression, CompletionParameters, PsiType> evaluator = refExpr.getContainingFile().getCopyableUserData(DYNAMIC_TYPE_EVALUATOR);
if(evaluator != null)
{
type = evaluator.fun(qualifier, parameters);
}
if(type == null)
{
type = GuessManager.getInstance(project).getControlFlowExpressionType(qualifier);
}
return type;
}
}
return null;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:JavaCompletionUtil.java
示例15: setDeclaredAttributeValue
import com.intellij.util.PairFunction; //导入依赖的package包/类
@Nullable
public static PsiAnnotationMemberValue setDeclaredAttributeValue(@NotNull PsiAnnotation psiAnnotation,
@Nullable String attributeName,
@Nullable PsiAnnotationMemberValue value,
@NotNull PairFunction<Project, String, PsiAnnotation> annotationCreator) {
PsiAnnotationMemberValue existing = psiAnnotation.findDeclaredAttributeValue(attributeName);
if (value == null) {
if (existing == null) {
return null;
}
existing.getParent().delete();
}
else {
if (existing != null) {
((PsiNameValuePair)existing.getParent()).setValue(value);
}
else {
PsiNameValuePair[] attributes = psiAnnotation.getParameterList().getAttributes();
if (attributes.length == 1) {
PsiNameValuePair attribute = attributes[0];
if (attribute.getName() == null) {
PsiAnnotationMemberValue defValue = attribute.getValue();
assert defValue != null : attribute;
attribute.replace(createNameValuePair(defValue, PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME + "=", annotationCreator));
}
}
boolean allowNoName = attributes.length == 0 && ("value".equals(attributeName) || null == attributeName);
final String namePrefix;
if (allowNoName) {
namePrefix = "";
}
else {
namePrefix = attributeName + "=";
}
psiAnnotation.getParameterList().addBefore(createNameValuePair(value, namePrefix, annotationCreator), null);
}
}
return psiAnnotation.findDeclaredAttributeValue(attributeName);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:PsiImplUtil.java
示例16: runDfa
import com.intellij.util.PairFunction; //导入依赖的package包/类
/**
* @return true if completed, false if "too complex"
*/
private boolean runDfa(boolean forward, PairFunction<Instruction, BitSet, BitSet> handleState) {
Set<Instruction> entryPoints = ContainerUtil.newHashSet();
if (forward) {
entryPoints.add(myInstructions[0]);
} else {
entryPoints.addAll(ContainerUtil.findAll(myInstructions, FilteringIterator.instanceOf(ReturnInstruction.class)));
}
Queue<InstructionState> queue = new Queue<InstructionState>(10);
for (Instruction i : entryPoints) {
queue.addLast(new InstructionState(i, new BitSet()));
}
int limit = myForwardMap.size() * 20;
Set<InstructionState> processed = ContainerUtil.newHashSet();
while (!queue.isEmpty()) {
int steps = processed.size();
if (steps > limit) {
return false;
}
if (steps % 1024 == 0) {
ProgressManager.checkCanceled();
}
InstructionState state = queue.pullFirst();
Instruction instruction = state.first;
Collection<Instruction> nextInstructions = forward ? myForwardMap.get(instruction) : myBackwardMap.get(instruction);
BitSet nextVars = handleState.fun(instruction, state.second);
for (Instruction next : nextInstructions) {
InstructionState nextState = new InstructionState(next, nextVars);
if (processed.add(nextState)) {
queue.addLast(nextState);
}
}
}
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:LiveVariablesAnalyzer.java
示例17: showCheckboxOkCancelDialog
import com.intellij.util.PairFunction; //导入依赖的package包/类
public static int showCheckboxOkCancelDialog(String message, @Nls(capitalization = Nls.Capitalization.Title) String title, String checkboxText, final boolean checked,
final int defaultOptionIndex, final int focusedOptionIndex, Icon icon) {
return showCheckboxMessageDialog(message, title, new String[]{OK_BUTTON, CANCEL_BUTTON}, checkboxText, checked, defaultOptionIndex,
focusedOptionIndex, icon,
new PairFunction<Integer, JCheckBox, Integer>() {
@Override
public Integer fun(final Integer exitCode, final JCheckBox cb) {
return exitCode == -1 ? CANCEL : exitCode + (cb.isSelected() ? 1 : 0);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:Messages.java
示例18: showCheckboxMessageDialog
import com.intellij.util.PairFunction; //导入依赖的package包/类
public static int showCheckboxMessageDialog(String message, @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String[] options, String checkboxText, final boolean checked,
final int defaultOptionIndex, final int focusedOptionIndex, Icon icon,
@Nullable final PairFunction<Integer, JCheckBox, Integer> exitFunc) {
if (isApplicationInUnitTestOrHeadless()) {
return ourTestImplementation.show(message);
}
else {
TwoStepConfirmationDialog dialog = new TwoStepConfirmationDialog(message, title, options, checkboxText, checked, defaultOptionIndex,
focusedOptionIndex, icon, exitFunc);
dialog.show();
return dialog.getExitCode();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:Messages.java
示例19: TwoStepConfirmationDialog
import com.intellij.util.PairFunction; //导入依赖的package包/类
public TwoStepConfirmationDialog(String message, @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String[] options, String checkboxText, boolean checked, final int defaultOptionIndexed,
final int focusedOptionIndex, Icon icon, @Nullable final PairFunction<Integer, JCheckBox, Integer> exitFunc) {
myCheckboxText = checkboxText;
myChecked = checked;
myExitFunc = exitFunc;
_init(title, message, options, defaultOptionIndexed, focusedOptionIndex, icon, null);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:Messages.java
示例20: jumpToCommit
import com.intellij.util.PairFunction; //导入依赖的package包/类
@NotNull
public Future<Boolean> jumpToCommit(@NotNull Hash commitHash) {
SettableFuture<Boolean> future = SettableFuture.create();
jumpTo(commitHash, new PairFunction<GraphTableModel, Hash, Integer>() {
@Override
public Integer fun(GraphTableModel model, Hash hash) {
return model.getRowOfCommit(hash);
}
}, future);
return future;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:VcsLogUiImpl.java
注:本文中的com.intellij.util.PairFunction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论