com.intellij.openapi.fileEditor.FileEditorLocation Java Examples

The following examples show how to use com.intellij.openapi.fileEditor.FileEditorLocation. 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 File: ShowUsagesAction.java    From otto-intellij-plugin with 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 File: ShowUsagesAction.java    From dagger-intellij-plugin with 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 File: FindUsagesManager.java    From consulo with 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 File: UIFormEditor.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
public FileEditorLocation getCurrentLocation() {
	return null;
}
 
Example #5
Source File: ShowUsagesAction.java    From otto-intellij-plugin with 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 #6
Source File: SandFileEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@javax.annotation.Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example #7
Source File: WebTextEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example #8
Source File: ConflictsDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public FileEditorLocation getLocation() {
  return null;
}
 
Example #9
Source File: FindUsagesManager.java    From consulo with 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 #10
Source File: ShowUsagesAction.java    From consulo with 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 #11
Source File: Usage.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
FileEditorLocation getLocation();
 
Example #12
Source File: UsageAdapter.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public FileEditorLocation getLocation() {
  return null;
}
 
Example #13
Source File: UsageNodeTreeBuilderTest.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public FileEditorLocation getLocation() {
  return null;
}
 
Example #14
Source File: CmtFileEditor.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}
 
Example #15
Source File: ShowUsagesAction.java    From dagger-intellij-plugin with 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 #16
Source File: CSharpAssemblyFileEditor.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation()
{
	return null;
}
 
Example #17
Source File: NoSqlDatabaseDataEditor.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}
 
Example #18
Source File: MindMapDocumentEditor.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example #19
Source File: ApiFileViewEditor.java    From ApiDebugger with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}
 
Example #20
Source File: FlutterWidgetPerfTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example #21
Source File: FlutterWidgetPerfTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
  return null;
}
 
Example #22
Source File: WeaveEditor.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}
 
Example #23
Source File: BPMNFileEditor.java    From intellij-bpmn-editor with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public FileEditorLocation getCurrentLocation() {
    return null;
}