org.junit.jupiter.api.extension.ExtendWith#com.intellij.openapi.util.Pair源码实例Demo

下面列出了org.junit.jupiter.api.extension.ExtendWith#com.intellij.openapi.util.Pair 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lsp4intellij   文件: LSPReferencesAction.java
@Override
public void actionPerformed(AnActionEvent e) {
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (editor != null) {
        EditorEventManager eventManager = EditorEventManagerBase.forEditor(editor);
        if (eventManager == null) {
            return;
        }
        List<PsiElement2UsageTargetAdapter> targets = new ArrayList<>();
        Pair<List<PsiElement>, List<VirtualFile>> references = eventManager
                .references(editor.getCaretModel().getCurrentCaret().getOffset());
        if (references.first != null && references.second != null) {
            references.first.forEach(element -> targets.add(new PsiElement2UsageTargetAdapter(element)));
        }
        showReferences(editor, targets, editor.getCaretModel().getCurrentCaret().getLogicalPosition());
    }
}
 
源代码2 项目: idea-gitignore   文件: GeneratorDialog.java
/**
 * Updates editor's content depending on the selected {@link TreePath}.
 *
 * @param path selected tree path
 */
private void updateDescriptionPanel(@NotNull TreePath path) {
    final TemplateTreeNode node = (TemplateTreeNode) path.getLastPathComponent();
    final Resources.Template template = node.getTemplate();

    ApplicationManager.getApplication().runWriteAction(
            () -> CommandProcessor.getInstance().runUndoTransparentAction(() -> {
                String content = template != null ?
                        StringUtil.notNullize(template.getContent()).replace('\r', '\0') : "";
                previewDocument.replaceString(0, previewDocument.getTextLength(), content);

                List<Pair<Integer, Integer>> pairs =
                        getFilterRanges(profileFilter.getTextEditor().getText(), content);
                highlightWords(pairs);
            })
    );
}
 
源代码3 项目: consulo   文件: ShowIntentionsPass.java
public static boolean markActionInvoked(@Nonnull Project project, @Nonnull final Editor editor, @Nonnull IntentionAction action) {
  final int offset = ((EditorEx)editor).getExpectedCaretOffset();

  List<HighlightInfo> infos = new ArrayList<>();
  DaemonCodeAnalyzerImpl.processHighlightsNearOffset(editor.getDocument(), project, HighlightSeverity.INFORMATION, offset, true, new CommonProcessors.CollectProcessor<>(infos));
  boolean removed = false;
  for (HighlightInfo info : infos) {
    if (info.quickFixActionMarkers != null) {
      for (Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> pair : info.quickFixActionMarkers) {
        HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
        if (actionInGroup.getAction() == action) {
          // no CME because the list is concurrent
          removed |= info.quickFixActionMarkers.remove(pair);
        }
      }
    }
  }
  return removed;
}
 
@Override
protected final void doExecute(@NotNull final Editor editor, @Nullable final Caret caret, final DataContext dataContext) {
    MyApplicationComponent.setAction(actionClass);

    final Pair<Boolean, T> additionalParameter = beforeWriteAction(editor, dataContext);
    if (!additionalParameter.first) {
        return;
    }

    final Runnable runnable = () -> executeWriteAction(editor, caret, dataContext, additionalParameter.second);
    new EditorWriteActionHandler(false) {
        @Override
        public void executeWriteAction(Editor editor1, @Nullable Caret caret1, DataContext dataContext1) {
            runnable.run();
        }
    }.doExecute(editor, caret, dataContext);
}
 
源代码5 项目: consulo   文件: TabbedShowHistoryAction.java
@Nonnull
private static Pair<FilePath, VirtualFile> getPathAndParentFile(@Nonnull VcsContext context) {
  if (context.getSelectedFilesStream().findAny().isPresent()) {
    VirtualFile file = getIfSingle(context.getSelectedFilesStream());
    return file != null ? Pair.create(VcsUtil.getFilePath(file), file) : Pair.empty();
  }

  File[] ioFiles = context.getSelectedIOFiles();
  if (ioFiles != null && ioFiles.length > 0) {
    for (File ioFile : ioFiles) {
      VirtualFile parent = getParentVirtualFile(ioFile);
      if (parent != null) return Pair.create(VcsUtil.getFilePath(parent, ioFile.getName()), parent);
    }
  }

  return Pair.empty();
}
 
源代码6 项目: consulo   文件: TypoTolerantMatcher.java
private boolean processErrors(int start, int end, Processor<? super Pair<Integer, Error>> processor) {
  if (myBase != null && start < myDeriveIndex) {
    if (!myBase.processErrors(start, myDeriveIndex, processor)) {
      return false;
    }
  }

  if (myErrors != null) {
    for (Pair<Integer, Error> error : myErrors) {
      if (start <= error.first && error.first < end) {
        if (!processor.process(error)) {
          return false;
        }
      }
    }
  }

  return true;
}
 
源代码7 项目: consulo   文件: ComponentStoreImpl.java
@Override
public final void save(@Nonnull List<Pair<StateStorage.SaveSession, File>> readonlyFiles) {
  ExternalizationSession externalizationSession = myComponents.isEmpty() ? null : getStateStorageManager().startExternalization();
  if (externalizationSession != null) {
    String[] names = ArrayUtil.toStringArray(myComponents.keySet());
    Arrays.sort(names);
    for (String name : names) {
      StateComponentInfo<?> componentInfo = myComponents.get(name);

      commitComponentInsideSingleUIWriteThread(componentInfo, externalizationSession);
    }
  }

  for (SettingsSavingComponent settingsSavingComponent : mySettingsSavingComponents) {
    try {
      settingsSavingComponent.save();
    }
    catch (Throwable e) {
      LOG.error(e);
    }
  }

  doSave(externalizationSession == null ? null : externalizationSession.createSaveSessions(), readonlyFiles);
}
 
源代码8 项目: consulo   文件: ShowIntentionActionsHandler.java
@Nullable
public static Pair<PsiFile, Editor> chooseBetweenHostAndInjected(@Nonnull PsiFile hostFile,
                                                                 @Nonnull Editor hostEditor,
                                                                 @Nullable PsiFile injectedFile,
                                                                 @Nonnull PairProcessor<? super PsiFile, ? super Editor> predicate) {
  Editor editorToApply = null;
  PsiFile fileToApply = null;

  Editor injectedEditor = null;
  if (injectedFile != null) {
    injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(hostEditor, injectedFile);
    if (predicate.process(injectedFile, injectedEditor)) {
      editorToApply = injectedEditor;
      fileToApply = injectedFile;
    }
  }

  if (editorToApply == null && hostEditor != injectedEditor && predicate.process(hostFile, hostEditor)) {
    editorToApply = hostEditor;
    fileToApply = hostFile;
  }
  if (editorToApply == null) return null;
  return Pair.create(fileToApply, editorToApply);
}
 
源代码9 项目: consulo   文件: Messages.java
@Nonnull
public static Pair<String, Boolean> showInputDialogWithCheckBox(String message,
                                                                String title,
                                                                String checkboxText,
                                                                boolean checked,
                                                                boolean checkboxEnabled,
                                                                @Nullable Icon icon,
                                                                @NonNls String initialValue,
                                                                @Nullable InputValidator validator) {
  if (isApplicationInUnitTestOrHeadless()) {
    return new Pair<String, Boolean>(ourTestInputImplementation.show(message), checked);
  }
  else {
    InputDialogWithCheckbox dialog = new InputDialogWithCheckbox(message, title, checkboxText, checked, checkboxEnabled, icon, initialValue, validator);
    dialog.show();
    return new Pair<String, Boolean>(dialog.getInputString(), dialog.isChecked());
  }
}
 
源代码10 项目: consulo   文件: NamedScopeDescriptor.java
@Override
public boolean matches(@Nonnull PsiFile psiFile) {
  Pair<NamedScopesHolder, NamedScope> resolved = resolveScope(psiFile.getProject());
  if (resolved == null) {
    resolved = resolveScope(ProjectManager.getInstance().getDefaultProject());
  }
  if (resolved != null) {
    PackageSet fileSet = resolved.second.getValue();
    if (fileSet != null) {
      return fileSet.contains(psiFile, resolved.first);
    }
  }
  if (myFileSet != null) {
    NamedScopesHolder holder = DependencyValidationManager.getInstance(psiFile.getProject());
    return myFileSet.contains(psiFile, holder);
  }
  return false;
}
 
源代码11 项目: consulo   文件: PersistentFSImpl.java
private void applyCreateEventsInDirectory(@Nonnull VirtualDirectoryImpl parent, @Nonnull Collection<? extends VFileCreateEvent> createEvents) {
  int parentId = getFileId(parent);
  NewVirtualFile vf = findFileById(parentId);
  if (!(vf instanceof VirtualDirectoryImpl)) return;
  parent = (VirtualDirectoryImpl)vf;  // retain in myIdToDirCache at least for the duration of this block in order to subsequent findFileById() won't crash
  final NewVirtualFileSystem delegate = replaceWithNativeFS(getDelegate(parent));
  TIntHashSet parentChildrenIds = new TIntHashSet(createEvents.size());

  List<ChildInfo> childrenAdded = getOrCreateChildInfos(parent, createEvents, VFileCreateEvent::getChildName, parentChildrenIds, delegate, (createEvent, childId) -> {
    createEvent.resetCache();
    String name = createEvent.getChildName();
    Pair<FileAttributes, String> childData = getChildData(delegate, createEvent.getParent(), name, createEvent.getAttributes(), createEvent.getSymlinkTarget());
    if (childData == null) return null;
    childId = makeChildRecord(parentId, name, childData, delegate);
    return new ChildInfoImpl(childId, name, childData.first, createEvent.getChildren(), createEvent.getSymlinkTarget());
  });
  FSRecords.updateList(parentId, parentChildrenIds.toArray());
  parent.createAndAddChildren(childrenAdded, false, (__, ___) -> {
  });

  saveScannedChildrenRecursively(createEvents, delegate);
}
 
源代码12 项目: p4ic4idea   文件: P4CommandUtil.java
public List<Pair<IFileSpec, IFileRevisionData>> getExactHistory(IOptionsServer server, List<IFileSpec> specs)
        throws P4JavaException {
    GetRevisionHistoryOptions opts = new GetRevisionHistoryOptions()
            .setMaxRevs(1)
            .setContentHistory(false)
            .setIncludeInherited(false)
            .setLongOutput(true)
            .setTruncatedLongOutput(false);
    Map<IFileSpec, List<IFileRevisionData>> res = server.getRevisionHistory(specs, opts);
    List<Pair<IFileSpec, IFileRevisionData>> ret = new ArrayList<>(res.size());
    for (Map.Entry<IFileSpec, List<IFileRevisionData>> entry: res.entrySet()) {
        // it can return empty values for a server message
        List<IFileRevisionData> value = entry.getValue();
        if (value != null && !value.isEmpty()) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Mapped " + entry.getKey().getDepotPath() + " to " + entry.getValue());
            }
            if (entry.getValue().size() != 1) {
                throw new IllegalStateException("Unexpected revision count for " + entry.getKey().getDepotPath());
            }
            ret.add(Pair.create(entry.getKey(), entry.getValue().get(0)));
        }
    }
    return ret;
}
 
源代码13 项目: consulo   文件: PathsVerifier.java
@Nonnull
public Collection<FilePatch> filterBadFileTypePatches() {
  List<Pair<VirtualFile, ApplyTextFilePatch>> failedTextPatches =
          ContainerUtil.findAll(myTextPatches, new Condition<Pair<VirtualFile, ApplyTextFilePatch>>() {
            @Override
            public boolean value(Pair<VirtualFile, ApplyTextFilePatch> textPatch) {
              final VirtualFile file = textPatch.getFirst();
              if (file.isDirectory()) return false;
              return !isFileTypeOk(file);
            }
          });
  myTextPatches.removeAll(failedTextPatches);
  return ContainerUtil.map(failedTextPatches, new Function<Pair<VirtualFile, ApplyTextFilePatch>, FilePatch>() {
    @Override
    public FilePatch fun(Pair<VirtualFile, ApplyTextFilePatch> patchInfo) {
      return patchInfo.getSecond().getPatch();
    }
  });
}
 
源代码14 项目: consulo   文件: VcsLogGraphTable.java
@Nonnull
private Pair<TIntHashSet, Integer> findRowsToSelectAndScroll(@Nonnull GraphTableModel model,
                                                             @Nonnull VisibleGraph<Integer> visibleGraph) {
  TIntHashSet rowsToSelect = new TIntHashSet();

  if (model.getRowCount() == 0) {
    // this should have been covered by facade.getVisibleCommitCount,
    // but if the table is empty (no commits match the filter), the GraphFacade is not updated, because it can't handle it
    // => it has previous values set.
    return Pair.create(rowsToSelect, null);
  }

  Integer rowToScroll = null;
  for (int row = 0;
       row < visibleGraph.getVisibleCommitCount() && (rowsToSelect.size() < mySelectedCommits.size() || rowToScroll == null);
       row++) { //stop iterating if found all hashes
    int commit = visibleGraph.getRowInfo(row).getCommit();
    if (mySelectedCommits.contains(commit)) {
      rowsToSelect.add(row);
    }
    if (myVisibleSelectedCommit != null && myVisibleSelectedCommit == commit) {
      rowToScroll = row;
    }
  }
  return Pair.create(rowsToSelect, rowToScroll);
}
 
源代码15 项目: p4ic4idea   文件: JreSettingsTest.java
@Test
void getProperty() {
    Properties props = System.getProperties();
    for (String key : props.stringPropertyNames()) {
        JreSettings.setOverrides((Map<String, String>) null);
        String value = props.getProperty(key);
        assertEquals(value, JreSettings.getProperty(key));
        JreSettings.setOverrides(new Pair<>(key, "--" + value));
        assertEquals("--" + value, JreSettings.getProperty(key));
        JreSettings.setOverrides(new Pair<>(key, null));
        assertNull(JreSettings.getProperty(key));
        assertEquals("abc", JreSettings.getProperty(key, "abc"));
    }

    JreSettings.setOverrides((Map<String, String>) null);

    int i = 0;
    String notExist;
    do {
        i++;
        notExist = "not-exist-" + i;
    } while (props.getProperty(notExist) != null);
    assertNull(JreSettings.getProperty(notExist));
    assertEquals("abc", JreSettings.getProperty(notExist, "abc"));
}
 
@RequiredReadAction
public MsilPropertyAsCSharpPropertyDeclaration(PsiElement parent, MsilPropertyEntry variable, List<Pair<DotNetXAccessor, MsilMethodEntry>> pairs)
{
	super(parent, getAdditionalModifiers(variable, pairs), variable);
	myAccessors = buildAccessors(this, pairs);

	myTypeForImplementValue = NullableLazyValue.of(() ->
	{
		String nameFromBytecode = getVariable().getNameFromBytecode();
		String typeBeforeDot = StringUtil.getPackageName(nameFromBytecode);
		SomeType someType = SomeTypeParser.parseType(typeBeforeDot, nameFromBytecode);
		if(someType != null)
		{
			return new DummyType(getProject(), MsilPropertyAsCSharpPropertyDeclaration.this, someType);
		}
		return null;
	});
}
 
源代码17 项目: consulo   文件: CachedIntentions.java
@Nonnull
IntentionActionWithTextCaching wrapAction(@Nonnull HighlightInfo.IntentionActionDescriptor descriptor,
                                          @Nonnull PsiElement element,
                                          @Nonnull PsiFile containingFile,
                                          @Nullable Editor containingEditor) {
  IntentionActionWithTextCaching cachedAction = new IntentionActionWithTextCaching(descriptor, (cached, action) -> {
    if (action instanceof QuickFixWrapper) {
      // remove only inspection fixes after invocation,
      // since intention actions might be still available
      removeActionFromCached(cached);
      markInvoked(action);
    }
  });
  final List<IntentionAction> options = descriptor.getOptions(element, containingEditor);
  if (options == null) return cachedAction;
  for (IntentionAction option : options) {
    Editor editor = ObjectUtils.chooseNotNull(myEditor, containingEditor);
    if (editor == null) continue;
    Pair<PsiFile, Editor> availableIn = ShowIntentionActionsHandler.chooseBetweenHostAndInjected(myFile, editor, containingFile, (f, e) -> ShowIntentionActionsHandler.availableFor(f, e, option));
    if (availableIn == null) continue;
    IntentionActionWithTextCaching textCaching = new IntentionActionWithTextCaching(option);
    boolean isErrorFix = myErrorFixes.contains(textCaching);
    if (isErrorFix) {
      cachedAction.addErrorFix(option);
    }
    boolean isInspectionFix = myInspectionFixes.contains(textCaching);
    if (isInspectionFix) {
      cachedAction.addInspectionFix(option);
    }
    else {
      cachedAction.addIntention(option);
    }
  }
  return cachedAction;
}
 
源代码18 项目: consulo   文件: ParameterInfoController.java
/**
 * Returned Point is in layered pane coordinate system.
 * Second value is a {@link HintManager.PositionFlags position flag}.
 */
static Pair<Point, Short> chooseBestHintPosition(Editor editor, VisualPosition pos, LightweightHint hint, short preferredPosition, boolean showLookupHint) {
  if (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isHeadlessEnvironment()) return Pair.pair(new Point(), HintManager.DEFAULT);

  HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
  Dimension hintSize = hint.getComponent().getPreferredSize();
  JComponent editorComponent = editor.getComponent();
  JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();

  Point p1;
  Point p2;
  if (showLookupHint) {
    p1 = hintManager.getHintPosition(hint, editor, HintManager.UNDER);
    p2 = hintManager.getHintPosition(hint, editor, HintManager.ABOVE);
  }
  else {
    p1 = HintManagerImpl.getHintPosition(hint, editor, pos, HintManager.UNDER);
    p2 = HintManagerImpl.getHintPosition(hint, editor, pos, HintManager.ABOVE);
  }

  boolean p1Ok = p1.y + hintSize.height < layeredPane.getHeight();
  boolean p2Ok = p2.y >= 0;

  if (!showLookupHint) {
    if (preferredPosition != HintManager.DEFAULT) {
      if (preferredPosition == HintManager.ABOVE) {
        if (p2Ok) return new Pair<>(p2, HintManager.ABOVE);
      }
      else if (preferredPosition == HintManager.UNDER) {
        if (p1Ok) return new Pair<>(p1, HintManager.UNDER);
      }
    }
  }
  if (p1Ok) return new Pair<>(p1, HintManager.UNDER);
  if (p2Ok) return new Pair<>(p2, HintManager.ABOVE);

  int underSpace = layeredPane.getHeight() - p1.y;
  int aboveSpace = p2.y;
  return aboveSpace > underSpace ? new Pair<>(new Point(p2.x, 0), HintManager.UNDER) : new Pair<>(p1, HintManager.ABOVE);
}
 
源代码19 项目: consulo   文件: ComponentStoreImpl.java
protected static void executeSave(@Nonnull SaveSession session, @Nonnull List<Pair<SaveSession, File>> readonlyFiles) {
  try {
    session.save();
  }
  catch (ReadOnlyModificationException e) {
    readonlyFiles.add(Pair.create(session, e.getFile()));
  }
}
 
源代码20 项目: consulo   文件: VfsImplUtil.java
@Nullable
public static NewVirtualFile refreshAndFindFileByPath(@Nonnull NewVirtualFileSystem vfs, @Nonnull String path) {
  Pair<NewVirtualFile, Iterable<String>> data = prepare(vfs, path);
  if (data == null) return null;

  NewVirtualFile file = data.first;
  for (String pathElement : data.second) {
    if (pathElement.isEmpty() || ".".equals(pathElement)) continue;
    if ("..".equals(pathElement)) {
      if (file.is(VFileProperty.SYMLINK)) {
        final String canonicalPath = file.getCanonicalPath();
        final NewVirtualFile canonicalFile = canonicalPath != null ? refreshAndFindFileByPath(vfs, canonicalPath) : null;
        file = canonicalFile != null ? canonicalFile.getParent() : null;
      }
      else {
        file = file.getParent();
      }
    }
    else {
      file = file.refreshAndFindChild(pathElement);
    }

    if (file == null) return null;
  }

  return file;
}
 
源代码21 项目: consulo   文件: BlockUtil.java
public static Pair<List<DataLanguageBlockWrapper>, List<DataLanguageBlockWrapper>> splitBlocksByRightBound(@Nonnull Block parent, @Nonnull TextRange bounds) {
  final List<Block> subBlocks = parent.getSubBlocks();
  if (subBlocks.size() == 0) return new Pair<List<DataLanguageBlockWrapper>, List<DataLanguageBlockWrapper>>(Collections.<DataLanguageBlockWrapper>emptyList(), Collections.<DataLanguageBlockWrapper>emptyList());
  final ArrayList<DataLanguageBlockWrapper> before = new ArrayList<DataLanguageBlockWrapper>(subBlocks.size() / 2);
  final ArrayList<DataLanguageBlockWrapper> after = new ArrayList<DataLanguageBlockWrapper>(subBlocks.size() / 2);
  splitByRightBoundAndCollectBlocks(subBlocks, before, after, bounds);
  return new Pair<List<DataLanguageBlockWrapper>, List<DataLanguageBlockWrapper>>(before, after);
}
 
源代码22 项目: consulo   文件: ExternalSystemFacadeManager.java
@SuppressWarnings("ConstantConditions")
@Nonnull
private RemoteExternalSystemFacade doGetFacade(@Nonnull IntegrationKey key, @Nonnull Project project) throws Exception {
  final boolean currentInProcess = ExternalSystemApiUtil.isInProcessMode(key.getExternalSystemId());
  final ExternalSystemCommunicationManager myCommunicationManager = currentInProcess ? myInProcessCommunicationManager : myRemoteCommunicationManager;
  
  ExternalSystemManager manager = ExternalSystemApiUtil.getManager(key.getExternalSystemId());
  if (project.isDisposed() || manager == null) {
    return RemoteExternalSystemFacade.NULL_OBJECT;
  }
  Pair<RemoteExternalSystemFacade, ExternalSystemExecutionSettings> pair = myRemoteFacades.get(key);
  if (pair != null && prepare(myCommunicationManager, project, key, pair)) {
    return pair.first;
  }
  
  myLock.lock();
  try {
    pair = myRemoteFacades.get(key);
    if (pair != null && prepare(myCommunicationManager, project, key, pair)) {
      return pair.first;
    }
    if (pair != null) {
      myFacadeWrappers.clear();
      myRemoteFacades.clear();
    }
    return doCreateFacade(key, project, myCommunicationManager);
  }
  finally {
    myLock.unlock();
  }
}
 
private GitCommitCompareInfo getCompareInfo(final Project project, final GitRepository gitRepository,
                                            final String source, final String target)
        throws VcsException {
    final VirtualFile root = gitRepository.getRoot();
    final List<GitCommit> commits1 = getUtilWrapper().history(project, root, ".." + target);
    final List<GitCommit> commits2 = getUtilWrapper().history(project, root, target + "..");

    final Collection<Change> diff = getUtilWrapper().getDiff(project, root, target, source);
    final GitCommitCompareInfo info = new GitCommitCompareInfo(GitCommitCompareInfo.InfoType.BRANCH_TO_HEAD);

    info.put(gitRepository, diff);
    info.put(gitRepository, new Pair<List<GitCommit>, List<GitCommit>>(commits1, commits2));

    return info;
}
 
源代码24 项目: consulo   文件: XDebuggerTreePanel.java
@Override
public Pair<Image, Point> createDraggedImage(final DnDAction action, final Point dragOrigin) {
  XValueNodeImpl[] nodes = getNodesToDrag();
  if (nodes.length == 1) {
    return DnDAwareTree.getDragImage(myTree, nodes[0].getPath(), dragOrigin);
  }
  return DnDAwareTree.getDragImage(myTree, XDebuggerBundle.message("xdebugger.drag.text.0.elements", nodes.length), dragOrigin);
}
 
源代码25 项目: consulo   文件: VirtualFilePointerImpl.java
@Override
@Nonnull
public String getPresentableUrl() {
  FilePointerPartNode node = checkDisposed(myNode);
  if (node == null) return "";
  Pair<VirtualFile, String> result = node.update();
  return result == null ? "" : PathUtil.toPresentableUrl(result.second);
}
 
源代码26 项目: consulo   文件: CreateFromTemplatePanel.java
@Nonnull
public Map<String, Object> getVariables(Map<String, Object> predefinedProperties) {
  Map<String, Object> result = new HashMap<>(predefinedProperties);
  for (Pair<String, JTextField> pair : myAttributes) {
    result.put(pair.first, pair.second.getText());
  }
  return result;
}
 
源代码27 项目: consulo   文件: NamedScopeDescriptor.java
private Pair<NamedScopesHolder, NamedScope> resolveScope(@Nonnull Project project) {
  NamedScopesHolder holder = DependencyValidationManager.getInstance(project);
  NamedScope scope = holder.getScope(myScopeName);
  if (scope == null) {
    holder = NamedScopeManager.getInstance(project);
    scope = holder.getScope(myScopeName);
  }
  return scope != null ? Pair.create(holder, scope) : null;
}
 
源代码28 项目: consulo   文件: ShowParameterInfoHandler.java
private static void showLookupEditorHint(Object[] descriptors, final Editor editor, ParameterInfoHandler handler, boolean requestFocus) {
  ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor, handler, requestFocus, false);
  component.update(false);

  final LightweightHint hint = new LightweightHint(component);
  hint.setSelectingHint(true);
  final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
  final Pair<Point, Short> pos = ParameterInfoController.chooseBestHintPosition(editor, null, hint, HintManager.DEFAULT, true);
  ApplicationManager.getApplication().invokeLater(() -> {
    if (!EditorActivityManager.getInstance().isVisible(editor)) return;
    hintManager.showEditorHint(hint, editor, pos.getFirst(), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_LOOKUP_ITEM_CHANGE | HintManager.UPDATE_BY_SCROLLING, 0, false, pos.getSecond());
  });
}
 
源代码29 项目: consulo   文件: ControlBinder.java
public synchronized void reset() {
  for (Pair<ControlValueAccessor, BeanValueAccessor> binding : myBindings) {
    if (!binding.first.isEnabled()) {
      continue;
    }
    Object value = binding.second.getValue();
    try {
      value = convert(value, binding.first.getType());
      binding.first.setValue(value);
    }
    catch (IllegalArgumentException e) {
      LOG.debug(e);
    }
  }
}
 
源代码30 项目: consulo   文件: DumpLookupElementWeights.java
public static List<String> getLookupElementWeights(LookupImpl lookup, boolean hideSingleValued) {
  final Map<LookupElement, List<Pair<String, Object>>> weights = lookup.getRelevanceObjects(lookup.getItems(), hideSingleValued);
  return ContainerUtil.map(weights.entrySet(), new Function<Map.Entry<LookupElement, List<Pair<String, Object>>>, String>() {
    @Override
    public String fun(Map.Entry<LookupElement, List<Pair<String, Object>>> entry) {
      return entry.getKey().getLookupString() + "\t" + StringUtil.join(entry.getValue(), new Function<Pair<String, Object>, String>() {
        @Override
        public String fun(Pair<String, Object> pair) {
          return pair.first + "=" + pair.second;
        }
      }, ", ");
    }
  });
}