Java Code Examples for com.intellij.openapi.fileEditor.FileEditorLocation

The following examples show how to use com.intellij.openapi.fileEditor.FileEditorLocation. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dagger-intellij-plugin   Source File: ShowUsagesAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public int compare(UsageNode c1, UsageNode c2) {
  if (c1 instanceof StringNode) return 1;
  if (c2 instanceof StringNode) return -1;
  Usage o1 = c1.getUsage();
  Usage o2 = c2.getUsage();
  if (o1 == MORE_USAGES_SEPARATOR) return 1;
  if (o2 == MORE_USAGES_SEPARATOR) return -1;

  VirtualFile v1 = UsageListCellRenderer.getVirtualFile(o1);
  VirtualFile v2 = UsageListCellRenderer.getVirtualFile(o2);
  String name1 = v1 == null ? null : v1.getName();
  String name2 = v2 == null ? null : v2.getName();
  int i = Comparing.compare(name1, name2);
  if (i != 0) return i;

  if (o1 instanceof Comparable && o2 instanceof Comparable) {
    return ((Comparable) o1).compareTo(o2);
  }

  FileEditorLocation loc1 = o1.getLocation();
  FileEditorLocation loc2 = o2.getLocation();
  return Comparing.compare(loc1, loc2);
}
 
Example 2
Source Project: otto-intellij-plugin   Source File: ShowUsagesAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public int compare(UsageNode c1, UsageNode c2) {
  if (c1 instanceof StringNode) return 1;
  if (c2 instanceof StringNode) return -1;
  Usage o1 = c1.getUsage();
  Usage o2 = c2.getUsage();
  if (o1 == MORE_USAGES_SEPARATOR) return 1;
  if (o2 == MORE_USAGES_SEPARATOR) return -1;

  VirtualFile v1 = UsageListCellRenderer.getVirtualFile(o1);
  VirtualFile v2 = UsageListCellRenderer.getVirtualFile(o2);
  String name1 = v1 == null ? null : v1.getName();
  String name2 = v2 == null ? null : v2.getName();
  int i = Comparing.compare(name1, name2);
  if (i != 0) return i;

  if (o1 instanceof Comparable && o2 instanceof Comparable) {
    return ((Comparable)o1).compareTo(o2);
  }

  FileEditorLocation loc1 = o1.getLocation();
  FileEditorLocation loc2 = o2.getLocation();
  return Comparing.compare(loc1, loc2);
}
 
Example 3
Source Project: consulo   Source File: FindUsagesManager.java    License: Apache License 2.0 5 votes vote down vote up
private void findUsagesInEditor(@Nonnull final PsiElement[] primaryElements,
                                @Nonnull final PsiElement[] secondaryElements,
                                @Nonnull FindUsagesHandler handler,
                                @Nonnull PsiFile scopeFile,
                                @Nonnull FileSearchScope direction,
                                @Nonnull final FindUsagesOptions findUsagesOptions,
                                @Nonnull FileEditor fileEditor) {
  initLastSearchElement(findUsagesOptions, primaryElements, secondaryElements);

  clearStatusBar();

  final FileEditorLocation currentLocation = fileEditor.getCurrentLocation();

  PsiElement2UsageTargetAdapter[] primaryTargets = PsiElement2UsageTargetAdapter.convert(primaryElements);
  PsiElement2UsageTargetAdapter[] secondaryTargets = PsiElement2UsageTargetAdapter.convert(primaryElements);
  final UsageSearcher usageSearcher = createUsageSearcher(primaryTargets, secondaryTargets, handler, findUsagesOptions, scopeFile);
  AtomicBoolean usagesWereFound = new AtomicBoolean();

  Usage fUsage = findSiblingUsage(usageSearcher, direction, currentLocation, usagesWereFound, fileEditor);

  if (fUsage != null) {
    fUsage.navigate(true);
    fUsage.selectInEditor();
  }
  else if (!usagesWereFound.get()) {
    String message = getNoUsagesFoundMessage(primaryElements[0]) + " in " + scopeFile.getName();
    showHintOrStatusBarMessage(message, fileEditor);
  }
  else {
    fileEditor.putUserData(KEY_START_USAGE_AGAIN, VALUE_START_USAGE_AGAIN);
    showHintOrStatusBarMessage(getSearchAgainMessage(primaryElements[0], direction), fileEditor);
  }
}
 
Example 4
Source Project: reasonml-idea-plugin   Source File: CmtFileEditor.java    License: MIT License 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}
 
Example 5
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}
 
Example 6
Source Project: mule-intellij-plugins   Source File: WeaveEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}
 
Example 7
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example 8
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example 9
Source Project: ApiDebugger   Source File: ApiFileViewEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}
 
Example 10
Source Project: netbeans-mmd-plugin   Source File: MindMapDocumentEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example 11
Source Project: nosql4idea   Source File: NoSqlDatabaseDataEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}
 
Example 12
Source Project: consulo-csharp   Source File: CSharpAssemblyFileEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation()
{
	return null;
}
 
Example 13
Source Project: dagger-intellij-plugin   Source File: ShowUsagesAction.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
private static Editor getEditorFor(@NotNull Usage usage) {
  FileEditorLocation location = usage.getLocation();
  FileEditor newFileEditor = location == null ? null : location.getEditor();
  return newFileEditor instanceof TextEditor ? ((TextEditor) newFileEditor).getEditor() : null;
}
 
Example 14
Source Project: MavenHelper   Source File: UIFormEditor.java    License: Apache License 2.0 4 votes vote down vote up
public FileEditorLocation getCurrentLocation() {
	return null;
}
 
Example 15
Source Project: consulo   Source File: UsageNodeTreeBuilderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public FileEditorLocation getLocation() {
  return null;
}
 
Example 16
Source Project: consulo   Source File: UsageAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public FileEditorLocation getLocation() {
  return null;
}
 
Example 17
Source Project: consulo   Source File: Usage.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
FileEditorLocation getLocation();
 
Example 18
Source Project: consulo   Source File: ShowUsagesAction.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
private static Editor getEditorFor(@Nonnull Usage usage) {
  FileEditorLocation location = usage.getLocation();
  FileEditor newFileEditor = location == null ? null : location.getEditor();
  return newFileEditor instanceof TextEditor ? ((TextEditor)newFileEditor).getEditor() : null;
}
 
Example 19
Source Project: consulo   Source File: FindUsagesManager.java    License: Apache License 2.0 4 votes vote down vote up
private static Usage findSiblingUsage(@Nonnull final UsageSearcher usageSearcher,
                                      @Nonnull FileSearchScope dir,
                                      final FileEditorLocation currentLocation,
                                      @Nonnull final AtomicBoolean usagesWereFound,
                                      @Nonnull FileEditor fileEditor) {
  if (fileEditor.getUserData(KEY_START_USAGE_AGAIN) != null) {
    dir = dir == FileSearchScope.AFTER_CARET ? FileSearchScope.FROM_START : FileSearchScope.FROM_END;
  }

  final FileSearchScope direction = dir;

  final AtomicReference<Usage> foundUsage = new AtomicReference<>();
  usageSearcher.generate(usage -> {
    usagesWereFound.set(true);
    if (direction == FileSearchScope.FROM_START) {
      foundUsage.compareAndSet(null, usage);
      return false;
    }
    if (direction == FileSearchScope.FROM_END) {
      foundUsage.set(usage);
    }
    else if (direction == FileSearchScope.AFTER_CARET) {
      if (Comparing.compare(usage.getLocation(), currentLocation) > 0) {
        foundUsage.set(usage);
        return false;
      }
    }
    else if (direction == FileSearchScope.BEFORE_CARET) {
      if (Comparing.compare(usage.getLocation(), currentLocation) >= 0) {
        return false;
      }
      while (true) {
        Usage found = foundUsage.get();
        if (found == null) {
          if (foundUsage.compareAndSet(null, usage)) break;
        }
        else {
          if (Comparing.compare(found.getLocation(), usage.getLocation()) < 0 && foundUsage.compareAndSet(found, usage)) break;
        }
      }
    }

    return true;
  });

  fileEditor.putUserData(KEY_START_USAGE_AGAIN, null);

  return foundUsage.get();
}
 
Example 20
Source Project: consulo   Source File: ConflictsDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public FileEditorLocation getLocation() {
  return null;
}
 
Example 21
Source Project: consulo   Source File: WebTextEditor.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example 22
Source Project: consulo   Source File: SandFileEditor.java    License: Apache License 2.0 4 votes vote down vote up
@javax.annotation.Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example 23
Source Project: otto-intellij-plugin   Source File: ShowUsagesAction.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
private static Editor getEditorFor(@NotNull Usage usage) {
  FileEditorLocation location = usage.getLocation();
  FileEditor newFileEditor = location == null ? null : location.getEditor();
  return newFileEditor instanceof TextEditor ? ((TextEditor)newFileEditor).getEditor() : null;
}