better fix for IDEA-101698 & IDEA-123573

This commit is contained in:
Maxim.Mossienko
2014-04-11 19:28:13 +02:00
parent 4c92967cf0
commit 5c53c0d975
3 changed files with 30993 additions and 21 deletions
@@ -15,25 +15,16 @@
*/
package com.intellij.lang.properties.parsing;
import com.intellij.lang.ASTNode;
import com.intellij.lang.LighterASTNode;
import com.intellij.lang.LighterASTTokenNode;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.PsiParser;
import com.intellij.lang.*;
import com.intellij.lang.impl.PsiBuilderImpl;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Ref;
import com.intellij.psi.impl.source.tree.LightTreeUtil;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.xml.XmlElementType;
import com.intellij.psi.xml.XmlTag;
import com.intellij.psi.xml.XmlTokenType;
import com.intellij.util.ThreeState;
import com.intellij.util.TripleFunction;
import com.intellij.util.diff.FlyweightCapableTreeStructure;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author max
*/
@@ -44,18 +35,18 @@ public class PropertiesParser implements PsiParser {
public ThreeState fun(ASTNode oldNode,
LighterASTNode newNode,
FlyweightCapableTreeStructure<LighterASTNode> structure) {
if (oldNode.getElementType() == PropertiesElementTypes.PROPERTY) {
ASTNode oldName = oldNode.findChildByType(PropertiesTokenTypes.KEY_CHARACTERS);
if (oldName != null) {
String oldNameStr = oldName.getText();
CharSequence oldNameStr = oldName.getChars();
CharSequence newNameStr = findKeyCharacters(newNode, structure);
if (oldNameStr != null && !oldNameStr.equals(newNameStr)) {
if (oldNameStr != null && !Comparing.equal(oldNameStr, newNameStr)) {
return ThreeState.NO;
}
}
}
return ThreeState.UNSURE;
}
};
File diff suppressed because it is too large Load Diff
@@ -15,13 +15,12 @@
*/
package com.intellij.lang.properties;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import com.intellij.testFramework.PlatformTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import com.intellij.util.ThrowableRunnable;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -42,9 +41,7 @@ public class PropertiesEnterTest extends LightPlatformCodeInsightTestCase {
}
private static void typeEnter() {
EditorActionManager actionManager = EditorActionManager.getInstance();
EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_ENTER);
actionHandler.execute(getEditor(), DataManager.getInstance().getDataContext());
type('\n');
}
public void testEndLine() throws Exception { doTest(); }
@@ -53,6 +50,16 @@ public class PropertiesEnterTest extends LightPlatformCodeInsightTestCase {
public void testValue() throws Exception { doTest(); }
public void testBackslash() throws Exception { doTest(); }
public void testBeforeComment() throws Exception { doTest(); }
public void testPerformance() throws Exception {
configureByFile(BASE_PATH + getTestName(false)+".properties");
PlatformTestUtil.startPerformanceTest("Property files editing", 1000, new ThrowableRunnable() {
@Override
public void run() throws Throwable {
type("aaaa=bbb");
PsiDocumentManager.getInstance(ourProject).commitAllDocuments();
}
}).cpuBound().assertTiming();
}
private void doTest() throws Exception {
configureByFile(BASE_PATH + getTestName(false)+".properties");