This commit is contained in:
Alexey Kudravtsev
2010-08-20 11:57:02 +04:00
parent 1861ce1462
commit 685d5cde65
15 changed files with 16 additions and 15 deletions
@@ -94,7 +94,7 @@ public class SaveAsTemplateAction extends AnAction {
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);
}
@@ -354,7 +354,7 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
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()) {
@@ -93,7 +93,7 @@ public class NameSuggestionsField extends JPanel {
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();
@@ -49,7 +49,7 @@ public interface Document extends UserDataHolder {
*/
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.
@@ -143,7 +143,7 @@ public class MergeOperations {
}
private static String getSubstring(Document document, TextRange range) {
return range.substring(document.getText());
return document.getText(range);
}
private Document getOtherDocument() {
@@ -50,8 +50,9 @@ public class TextComponentDocument extends UserDataHolderBase implements Documen
}
}
@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());
@@ -54,7 +54,7 @@ public class XAddToWatchesFromEditorActionHandler extends XDebuggerActionHandler
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);
}
}
}
@@ -62,7 +62,7 @@ public class XValueHint extends AbstractValueHint {
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;
}
@@ -197,7 +197,7 @@ public class I18nizeAction extends AnAction implements I18nQuickFixHandler{
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;
@@ -100,7 +100,7 @@ public abstract class BaseSplitter implements Splitter {
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();
@@ -48,7 +48,7 @@ public class CheckArea {
@Nullable
public String getWord() {
if (text == null || textRange == null) return null;
return text.substring(textRange.getStartOffset(), textRange.getEndOffset());
return textRange.substring(text);
}
@Override
@@ -38,7 +38,7 @@ public class PlainTextSplitter extends BaseSplitter {
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;
}
@@ -40,7 +40,7 @@ public class PropertiesSplitter extends BaseSplitter {
}
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;
@@ -41,7 +41,7 @@ public class TextSplitter extends BaseSplitter {
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);
@@ -39,7 +39,7 @@ public class WordSplitter extends BaseSplitter {
}
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);