• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ScopeHighlighter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.codeInsight.unwrap.ScopeHighlighter的典型用法代码示例。如果您正苦于以下问题:Java ScopeHighlighter类的具体用法?Java ScopeHighlighter怎么用?Java ScopeHighlighter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScopeHighlighter类属于com.intellij.codeInsight.unwrap包,在下文中一共展示了ScopeHighlighter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: showChooser

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
public static <T extends PsiElement> void showChooser(final Editor editor,
                                                      final List<T> expressions,
                                                      final Pass<T> callback,
                                                      final Function<T, String> renderer,
                                                      String title) {
  showChooser(editor, expressions, callback, renderer, title, ScopeHighlighter.NATURAL_RANGER);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:IntroduceTargetChooser.java


示例2: expand

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
@Override
public void expand(@NotNull PsiElement context, @NotNull final Editor editor) {
  List<PsiExpression> expressions = getExpressions(context, editor.getDocument(), editor.getCaretModel().getOffset());

  if (expressions.isEmpty()) {
    PostfixTemplatesUtils.showErrorHint(context.getProject(), editor);
  }
  else if (expressions.size() == 1) {
    doIt(editor, expressions.get(0));
  }
  else {
    IntroduceTargetChooser.showChooser(
      editor, expressions,
      new Pass<PsiExpression>() {
        public void pass(@NotNull final PsiExpression e) {
          ApplicationManager.getApplication().runWriteAction(new Runnable() {
            @Override
            public void run() {
              CommandProcessor.getInstance().executeCommand(e.getProject(), new Runnable() {
                public void run() {
                  doIt(editor, e);
                }
              }, "Expand postfix template", PostfixLiveTemplate.POSTFIX_TEMPLATE_ID);
            }
          });
        }
      },
      new PsiExpressionTrimRenderer.RenderFunction(),
      "Expressions", 0, ScopeHighlighter.NATURAL_RANGER
    );
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:33,代码来源:ExpressionPostfixTemplateWithChooser.java


示例3: PsiMethodListPopupStep

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
public PsiMethodListPopupStep(Editor editor, final List<SmartStepTarget> targets, final OnChooseRunnable stepRunnable) {
  myTargets = targets;
  myScopeHighlighter = new ScopeHighlighter(editor);
  myStepRunnable = stepRunnable;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:PsiMethodListPopupStep.java


示例4: getScopeHighlighter

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
@NotNull
public ScopeHighlighter getScopeHighlighter() {
  return myScopeHighlighter;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PsiMethodListPopupStep.java


示例5: processElementToWorkOn

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
public static void processElementToWorkOn(final Editor editor, final PsiFile file, final String refactoringName, final String helpId, final Project project, final ElementsProcessor<ElementToWorkOn> processor) {
  PsiLocalVariable localVar = null;
  PsiExpression expr = null;

  if (!editor.getSelectionModel().hasSelection()) {
    PsiElement element = TargetElementUtil.findTargetElement(editor, TargetElementUtil
                                                                       .ELEMENT_NAME_ACCEPTED | TargetElementUtil
                                                                       .REFERENCED_ELEMENT_ACCEPTED | TargetElementUtil
                                                                       .LOOKUP_ITEM_ACCEPTED);
    if (element instanceof PsiLocalVariable) {
      localVar = (PsiLocalVariable) element;
      PsiElement elementAt = file.findElementAt(editor.getCaretModel().getOffset());
      if (elementAt instanceof PsiIdentifier && elementAt.getParent() instanceof PsiReferenceExpression) {
        expr = (PsiExpression) elementAt.getParent();
      } else {
        final PsiReference reference = TargetElementUtil.findReference(editor);
        if (reference != null) {
          final PsiElement refElement = reference.getElement();
          if (refElement instanceof PsiReferenceExpression) {
            expr = (PsiReferenceExpression)refElement;
          }
        }
      }
    } else {
      final PsiLocalVariable variable = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PsiLocalVariable.class);

      final int offset = editor.getCaretModel().getOffset();
      final PsiElement[] statementsInRange = IntroduceVariableBase.findStatementsAtOffset(editor, file, offset);

      if (statementsInRange.length == 1 && IntroduceVariableBase.selectLineAtCaret(offset, statementsInRange)) {
        editor.getSelectionModel().selectLineAtCaret();
        final ElementToWorkOn elementToWorkOn = getElementToWorkOn(editor, file, refactoringName, helpId, project, localVar, expr);
        if (elementToWorkOn == null || elementToWorkOn.getLocalVariable() == null && elementToWorkOn.getExpression() == null || !processor.accept(elementToWorkOn)) {
          editor.getSelectionModel().removeSelection();
        }
      }

      if (!editor.getSelectionModel().hasSelection()){
        final List<PsiExpression> expressions = IntroduceVariableBase.collectExpressions(file, editor, offset);
        for (Iterator<PsiExpression> iterator = expressions.iterator(); iterator.hasNext(); ) {
          PsiExpression expression = iterator.next();
          if (!processor.accept(new ElementToWorkOn(null, expression))) {
            iterator.remove();
          }
        }

        if (expressions.isEmpty()) {
          editor.getSelectionModel().selectLineAtCaret();
        }
        else if (!IntroduceVariableBase.isChooserNeeded(expressions)) {
          expr = expressions.get(0);
        }
        else {
          final int selection = IntroduceVariableBase.preferredSelection(statementsInRange, expressions);
          IntroduceTargetChooser.showChooser(editor, expressions, new Pass<PsiExpression>() {
            @Override
            public void pass(final PsiExpression selectedValue) {
              PsiLocalVariable var = null; //replace var if selected expression == var initializer
              if (variable != null && variable.getInitializer() == selectedValue) {
                var = variable;
              }
              processor.pass(getElementToWorkOn(editor, file, refactoringName, helpId, project, var, selectedValue));
            }
          }, new PsiExpressionTrimRenderer.RenderFunction(), "Expressions", selection, ScopeHighlighter.NATURAL_RANGER);
          return;
        }
      }
    }
  }


  processor.pass(getElementToWorkOn(editor, file, refactoringName, helpId, project, localVar, expr));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:74,代码来源:ElementToWorkOn.java


示例6: invoke

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file, DataContext dataContext) {
  final SelectionModel selectionModel = editor.getSelectionModel();
  if (!selectionModel.hasSelection()) {
    final int offset = editor.getCaretModel().getOffset();
    final PsiElement[] statementsInRange = findStatementsAtOffset(editor, file, offset);

    //try line selection
    if (statementsInRange.length == 1 && selectLineAtCaret(offset, statementsInRange)) {
      selectionModel.selectLineAtCaret();
      final PsiExpression expressionInRange =
        findExpressionInRange(project, file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
      if (expressionInRange == null || getErrorMessage(expressionInRange) != null) {
        selectionModel.removeSelection();
      }
    }

    if (!selectionModel.hasSelection()) {
      final List<PsiExpression> expressions = collectExpressions(file, editor, offset);
      if (expressions.isEmpty()) {
        selectionModel.selectLineAtCaret();
      } else if (!isChooserNeeded(expressions)) {
        final TextRange textRange = expressions.get(0).getTextRange();
        selectionModel.setSelection(textRange.getStartOffset(), textRange.getEndOffset());
      }
      else {
        IntroduceTargetChooser.showChooser(editor, expressions,
          new Pass<PsiExpression>(){
            public void pass(final PsiExpression selectedValue) {
              invoke(project, editor, file, selectedValue.getTextRange().getStartOffset(), selectedValue.getTextRange().getEndOffset());
            }
          },
          new PsiExpressionTrimRenderer.RenderFunction(), "Expressions", preferredSelection(statementsInRange, expressions), ScopeHighlighter.NATURAL_RANGER);
        return;
      }
    }
  }
  if (invoke(project, editor, file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()) &&
      LookupManager.getActiveLookup(editor) == null) {
    selectionModel.removeSelection();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:IntroduceVariableBase.java


示例7: invoke

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file, DataContext dataContext) {
  final SelectionModel selectionModel = editor.getSelectionModel();
  if (!selectionModel.hasSelection()) {
    final int offset = editor.getCaretModel().getOffset();
    final PsiElement[] statementsInRange = findStatementsAtOffset(editor, file, offset);

    //try line selection
    if (statementsInRange.length == 1 && (!PsiUtil.isStatement(statementsInRange[0]) ||
                                          statementsInRange[0].getTextRange().getStartOffset() > offset ||
                                          statementsInRange[0].getTextRange().getEndOffset() < offset ||
                                          isPreferStatements())) {
      selectionModel.selectLineAtCaret();
      final PsiExpression expressionInRange =
        findExpressionInRange(project, file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
      if (expressionInRange == null || getErrorMessage(expressionInRange) != null) {
        selectionModel.removeSelection();
      }
    }

    if (!selectionModel.hasSelection()) {
      final List<PsiExpression> expressions = collectExpressions(file, editor, offset);
      if (expressions.isEmpty()) {
        selectionModel.selectLineAtCaret();
      } else if (expressions.size() == 1) {
        final TextRange textRange = expressions.get(0).getTextRange();
        selectionModel.setSelection(textRange.getStartOffset(), textRange.getEndOffset());
      }
      else {
        int selection;
        if (statementsInRange.length == 1 &&
            statementsInRange[0] instanceof PsiExpressionStatement &&
            PsiUtilCore.hasErrorElementChild(statementsInRange[0])) {
          selection = expressions.indexOf(((PsiExpressionStatement)statementsInRange[0]).getExpression());
        } else {
          PsiExpression expression = expressions.get(0);
          if (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression)expression).resolve() instanceof PsiLocalVariable) {
            selection = 1;
          }
          else {
            selection = -1;
          }
        }
        IntroduceTargetChooser.showChooser(editor, expressions,
          new Pass<PsiExpression>(){
            public void pass(final PsiExpression selectedValue) {
              invoke(project, editor, file, selectedValue.getTextRange().getStartOffset(), selectedValue.getTextRange().getEndOffset());
            }
          },
          new PsiExpressionTrimRenderer.RenderFunction(), "Expressions", selection, ScopeHighlighter.NATURAL_RANGER);
        return;
      }
    }
  }
  if (invoke(project, editor, file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()) &&
      LookupManager.getActiveLookup(editor) == null) {
    selectionModel.removeSelection();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:59,代码来源:IntroduceVariableBase.java


示例8: invoke

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file, DataContext dataContext)
{
	final SelectionModel selectionModel = editor.getSelectionModel();
	if(!selectionModel.hasSelection())
	{
		final int offset = editor.getCaretModel().getOffset();
		final PsiElement[] statementsInRange = findStatementsAtOffset(editor, file, offset);

		//try line selection
		if(statementsInRange.length == 1 && (!PsiUtil.isStatement(statementsInRange[0]) ||
				statementsInRange[0].getTextRange().getStartOffset() > offset ||
				statementsInRange[0].getTextRange().getEndOffset() < offset ||
				isPreferStatements()))
		{
			selectionModel.selectLineAtCaret();
			final PsiExpression expressionInRange = findExpressionInRange(project, file, selectionModel.getSelectionStart(),
					selectionModel.getSelectionEnd());
			if(expressionInRange == null || getErrorMessage(expressionInRange) != null)
			{
				selectionModel.removeSelection();
			}
		}

		if(!selectionModel.hasSelection())
		{
			final List<PsiExpression> expressions = collectExpressions(file, editor, offset);
			if(expressions.isEmpty())
			{
				selectionModel.selectLineAtCaret();
			}
			else if(expressions.size() == 1)
			{
				final TextRange textRange = expressions.get(0).getTextRange();
				selectionModel.setSelection(textRange.getStartOffset(), textRange.getEndOffset());
			}
			else
			{
				int selection;
				if(statementsInRange.length == 1 &&
						statementsInRange[0] instanceof PsiExpressionStatement &&
						PsiUtilCore.hasErrorElementChild(statementsInRange[0]))
				{
					selection = expressions.indexOf(((PsiExpressionStatement) statementsInRange[0]).getExpression());
				}
				else
				{
					PsiExpression expression = expressions.get(0);
					if(expression instanceof PsiReferenceExpression && ((PsiReferenceExpression) expression).resolve() instanceof
							PsiLocalVariable)
					{
						selection = 1;
					}
					else
					{
						selection = -1;
					}
				}
				IntroduceTargetChooser.showChooser(editor, expressions, new Pass<PsiExpression>()
				{
					public void pass(final PsiExpression selectedValue)
					{
						invoke(project, editor, file, selectedValue.getTextRange().getStartOffset(), selectedValue.getTextRange().getEndOffset
								());
					}
				}, new PsiExpressionTrimRenderer.RenderFunction(), "Expressions", selection, ScopeHighlighter.NATURAL_RANGER);
				return;
			}
		}
	}
	if(invoke(project, editor, file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()) && LookupManager.getActiveLookup
			(editor) == null)
	{
		selectionModel.removeSelection();
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:76,代码来源:IntroduceVariableBase.java


示例9: PsiMethodListPopupStep

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
public PsiMethodListPopupStep(Editor editor, final List<SmartStepTarget> targets, final OnChooseRunnable stepRunnable)
{
	myTargets = targets;
	myScopeHighlighter = new ScopeHighlighter(editor);
	myStepRunnable = stepRunnable;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:7,代码来源:PsiMethodListPopupStep.java


示例10: getScopeHighlighter

import com.intellij.codeInsight.unwrap.ScopeHighlighter; //导入依赖的package包/类
@NotNull
public ScopeHighlighter getScopeHighlighter()
{
	return myScopeHighlighter;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:6,代码来源:PsiMethodListPopupStep.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IntLinkedOpenHashSet类代码示例发布时间:2022-05-22
下一篇:
Java ResourceChangeListener类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap