本文整理了Java中com.intellij.openapi.util.Pair.getFirst()
方法的一些代码示例,展示了Pair.getFirst()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pair.getFirst()
方法的具体详情如下:
包路径:com.intellij.openapi.util.Pair
类名称:Pair
方法名:getFirst
暂无
代码示例来源:origin: hsz/idea-gitignore
/**
* Gets value using passed key. Returns null if expired.
*
* @param key to check
* @return value or null
if expired
*/
@Nullable
public V get(@NotNull K key) {
long current = System.currentTimeMillis();
final Pair
if (data != null) {
if ((data.getSecond() + time) > current) {
return data.getFirst();
}
map.remove(key);
}
return null;
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
public void apply(ProcessHandler listener) {
for (Pair
listener.notifyTextAvailable(pair.getFirst().getText(), pair.getSecond());
}
}
}
代码示例来源:origin: ballerina-platform/ballerina-lang
public void apply(ProcessHandler listener) {
for (Pair
listener.notifyTextAvailable(pair.getFirst().getText(), pair.getSecond());
}
}
}
代码示例来源:origin: JetBrains/ideavim
@Override
public boolean apply(@NotNull Editor editor, @NotNull DataContext context, @NotNull SelectionType selectionType) {
final char c = getChar(editor);
if (c == 0) {
return true;
}
final Pair
if (pair == null) {
return false;
}
// XXX: Will it work with line-wise or block-wise selections?
final TextRange range = getSurroundRange(editor);
if (range == null) {
return false;
}
WriteAction.run(() -> {
final ChangeGroup change = VimPlugin.getChange();
final String leftSurround = pair.getFirst();
final Caret primaryCaret = editor.getCaretModel().getPrimaryCaret();
primaryCaret.moveToOffset(range.getStartOffset());
change.insertText(editor, primaryCaret, leftSurround);
primaryCaret.moveToOffset(range.getEndOffset() + leftSurround.length());
change.insertText(editor, primaryCaret, pair.getSecond());
// Jump back to start
executeNormal(parseKeys("`["), editor);
});
return true;
}
代码示例来源:origin: JetBrains/ideavim
@Nullable
public static TextRange findBlockTagRange(@NotNull Editor editor, @NotNull Caret caret, int count, boolean isOuter) {
final int cursorOffset = caret.getOffset();
int pos = cursorOffset;
int currentCount = count;
final CharSequence sequence = editor.getDocument().getCharsSequence();
while (true) {
final Pair
if (closingTagResult == null) {
return null;
}
final TextRange closingTagTextRange = closingTagResult.getFirst();
final String tagName = closingTagResult.getSecond();
final TextRange openingTagTextRange = findOpeningTag(sequence, closingTagTextRange.getStartOffset(), tagName);
if (openingTagTextRange != null && openingTagTextRange.getStartOffset() <= cursorOffset && --currentCount == 0) {
if (isOuter) {
return new TextRange(openingTagTextRange.getStartOffset(), closingTagTextRange.getEndOffset());
}
else {
return new TextRange(openingTagTextRange.getEndOffset() + 1, closingTagTextRange.getStartOffset() - 1);
}
}
else {
pos = closingTagTextRange.getEndOffset() + 1;
}
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Override
public void accept(Pair
values.add(pair.getFirst());
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* {% import _self as foobar %}
* {% import 'foobar.html.twig' as foobar %}
*/
public static Collection
Collection
visitImportedMacrosNamespaces(psiFile, pair -> macros.add(pair.getFirst()));
return macros;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@NotNull
public static Set
Set
visitXliffTranslations(content, pair -> set.add(pair.getFirst()));
return set;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Override
public void accept(Pair
if(pair.getFirst().equalsIgnoreCase(filterValue)) {
values.add(pair.getSecond());
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@NotNull
public static Collection
Collection
DotEnvUtil.visitEnvironment(project, pair -> {
if(environmentVariable.equals(pair.getFirst())) {
items.add(pair.getSecond());
}
});
return items;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* Find targets for given macros, alias supported
*
* {% import _self as foobar %}
* {{ foobar.bar() }}
*/
public static Collection
Collection
visitImportedMacrosNamespaces(psiFile, pair -> {
if(pair.getFirst().getName().equals(macroName)) {
macros.add(pair.getSecond());
}
});
return macros;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@NotNull
@Override
public Collection
Collection
for (Pair
elements.add(LookupElementBuilder.create(pair.getFirst()).withIcon(Symfony2Icons.DOCTRINE));
}
return elements;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Override
public void accept(Pair
String name = pair.getFirst();
if (!elements.contains(name)) {
LookupElementBuilder lookupElement = LookupElementBuilder.create(name).withIcon(Symfony2Icons.SYMFONY);
PhpClass phpClass = PsiTreeUtil.getParentOfType(pair.getSecond(), PhpClass.class);
if (phpClass != null) {
lookupElement = lookupElement.withTypeText(phpClass.getName(), true);
}
lookupElements.add(lookupElement);
elements.add(name);
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) throws IncorrectOperationException {
Pair
if(pair == null) {
return;
}
new TranslationKeyIntentionAndQuickFixAction(pair.getFirst(), pair.getSecond(), new MyKeyDomainNotExistingCollector())
.invoke(project, editor, psiElement.getContainingFile());
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void update(AnActionEvent event) {
Project project = event.getData(PlatformDataKeys.PROJECT);
if (project == null || !Symfony2ProjectComponent.isEnabled(project)) {
this.setStatus(event, false);
return;
}
Pair
if(pair == null) {
return;
}
PsiFile psiFile = pair.getFirst();
if(!(psiFile instanceof YAMLFile) && !(psiFile instanceof XmlFile) && !(psiFile instanceof PhpFile)) {
this.setStatus(event, false);
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void assertLocalInspectionContains(String filename, String content, String contains) {
Set
Pair, Integer> localInspectiOnsAtCaret= getLocalInspectionsAtCaret(filename, content);
for (ProblemDescriptor result : localInspectionsAtCaret.getFirst()) {
TextRange textRange = result.getPsiElement().getTextRange();
if (textRange.contains(localInspectionsAtCaret.getSecond()) && result.toString().equals(contains)) {
return;
}
matches.add(result.toString());
}
fail(String.format("Fail matches '%s' with one of %s", contains, matches));
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.doctrine.metadata.util.DoctrineMetadataUtil#getTables
*/
public void testGetTables() {
Map
Collection
for (Pair
items.put(pair.getFirst(), pair.getSecond());
}
assertContainsElements(items.keySet(), "cms_users", "foo_table");
assertNotNull(items.get("cms_users"));
assertNotNull(items.get("foo_table"));
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void assertLocalInspectionNotContains(String filename, String content, String contains) {
Pair, Integer> localInspectiOnsAtCaret= getLocalInspectionsAtCaret(filename, content);
for (ProblemDescriptor result : localInspectionsAtCaret.getFirst()) {
TextRange textRange = result.getPsiElement().getTextRange();
if (textRange.contains(localInspectionsAtCaret.getSecond()) && result.toString().contains(contains)) {
fail(String.format("Fail inspection not contains '%s'", contains));
}
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void testGetTemplateAnnotationFiles() {
PhpDocTag phpPsiFromText = PhpPsiElementFactory.createPhpPsiFromText(getProject(), PhpDocTag.class, "/** @Template(\"foo.html.twig\") */");
assertEquals("foo.html.twig", TwigUtil.getTemplateAnnotationFiles(phpPsiFromText).getFirst());
phpPsiFromText = PhpPsiElementFactory.createPhpPsiFromText(getProject(), PhpDocTag.class, "/** @Template(template=\"foo.html.twig\") */");
assertEquals("foo.html.twig", TwigUtil.getTemplateAnnotationFiles(phpPsiFromText).getFirst());
phpPsiFromText = PhpPsiElementFactory.createPhpPsiFromText(getProject(), PhpDocTag.class, "/** @Template(template=\"foo\\foo.html.twig\") */");
assertEquals("foo/foo.html.twig", TwigUtil.getTemplateAnnotationFiles(phpPsiFromText).getFirst());
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.templating.util.TwigUtil#getTwigMacroNameAndParameter
*/
public void testGetTwigMacroNameAndParameter() {
PsiElement psiElement = TwigElementFactory.createPsiElement(
getProject(),
"{% macro foo(foobar, foo, bar) %}{% endmacro %}",
TwigElementTypes.MACRO_TAG
);
Pair
assertNotNull(parameter);
assertEquals("foo", parameter.getFirst());
assertEquals("(foobar, foo, bar)", parameter.getSecond());
}