本文整理汇总了Java中com.intellij.openapi.vcs.actions.VcsContext.getEditor方法的典型用法代码示例。如果您正苦于以下问题:Java VcsContext.getEditor方法的具体用法?Java VcsContext.getEditor怎么用?Java VcsContext.getEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vcs.actions.VcsContext
的用法示例。
在下文中一共展示了VcsContext.getEditor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectionFromEditor
import com.intellij.openapi.vcs.actions.VcsContext; //导入方法依赖的package包/类
@Nullable
private static VcsSelection getSelectionFromEditor(VcsContext context) {
Editor editor = context.getEditor();
if (editor == null) return null;
SelectionModel selectionModel = editor.getSelectionModel();
if (!selectionModel.hasSelection()) {
return null;
}
return new VcsSelection(editor.getDocument(), selectionModel);
}
示例2: getSelection
import com.intellij.openapi.vcs.actions.VcsContext; //导入方法依赖的package包/类
@Override
public VcsSelection getSelection(VcsContext context) {
final Editor editor = context.getEditor();
if (editor == null) return null;
PsiElement psiElement = TargetElementUtil.findTargetElement(editor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
if (psiElement == null || !psiElement.isValid()) {
return null;
}
final String actionName;
if (psiElement instanceof XmlTag) {
actionName = VcsBundle.message("action.name.show.history.for.tag");
}
else if (psiElement instanceof XmlText) {
actionName = VcsBundle.message("action.name.show.history.for.text");
}
else {
return null;
}
TextRange textRange = psiElement.getTextRange();
if (textRange == null) {
return null;
}
VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
if (virtualFile == null) {
return null;
}
if (!virtualFile.isValid()) {
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
return new VcsSelection(document, textRange, actionName);
}
示例3: getSelection
import com.intellij.openapi.vcs.actions.VcsContext; //导入方法依赖的package包/类
public VcsSelection getSelection(VcsContext context) {
final Editor editor = context.getEditor();
if (editor == null) return null;
PsiElement psiElement = TargetElementUtilBase.findTargetElement(editor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED);
if (psiElement == null || !psiElement.isValid()) {
return null;
}
final String actionName;
if (psiElement instanceof XmlTag) {
actionName = VcsBundle.message("action.name.show.history.for.tag");
}
else if (psiElement instanceof XmlText) {
actionName = VcsBundle.message("action.name.show.history.for.text");
}
else {
return null;
}
TextRange textRange = psiElement.getTextRange();
if (textRange == null) {
return null;
}
VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
if (virtualFile == null) {
return null;
}
if (!virtualFile.isValid()) {
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
return new VcsSelection(document, textRange, actionName);
}
示例4: getSelection
import com.intellij.openapi.vcs.actions.VcsContext; //导入方法依赖的package包/类
@Nullable
public VcsSelection getSelection(final VcsContext context) {
final Editor editor = context.getEditor();
if (editor == null) return null;
PsiElement psiElement = TargetElementUtil.findTargetElement(editor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
if (psiElement == null) {
return null;
}
if (!psiElement.isValid()) {
return null;
}
if (psiElement instanceof PsiCompiledElement) {
return null;
}
final String actionName;
if (psiElement instanceof PsiClass) {
actionName = VcsBundle.message("action.name.show.history.for.class");
}
else if (psiElement instanceof PsiField) {
actionName = VcsBundle.message("action.name.show.history.for.field");
}
else if (psiElement instanceof PsiMethod) {
actionName = VcsBundle.message("action.name.show.history.for.method");
}
else if (psiElement instanceof PsiCodeBlock) {
actionName = VcsBundle.message("action.name.show.history.for.code.block");
}
else if (psiElement instanceof PsiStatement) {
actionName = VcsBundle.message("action.name.show.history.for.statement");
}
else {
return null;
}
TextRange textRange = psiElement.getTextRange();
if (textRange == null) {
return null;
}
VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
if (virtualFile == null) {
return null;
}
if (!virtualFile.isValid()) {
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
return new VcsSelection(document, textRange, actionName);
}
示例5: getSelection
import com.intellij.openapi.vcs.actions.VcsContext; //导入方法依赖的package包/类
@Nullable
public VcsSelection getSelection(final VcsContext context) {
final Editor editor = context.getEditor();
if (editor == null) return null;
PsiElement psiElement = TargetElementUtilBase.findTargetElement(editor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED);
if (psiElement == null) {
return null;
}
if (!psiElement.isValid()) {
return null;
}
if (psiElement instanceof PsiCompiledElement) {
return null;
}
final String actionName;
if (psiElement instanceof PsiClass) {
actionName = VcsBundle.message("action.name.show.history.for.class");
}
else if (psiElement instanceof PsiField) {
actionName = VcsBundle.message("action.name.show.history.for.field");
}
else if (psiElement instanceof PsiMethod) {
actionName = VcsBundle.message("action.name.show.history.for.method");
}
else if (psiElement instanceof PsiCodeBlock) {
actionName = VcsBundle.message("action.name.show.history.for.code.block");
}
else if (psiElement instanceof PsiStatement) {
actionName = VcsBundle.message("action.name.show.history.for.statement");
}
else {
return null;
}
TextRange textRange = psiElement.getTextRange();
if (textRange == null) {
return null;
}
VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
if (virtualFile == null) {
return null;
}
if (!virtualFile.isValid()) {
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
return new VcsSelection(document, textRange, actionName);
}
示例6: getSelection
import com.intellij.openapi.vcs.actions.VcsContext; //导入方法依赖的package包/类
@RequiredDispatchThread
public VcsSelection getSelection(VcsContext context)
{
final Editor editor = context.getEditor();
if(editor == null)
{
return null;
}
PsiElement psiElement = TargetElementUtil.findTargetElement(editor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
if(psiElement == null || !psiElement.isValid())
{
return null;
}
final String actionName;
if(psiElement instanceof XmlTag)
{
actionName = VcsBundle.message("action.name.show.history.for.tag");
}
else if(psiElement instanceof XmlText)
{
actionName = VcsBundle.message("action.name.show.history.for.text");
}
else
{
return null;
}
TextRange textRange = psiElement.getTextRange();
if(textRange == null)
{
return null;
}
VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
if(virtualFile == null)
{
return null;
}
if(!virtualFile.isValid())
{
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
return new VcsSelection(document, textRange, actionName);
}
示例7: getSelection
import com.intellij.openapi.vcs.actions.VcsContext; //导入方法依赖的package包/类
@Nullable
@RequiredDispatchThread
public VcsSelection getSelection(final VcsContext context) {
final Editor editor = context.getEditor();
if (editor == null) return null;
PsiElement psiElement = TargetElementUtil.findTargetElement(editor, ContainerUtil.newHashSet(TargetElementUtilEx.ELEMENT_NAME_ACCEPTED));
if (psiElement == null) {
return null;
}
if (!psiElement.isValid()) {
return null;
}
if (psiElement instanceof PsiCompiledElement) {
return null;
}
final String actionName;
if (psiElement instanceof PsiClass) {
actionName = VcsBundle.message("action.name.show.history.for.class");
}
else if (psiElement instanceof PsiField) {
actionName = VcsBundle.message("action.name.show.history.for.field");
}
else if (psiElement instanceof PsiMethod) {
actionName = VcsBundle.message("action.name.show.history.for.method");
}
else if (psiElement instanceof PsiCodeBlock) {
actionName = VcsBundle.message("action.name.show.history.for.code.block");
}
else if (psiElement instanceof PsiStatement) {
actionName = VcsBundle.message("action.name.show.history.for.statement");
}
else {
return null;
}
TextRange textRange = psiElement.getTextRange();
if (textRange == null) {
return null;
}
VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
if (virtualFile == null) {
return null;
}
if (!virtualFile.isValid()) {
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
return new VcsSelection(document, textRange, actionName);
}