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


Java TargetElementUtil.adjustOffset方法代码示例

本文整理汇总了Java中consulo.codeInsight.TargetElementUtil.adjustOffset方法的典型用法代码示例。如果您正苦于以下问题:Java TargetElementUtil.adjustOffset方法的具体用法?Java TargetElementUtil.adjustOffset怎么用?Java TargetElementUtil.adjustOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在consulo.codeInsight.TargetElementUtil的用法示例。


在下文中一共展示了TargetElementUtil.adjustOffset方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createHighlightUsagesHandler

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Nullable
@Override
@RequiredReadAction
public HighlightUsagesHandlerBase createHighlightUsagesHandler(Editor editor, PsiFile file)
{
	int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
	PsiElement target = file.findElementAt(offset);
	if(target != null && target.getNode().getElementType() == CSharpDocTokenType.XML_NAME)
	{
		CSharpDocTagImpl docTag = PsiTreeUtil.getParentOfType(target, CSharpDocTagImpl.class);
		if(docTag == null)
		{
			return null;
		}
		return new CSharpDocTagHighlightUsagesHandler(editor, file, docTag);
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:19,代码来源:CSharpDocHighlightUsagesHandlerFactory.java

示例2: createHighlightUsagesHandler

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Nullable
@Override
@RequiredReadAction
public HighlightUsagesHandlerBase createHighlightUsagesHandler(Editor editor, PsiFile file)
{
	int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
	PsiElement target = file.findElementAt(offset);
	if(target != null && target.getNode().getElementType() == CSharpTokens.USING_KEYWORD)
	{
		CSharpUsingListChild listChild = PsiTreeUtil.getParentOfType(target, CSharpUsingListChild.class);
		if(listChild == null)
		{
			return null;
		}
		return new CSharpUsingHighlightUsagesHandler(editor, file, listChild);
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:19,代码来源:CSharpHighlightUsagesHandlerFactory.java

示例3: getNameIdentifier

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Override
protected PsiElement getNameIdentifier() {
  final PsiFile currentFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
  if (currentFile == myElementToRename.getContainingFile()){
    return super.getNameIdentifier();
  }
  if (currentFile != null) {
    int offset = myEditor.getCaretModel().getOffset();
    offset = TargetElementUtil.adjustOffset(currentFile, myEditor.getDocument(), offset);
    final PsiElement elementAt = currentFile.findElementAt(offset);
    if (elementAt != null) {
      final PsiElement referenceExpression = elementAt.getParent();
      if (referenceExpression != null) {
        final PsiReference reference = referenceExpression.getReference();
        if (reference != null && reference.resolve() == myElementToRename) {
          return elementAt;
        }
      }
    }
    return null;
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:MemberInplaceRenamer.java

示例4: createHighlightUsagesHandler

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Override
public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file) {
  int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
  PsiElement target = file.findElementAt(offset);
  if (target instanceof PsiKeyword) {
    PsiElement parent = target.getParent();
    if (PsiKeyword.TRY.equals(target.getText()) && parent instanceof PsiTryStatement) {
      return createHighlightTryHandler(editor, file, target, parent);
    }
    if (PsiKeyword.CATCH.equals(target.getText()) && parent instanceof PsiCatchSection) {
      return createHighlightCatchHandler(editor, file, target, parent);
    }
    if (PsiKeyword.THROWS.equals(target.getText())) {
      return createThrowsHandler(editor, file, target);
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:HighlightExceptionsHandlerFactory.java

示例5: getTargetElement

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Nullable
@RequiredDispatchThread
private static PsiElement getTargetElement(Editor editor, PsiFile file) {
  PsiElement target = TargetElementUtil.findTargetElement(editor, TargetElementUtil.getReferenceSearchFlags());

  if (target == null) {
    int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
    PsiElement element = file.findElementAt(offset);
    if (element == null) return null;
  }

  return target;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:HighlightUsagesHandler.java

示例6: createHighlightUsagesHandler

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Nullable
@Override
public final HighlightUsagesHandlerBase createHighlightUsagesHandler(Editor editor, PsiFile file) {
  int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
  PsiElement target = file.findElementAt(offset);
  if (target == null) return null;
  return createHighlightUsagesHandler(editor, file, target);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:HighlightUsagesHandlerFactoryBase.java

示例7: createHighlightUsagesHandler

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Override
public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file)
{
	int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
	PsiElement target = file.findElementAt(offset);
	if(target instanceof PsiKeyword)
	{
		if(PsiKeyword.RETURN.equals(target.getText()) || PsiKeyword.THROW.equals(target.getText()))
		{
			return new HighlightExitPointsHandler(editor, file, target);
		}
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:HighlightExitPointsHandlerFactory.java

示例8: createHighlightUsagesHandler

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Override
public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file) {
  int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
  final PsiElement target = file.findElementAt(offset);
  if (target instanceof PsiKeyword && (PsiKeyword.EXTENDS.equals(target.getText()) || PsiKeyword.IMPLEMENTS.equals(target.getText()))) {
    PsiElement parent = target.getParent();
    if (!(parent instanceof PsiReferenceList)) return null;
    PsiElement grand = parent.getParent();
    if (!(grand instanceof PsiClass)) return null;
    return new HighlightOverridingMethodsHandler(editor, file, target, (PsiClass) grand);
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:14,代码来源:HighlightOverridingMethodsHandlerFactory.java

示例9: createHighlightUsagesHandler

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Override
public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file) {
  int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
  final PsiElement target = file.findElementAt(offset);
  final PsiAnnotation annotation = PsiTreeUtil.getParentOfType(target, PsiAnnotation.class);
  if (annotation != null && Comparing.strEqual(SuppressWarnings.class.getName(), annotation.getQualifiedName())) {
    final VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile != null && !virtualFile.getFileType().isBinary()) {
      return new HighlightSuppressedWarningsHandler(editor, file, annotation, PsiTreeUtil.getParentOfType(target, PsiLiteralExpression.class));
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:14,代码来源:HighlightSuppressedWarningsFactory.java

示例10: getExpressionAtCaret

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Nullable
public PsiElement getExpressionAtCaret(final Editor editor, final PsiFile file) {
  int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
  if (offset == 0) {
    return null;
  }
  PsiElement atCaret = file.findElementAt(offset);

  PsiElement element = PsiTreeUtil.getParentOfType(atCaret, PsiExpression.class, PsiVariable.class);
  if (myDataFlowToThis && element instanceof PsiLiteralExpression) return null;
  return element;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:13,代码来源:SliceHandler.java

示例11: invoke

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext)
{
	editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
	final int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
	final PsiElement element = file.findElementAt(offset);
	PsiTypeElement typeElement = PsiTreeUtil.getParentOfType(element, PsiTypeElement.class);
	while(typeElement != null)
	{
		final PsiElement parent = typeElement.getParent();
		PsiElement[] toMigrate = null;
		if(parent instanceof PsiVariable)
		{
			toMigrate = extractReferencedVariables(typeElement);
		}
		else if((parent instanceof PsiMember && !(parent instanceof PsiClass)) || isClassArgument(parent))
		{
			toMigrate = new PsiElement[]{parent};
		}
		if(toMigrate != null && toMigrate.length > 0)
		{
			invoke(project, toMigrate, editor);
			return;
		}
		typeElement = PsiTreeUtil.getParentOfType(parent, PsiTypeElement.class, false);
	}
	CommonRefactoringUtil.showErrorHint(project, editor, "The caret should be positioned on type of field, variable, method or method parameter to be refactored", REFACTORING_NAME, "refactoring" +
			".migrateType");
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:30,代码来源:ChangeTypeSignatureHandler.java

示例12: isAvailableOnElementInEditorAndFile

import consulo.codeInsight.TargetElementUtil; //导入方法依赖的package包/类
@Override
protected boolean isAvailableOnElementInEditorAndFile(@NotNull final PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context)
{
	final int offset = TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
	final PsiElement psiElement = file.findElementAt(offset);
	final PsiReferenceParameterList referenceParameterList = PsiTreeUtil.getParentOfType(psiElement, PsiReferenceParameterList.class);
	if(referenceParameterList != null)
	{
		return referenceParameterList.getTypeArguments().length > 0;
	}
	return PsiTreeUtil.getParentOfType(psiElement, PsiTypeElement.class) != null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:13,代码来源:ChangeTypeSignatureAction.java


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