String canonicalText = reference.getCanonicalText();
TextRange referenceRange = reference.getRangeInElement();
TextRange range = element.getTextRange().cutOut(referenceRange).shiftRight(-offsetDelta);
- final String oldText = range.substring(document.getText());
+ final String oldText = document.getText(range);
if (!canonicalText.equals(oldText)) {
rangeToText.put(document.createRangeMarker(range), canonicalText);
}
HighlighterTargetArea.EXACT_RANGE);
final int offset = history.getTextLength();
- final String text = textRange.substring(consoleEditor.getDocument().getText());
+ final String text = consoleEditor.getDocument().getText(textRange);
history.insertString(offset, text);
final HighlighterIterator iterator = consoleEditor.getHighlighter().createIterator(0);
while (!iterator.atEnd()) {
Editor myEditor = getEditor();
if (myEditor == null) return;
for (TextRange wordRange : ranges) {
- String word = wordRange.substring(editor.getDocument().getText());
+ String word = editor.getDocument().getText(wordRange);
if (!word.equals(getEnteredName())) continue;
final SelectionModel selectionModel = editor.getSelectionModel();
myEditor.getSelectionModel().removeSelection();
*/
String getText();
- String getText(TextRange range);
+ @NotNull String getText(@NotNull TextRange range);
/**
* Use this method instead of {@link #getText()} if you do not need to create a copy of the content.
}
private static String getSubstring(Document document, TextRange range) {
- return range.substring(document.getText());
+ return document.getText(range);
}
private Document getOtherDocument() {
}
}
+ @NotNull
@Override
- public String getText(TextRange range) {
+ public String getText(@NotNull TextRange range) {
try {
final javax.swing.text.Document document = myTextComponent.getDocument();
return document.getText(range.getStartOffset(), range.getLength());
final Document document = editor.getDocument();
final TextRange textRange = evaluator.getExpressionRangeAtOffset(session.getProject(), document, offset);
if (textRange != null) {
- text = textRange.substring(document.getText());
+ text = document.getText(textRange);
}
}
}
myEvaluator = evaluator;
myDebugSession = session;
final Document document = editor.getDocument();
- myExpression = textRange.substring(document.getText());
+ myExpression = document.getText(textRange);
final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
myExpressionPosition = file != null ? XDebuggerUtil.getInstance().createPositionByOffset(file, textRange.getStartOffset()) : null;
}
TextRange selectedRange = getSelectedRange(editor, psiFile);
if (selectedRange == null) return null;
- String text = selectedRange.substring(editor.getDocument().getText());
+ String text = editor.getDocument().getText(selectedRange);
return new JavaI18nizeQuickFixDialog(project, jspFile, null, text, null, false, true){
protected String getTemplateName() {
return JavaTemplateUtil.TEMPLATE_I18NIZED_JSP_EXPRESSION;
int from = range.getStartOffset();
int till;
boolean addLast = true;
- Matcher matcher = toExclude.matcher(text.substring(range.getStartOffset(), range.getEndOffset()));
+ Matcher matcher = toExclude.matcher(range.substring(text));
while (matcher.find()) {
checkCancelled();
@Nullable
public String getWord() {
if (text == null || textRange == null) return null;
- return text.substring(textRange.getStartOffset(), textRange.getEndOffset());
+ return textRange.substring(text);
}
@Override
if (text == null || StringUtil.isEmpty(text)) {
return null;
}
- if (Verifier.checkCharacterData(text.substring(range.getStartOffset(), range.getEndOffset())) != null) {
+ if (Verifier.checkCharacterData(range.substring(text)) != null) {
return null;
}
}
List<CheckArea> results = new ArrayList<CheckArea>();
final IdentifierSplitter splitter = SplitterFactory.getInstance().getIdentifierSplitter();
- Matcher matcher = WORD.matcher(text.substring(range.getStartOffset(), range.getEndOffset()));
+ Matcher matcher = WORD.matcher(range.substring(text));
while (matcher.find()) {
if (matcher.end() - matcher.start() < MIN_RANGE_LENGTH) {
continue;
protected void doSplit(@NotNull String text, @NotNull TextRange range, List<CheckArea> results) {
Matcher matcher;
final WordSplitter ws = SplitterFactory.getInstance().getWordSplitter();
- matcher = EXTENDED_WORD_AND_SPECIAL.matcher(text.substring(range.getStartOffset(), range.getEndOffset()));
+ matcher = EXTENDED_WORD_AND_SPECIAL.matcher(range.substring(text));
while (matcher.find()) {
TextRange found = matcherRange(range, matcher);
}
List<CheckArea> results = new ArrayList<CheckArea>();
- Matcher specialMatcher = SPECIAL.matcher(text.substring(range.getStartOffset(), range.getEndOffset()));
+ Matcher specialMatcher = SPECIAL.matcher(range.substring(text));
if (specialMatcher.find()) {
TextRange found = matcherRange(range, specialMatcher);
addWord(text, results, true, found);