本文整理汇总了Java中com.intellij.openapi.actionSystem.DataProvider.getDataUnchecked方法的典型用法代码示例。如果您正苦于以下问题:Java DataProvider.getDataUnchecked方法的具体用法?Java DataProvider.getDataUnchecked怎么用?Java DataProvider.getDataUnchecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.actionSystem.DataProvider
的用法示例。
在下文中一共展示了DataProvider.getDataUnchecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public String getData(@Nonnull DataProvider dataProvider) {
final VirtualFile virtualFile = dataProvider.getDataUnchecked(PlatformDataKeys.VIRTUAL_FILE);
if (virtualFile == null) {
return null;
}
final FileType fileType = virtualFile.getFileType();
if (fileType.isBinary() || fileType.isReadOnly()) {
return null;
}
final Project project = dataProvider.getDataUnchecked(CommonDataKeys.PROJECT);
if (project == null) {
return null;
}
final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
if (document == null) {
return null;
}
return document.getText();
}
示例2: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public AnalysisScope getData(@NotNull final DataProvider dataProvider)
{
final Object psiFile = dataProvider.getDataUnchecked(LangDataKeys.PSI_FILE);
if(psiFile instanceof PsiJavaFile)
{
return new JavaAnalysisScope((PsiJavaFile) psiFile);
}
Object psiTarget = dataProvider.getDataUnchecked(LangDataKeys.PSI_ELEMENT);
if(psiTarget instanceof PsiJavaPackage)
{
PsiJavaPackage pack = (PsiJavaPackage) psiTarget;
PsiManager manager = pack.getManager();
if(!manager.isInProject(pack))
{
return null;
}
PsiDirectory[] dirs = pack.getDirectories(GlobalSearchScope.projectScope(manager.getProject()));
if(dirs.length == 0)
{
return null;
}
return new JavaAnalysisScope(pack, dataProvider.getDataUnchecked(LangDataKeys.MODULE));
}
return null;
}
示例3: getRevisionNumbers
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Nullable
public List<VcsRevisionNumber> getRevisionNumbers(@Nonnull DataProvider dataProvider) {
VcsRevisionNumber revisionNumber = dataProvider.getDataUnchecked(VcsDataKeys.VCS_REVISION_NUMBER);
if (revisionNumber != null) {
return Collections.singletonList(revisionNumber);
}
ChangeList[] changeLists = dataProvider.getDataUnchecked(VcsDataKeys.CHANGE_LISTS);
if (changeLists != null && changeLists.length > 0) {
List<CommittedChangeList> committedChangeLists = ContainerUtil.findAll(changeLists, CommittedChangeList.class);
if (!committedChangeLists.isEmpty()) {
ContainerUtil.sort(committedChangeLists, CommittedChangeListByDateComparator.DESCENDING);
return ContainerUtil.mapNotNull(committedChangeLists, CommittedChangeListToRevisionNumberFunction.INSTANCE);
}
}
VcsFileRevision[] fileRevisions = dataProvider.getDataUnchecked(VcsDataKeys.VCS_FILE_REVISIONS);
if (fileRevisions != null && fileRevisions.length > 0) {
return ContainerUtil.mapNotNull(fileRevisions, FileRevisionToRevisionNumberFunction.INSTANCE);
}
return null;
}
示例4: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public Navigatable getData(@Nonnull DataProvider dataProvider) {
final Navigatable navigatable = dataProvider.getDataUnchecked(PlatformDataKeys.NAVIGATABLE);
if (navigatable != null && navigatable instanceof OpenFileDescriptor) {
final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor)navigatable;
if (openFileDescriptor.getFile().isValid()) {
return openFileDescriptor;
}
}
final PsiElement element = dataProvider.getDataUnchecked(LangDataKeys.PSI_ELEMENT);
if (element instanceof Navigatable) {
return (Navigatable)element;
}
if (element != null) {
return EditSourceUtil.getDescriptor(element);
}
final Object selection = dataProvider.getDataUnchecked(PlatformDataKeys.SELECTED_ITEM);
if (selection instanceof Navigatable) {
return (Navigatable)selection;
}
return null;
}
示例5: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public PsiElement[] getData(@Nonnull DataProvider dataProvider) {
final Object[] objects = dataProvider.getDataUnchecked(PlatformDataKeys.SELECTED_ITEMS);
if (objects != null) {
final PsiElement[] elements = new PsiElement[objects.length];
for (int i = 0, objectsLength = objects.length; i < objectsLength; i++) {
Object object = objects[i];
if (!(object instanceof PsiElement)) return null;
if (!((PsiElement)object).isValid()) return null;
elements[i] = (PsiElement)object;
}
return elements;
}
return null;
}
示例6: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public Navigatable[] getData(@Nonnull DataProvider dataProvider) {
final Navigatable element = dataProvider.getDataUnchecked(DiffDataKeys.NAVIGATABLE);
if (element == null) {
return null;
}
return new Navigatable[]{element};
}
示例7: add
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public void add(@Nonnull DockableContent content, RelativePoint dropTarget) {
EditorWindow window = null;
if (myCurrentOver != null) {
final DataProvider provider = myCurrentOver.getDataProvider();
if (provider != null) {
window = provider.getDataUnchecked(EditorWindow.DATA_KEY);
}
}
final EditorTabbedContainer.DockableEditor dockableEditor = (EditorTabbedContainer.DockableEditor)content;
VirtualFile file = dockableEditor.getFile();
if (window == null || window.isDisposed()) {
window = mySplitters.getOrCreateCurrentWindow(file);
}
if (myCurrentOver != null) {
int index = ((JBTabsImpl)myCurrentOver).getDropInfoIndex();
file.putUserData(DesktopEditorWindow.INITIAL_INDEX_KEY, index);
}
((FileEditorManagerImpl)FileEditorManagerEx.getInstanceEx(myProject)).openFileImpl2(window, file, true);
window.setFilePinned(file, dockableEditor.isPinned());
}
示例8: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public Navigatable[] getData(@Nonnull DataProvider dataProvider) {
final Navigatable element = dataProvider.getDataUnchecked(PlatformDataKeys.NAVIGATABLE);
if (element == null) {
return null;
}
return new Navigatable[]{element};
}
示例9: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public CutProvider getData(@Nonnull DataProvider dataProvider) {
final Editor editor = dataProvider.getDataUnchecked(PlatformDataKeys.EDITOR);
if (editor instanceof EditorEx) {
return ((EditorEx)editor).getCutProvider();
}
return null;
}
示例10: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public PasteProvider getData(@Nonnull DataProvider dataProvider) {
final Editor editor = dataProvider.getDataUnchecked(PlatformDataKeys.EDITOR);
if (editor instanceof EditorEx) {
return ((EditorEx) editor).getPasteProvider();
}
return null;
}
示例11: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public CopyProvider getData(@Nonnull DataProvider dataProvider) {
final Editor editor = dataProvider.getDataUnchecked(PlatformDataKeys.EDITOR);
if (editor instanceof EditorEx) {
return ((EditorEx) editor).getCopyProvider();
}
return null;
}
示例12: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public FileEditor getData(@Nonnull DataProvider dataProvider) {
final Editor editor = dataProvider.getDataUnchecked(PlatformDataKeys.EDITOR);
if (editor == null) {
return null;
}
final Boolean aBoolean = editor.getUserData(EditorTextField.SUPPLEMENTARY_KEY);
if (aBoolean != null && aBoolean.booleanValue()) {
return null;
}
return TextEditorProvider.getInstance().getTextEditor(editor);
}
示例13: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Nullable
@Override
public Stream<VirtualFile> getData(@Nonnull DataProvider dataProvider) {
VirtualFile[] files = dataProvider.getDataUnchecked(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (files != null) {
return Stream.of(files);
}
VirtualFile file = dataProvider.getDataUnchecked(CommonDataKeys.VIRTUAL_FILE);
if (file != null) {
return Stream.of(file);
}
return null;
}
示例14: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public Module getData(@Nonnull DataProvider dataProvider) {
Module moduleContext = dataProvider.getDataUnchecked(LangDataKeys.MODULE_CONTEXT);
if (moduleContext != null) {
return moduleContext;
}
Project project = dataProvider.getDataUnchecked(CommonDataKeys.PROJECT);
if (project == null) {
PsiElement element = dataProvider.getDataUnchecked(LangDataKeys.PSI_ELEMENT);
if (element == null || !element.isValid()) return null;
project = element.getProject();
}
VirtualFile virtualFile = dataProvider.getDataUnchecked(PlatformDataKeys.VIRTUAL_FILE);
if (virtualFile == null) {
GetDataRule<VirtualFile> dataRule = ((DataManagerImpl)DataManager.getInstance()).getDataRule(PlatformDataKeys.VIRTUAL_FILE);
if (dataRule != null) {
virtualFile = dataRule.getData(dataProvider);
}
}
if (virtualFile == null) {
return null;
}
return ModuleUtil.findModuleForFile(virtualFile, project);
}
示例15: getData
import com.intellij.openapi.actionSystem.DataProvider; //导入方法依赖的package包/类
@Override
public PsiElement getData(@Nonnull DataProvider dataProvider) {
final Object element = dataProvider.getDataUnchecked(PlatformDataKeys.SELECTED_ITEM);
if (element instanceof PsiElement) {
PsiElement psiElement = (PsiElement)element;
if (psiElement.isValid()) {
return (PsiElement)element;
}
}
return null;
}