Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yann Cébron
2014-11-19 10:48:52 +01:00
5 changed files with 37 additions and 3 deletions
@@ -85,6 +85,7 @@ public abstract class PsiAwareLineWrapPositionStrategy implements LineWrapPositi
return -1;
}
documentManager.commitDocument(document);
PsiElement element = psiFile.findElementAt(maxPreferredOffset);
if (element == null) {
return -1;
@@ -114,6 +114,9 @@ public class CodeStyleSettingsManager implements PersistentStateComponent<Elemen
return myTemporarySettings;
}
/**
* @see #dropTemporarySettings()
*/
public void setTemporarySettings(@NotNull CodeStyleSettings settings) {
myTemporarySettings = settings;
}
@@ -123,7 +123,7 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
* @param psiFile psi file for element
* @return a pair where first element is read usages and second is write usages
*/
public static Couple<Collection<TextRange>> getHighlightUsages(@NotNull PsiElement target, PsiFile psiFile, boolean withDecls) {
public static Couple<Collection<TextRange>> getHighlightUsages(@NotNull PsiElement target, PsiFile psiFile, boolean withDeclarations) {
Collection<TextRange> readRanges = new ArrayList<TextRange>();
Collection<TextRange> writeRanges = new ArrayList<TextRange>();
final ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(target);
@@ -143,7 +143,7 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
}
}
if (withDecls) {
if (withDeclarations) {
final TextRange declRange = HighlightUsagesHandler.getNameIdentifierRange(psiFile, target);
if (declRange != null) {
if (detector != null && detector.isDeclarationWriteAccess(target)) {
@@ -40,6 +40,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiReference;
import com.intellij.testFramework.EditorTestUtil;
import com.intellij.testFramework.HighlightTestInfo;
import com.intellij.testFramework.TestDataFile;
import com.intellij.usageView.UsageInfo;
@@ -59,7 +60,7 @@ import java.util.List;
*/
public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
@NonNls String CARET_MARKER = "<caret>";
@NonNls String CARET_MARKER = EditorTestUtil.CARET_TAG;
@NonNls String ERROR_MARKER = "error";
@NonNls String WARNING_MARKER = "warning";
@@ -1,5 +1,7 @@
package com.intellij.editor;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.testFramework.EditorTestUtil;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.testFramework.PlatformTestUtil;
@@ -28,6 +30,33 @@ public class XmlEditorTest extends LightCodeInsightTestCase {
checkResultByFile(getTestFilePath(false));
}
public void testHardWrap() throws Exception {
configureFromFileText("a.xml",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" +
"<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\">\n" +
"<g>\n" +
" <path clip-path=\"url(#SVGID_2_)\" fill=\"#ffffff\" stroke=\"<selection>#000000</selection>\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-miterlimit=\"10\" d=\"M19.333,8.333V12c0,1.519-7.333,4-7.333,4s-7.333-2.481-7.333-4V8.333\"/>\n" +
"</g>\n" +
"</svg>");
CodeStyleSettings clone = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().clone();
clone.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
try {
CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(clone);
EditorTestUtil.performTypingAction(getEditor(), 'x');
}
finally {
CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
}
checkResultByText("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" +
"<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\">\n" +
"<g>\n" +
" <path clip-path=\"url(#SVGID_2_)\" fill=\"#ffffff\" stroke=\"x\" stroke-width=\"2\" stroke-linecap=\"round\" \n" +
" stroke-linejoin=\"round\" stroke-miterlimit=\"10\" d=\"M19.333,8.333V12c0,1.519-7.333,4-7.333,4s-7.333-2.481-7.333-4V8.333\"/>\n" +
"</g>\n" +
"</svg>");
}
@NotNull
@Override
protected String getTestDataPath() {