Package com.intellij.openapi.util

Examples of com.intellij.openapi.util.TextRange


    public PsiElement getElement() {
        return null;
    }

    public TextRange getRangeInElement() {
        return new TextRange(0, getTextLength());
    }
View Full Code Here


    public MarkupWicketIdReference(@NotNull XmlAttributeValue attributeValue, @NotNull PsiClass psiClass) {
        this.attributeValue = attributeValue;

        this.psiClass = psiClass;
        textRange = new TextRange(1, attributeValue.getTextLength() - 1);
    }
View Full Code Here

    private TextRange textRange;

    public ClassWicketIdReference(@NotNull PsiLiteralExpression wicketIdExpression, @NotNull PsiClass psiClass) {
        this.wicketIdExpression = wicketIdExpression;
        this.psiClass = psiClass;
        textRange = new TextRange(0, wicketIdExpression.getTextLength()); // issue 62: text range from 0 -> need also parentheses
    }
View Full Code Here

        {
            SelectInEditorManager selectInEditorManager = SelectInEditorManager.getInstance(cssBlock.getProject());
            VirtualFile virtualFile = cssBlock.getContainingFile().getVirtualFile();
            if (virtualFile != null)
            {
                TextRange textRange = cssBlock.getTextRange();
                selectInEditorManager.selectInEditor(virtualFile, textRange.getStartOffset(), textRange.getEndOffset(), false, false);
            }
        }
    }
View Full Code Here

        {
            SelectInEditorManager selectInEditorManager = SelectInEditorManager.getInstance(cssElement.getProject());
            VirtualFile virtualFile = cssElement.getContainingFile().getVirtualFile();
            if (virtualFile != null)
            {
                TextRange textRange = cssElement.getTextRange();
                selectInEditorManager.selectInEditor(virtualFile, textRange.getStartOffset(), textRange.getEndOffset(), false, false);
            }
        }
    }
View Full Code Here

        return place;
    }

    public TextRange getRangeInElement()
    {
        return new TextRange(0, getName().length());
    }
View Full Code Here

          );
        }
      }
    }
    else {
      List<BnfExpression> selectedExpression = findSelectedExpressionsInRange(parentExpression, new TextRange(startOffset, endOffset));
      if (selectedExpression.isEmpty()) {
        CommonRefactoringUtil.showErrorHint(editor.getProject(), editor,
                                             RefactoringBundle.message("refactoring.introduce.selection.error"), "Error", null);
        return;
      }
View Full Code Here

                                      final PsiFile file,
                                      final BnfRule currentRule,
                                      final List<BnfExpression> selectedExpression) {
    BnfExpression firstExpression = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(selectedExpression));
    BnfExpression lastExpression = ObjectUtils.assertNotNull(ContainerUtil.getLastItem(selectedExpression));
    final TextRange fixedRange = new TextRange(firstExpression.getTextRange().getStartOffset(), lastExpression.getTextRange().getEndOffset());
    final BnfRule ruleFromText = BnfElementFactory.createRuleFromText(file.getProject(), "a ::= " + fixedRange.substring(file.getText()));
    BnfExpressionOptimizer.optimize(ruleFromText.getExpression());

    final Map<OccurrencesChooser.ReplaceChoice, List<BnfExpression[]>> occurrencesMap = ContainerUtil.newLinkedHashMap();
    occurrencesMap.put(OccurrencesChooser.ReplaceChoice.NO, Collections.singletonList(selectedExpression.toArray(new BnfExpression[selectedExpression.size()])));
    occurrencesMap.put(OccurrencesChooser.ReplaceChoice.ALL, new ArrayList<BnfExpression[]>());
    file.acceptChildren(new PsiRecursiveElementWalkingVisitor() {
      @Override
      public void visitElement(PsiElement element) {
        if (element instanceof BnfExpression) {
          findOccurrences((BnfExpression)element, selectedExpression, occurrencesMap);
        }
        else if (element instanceof BnfAttrs) {
          return;
        }
        super.visitElement(element);
      }
    });
    if (occurrencesMap.get(OccurrencesChooser.ReplaceChoice.ALL).size() <= 1 && !ApplicationManager.getApplication().isUnitTestMode()) {
      occurrencesMap.remove(OccurrencesChooser.ReplaceChoice.ALL);
    }

    final Pass<OccurrencesChooser.ReplaceChoice> callback = new Pass<OccurrencesChooser.ReplaceChoice>() {
      @Override
      public void pass(final OccurrencesChooser.ReplaceChoice choice) {
        new WriteCommandAction.Simple(project, REFACTORING_NAME, file) {
          @Override
          public void run() {
            final PsiFile containingFile = currentRule.getContainingFile();
            String newRuleName = choseRuleName(containingFile);
            String newRuleText = "private " + newRuleName + " ::= " + ruleFromText.getExpression().getText();
            BnfRule addedRule = addNextRule(project, currentRule, newRuleText);
            if (choice == OccurrencesChooser.ReplaceChoice.ALL) {
              List<BnfExpression[]> exprToReplace = occurrencesMap.get(OccurrencesChooser.ReplaceChoice.ALL);
              replaceUsages(project, exprToReplace, addedRule.getId());
            } else {
              List<BnfExpression[]> exprToReplace = occurrencesMap.get(OccurrencesChooser.ReplaceChoice.NO);
              replaceUsages(project, exprToReplace, addedRule.getId());
            }
            final BnfIntroduceRulePopup popup = new BnfIntroduceRulePopup(project, editor, addedRule, addedRule.getExpression());

            editor.getCaretModel().moveToOffset(addedRule.getTextOffset());
            PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
            popup.performInplaceRefactoring(null);
          }
        }.execute();
      }
    };
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      callback.pass(OccurrencesChooser.ReplaceChoice.ALL);
    }
    else {
      new OccurrencesChooser<BnfExpression[]>(editor) {
        @Override
        protected TextRange getOccurrenceRange(BnfExpression[] occurrence) {
          return new TextRange(occurrence[0].getTextRange().getStartOffset(),
                               occurrence[occurrence.length - 1].getTextRange().getEndOffset());
        }
      }.showChooser(callback, occurrencesMap);
    }
  }
View Full Code Here

    final PsiElement body = DartResolveUtil.getBody(myDartClass);
    if (body == null) {
      editor.getCaretModel().moveToOffset(offset);
    }
    else {
      final TextRange bodyRange = body.getTextRange();
      editor.getCaretModel().moveToOffset(bodyRange.containsOffset(offset) ? offset : bodyRange.getEndOffset());
    }
  }
View Full Code Here

    functionBody.append(controlFlow.getSignature(functionName));
    functionBody.append("{\n");

    final int startOffset = elements[0].getTextOffset();
    final int endOffset = elements[elements.length - 1].getTextRange().getEndOffset();
    functionBody.append(new TextRange(startOffset, endOffset).substring(elements[0].getContainingFile().getText()));

    if (!controlFlow.getReturnValues().isEmpty()) {
      functionBody.append("\nreturn ");
      final DartComponentName componentName = controlFlow.getReturnValues().iterator().next();
      functionBody.append(componentName.getName());
View Full Code Here

TOP

Related Classes of com.intellij.openapi.util.TextRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.