Java Code Examples for com.intellij.openapi.actionSystem.CommonDataKeys#PSI_FILE

The following examples show how to use com.intellij.openapi.actionSystem.CommonDataKeys#PSI_FILE . 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: FileSearchEverywhereContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Object getDataForItem(@Nonnull Object element, @Nonnull Key dataId) {
  if (CommonDataKeys.PSI_FILE == dataId && element instanceof PsiFile) {
    return element;
  }

  if (SearchEverywhereDataKeys.ITEM_STRING_DESCRIPTION == dataId && element instanceof PsiFile) {
    String path = ((PsiFile)element).getVirtualFile().getPath();
    path = FileUtil.toSystemIndependentName(path);
    if (myProject != null) {
      String basePath = myProject.getBasePath();
      if (basePath != null) {
        path = FileUtil.getRelativePath(basePath, path, '/');
      }
    }
    return path;
  }

  return super.getDataForItem(element, dataId);
}
 
Example 2
Source File: XDebuggerExpressionEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public XDebuggerExpressionEditor(Project project,
                                 @Nonnull XDebuggerEditorsProvider debuggerEditorsProvider,
                                 @Nullable @NonNls String historyId,
                                 @Nullable XSourcePosition sourcePosition,
                                 @Nonnull XExpression text,
                                 final boolean multiline,
                                 boolean editorFont,
                                 boolean showEditor) {
  super(project, debuggerEditorsProvider, multiline ? EvaluationMode.CODE_FRAGMENT : EvaluationMode.EXPRESSION, historyId, sourcePosition);
  myExpression = XExpressionImpl.changeMode(text, getMode());
  myEditorTextField =
          new EditorTextField(createDocument(myExpression), project, debuggerEditorsProvider.getFileType(), false, !multiline) {
            @Override
            protected EditorEx createEditor() {
              final EditorEx editor = super.createEditor();
              editor.setVerticalScrollbarVisible(multiline);
              editor.getColorsScheme().setEditorFontName(getFont().getFontName());
              editor.getColorsScheme().setEditorFontSize(getFont().getSize());
              return editor;
            }

            @Override
            public Object getData(@Nonnull Key dataId) {
              if (LangDataKeys.CONTEXT_LANGUAGES == dataId) {
                return new Language[]{myExpression.getLanguage()};
              } else if (CommonDataKeys.PSI_FILE == dataId) {
                return PsiDocumentManager.getInstance(getProject()).getPsiFile(getDocument());
              }
              return super.getData(dataId);
            }
          };
  if (editorFont) {
    myEditorTextField.setFontInheritedFromLAF(false);
    myEditorTextField.setFont(EditorUtil.getEditorFont());
  }
  myComponent = decorate(myEditorTextField, multiline, showEditor);
}
 
Example 3
Source File: PsiFileDataValidator.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<PsiFile> getKey() {
  return CommonDataKeys.PSI_FILE;
}
 
Example 4
Source File: PsiFileRule.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<PsiFile> getKey() {
  return CommonDataKeys.PSI_FILE;
}