当前位置: 首页>>代码示例>>Java>>正文


Java DataProvider.getDataUnchecked方法代码示例

本文整理汇总了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();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:FileTextRule.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:AnalysisScopeRule.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:VcsRevisionNumberArrayRule.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:NavigatableRule.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:PsiElementFromSelectionsRule.java

示例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};
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:DiffNavigatableArrayRule.java

示例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());
}
 
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:DockableEditorTabbedContainer.java

示例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};
}
 
开发者ID:consulo,项目名称:consulo,代码行数:10,代码来源:NavigatableArrayRule.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:CutProviderRule.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:PasteProviderRule.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:CopyProviderRule.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:FileEditorRule.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:VirtualFileStreamRule.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:ModuleRule.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:13,代码来源:PsiElementFromSelectionRule.java


注:本文中的com.intellij.openapi.actionSystem.DataProvider.getDataUnchecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。