fix xpath inter-test dependency

This commit is contained in:
peter
2012-07-18 14:54:12 +02:00
parent 345c82b052
commit 4de3abc024
8 changed files with 40 additions and 29 deletions
@@ -18,7 +18,6 @@ package org.intellij.lang.xpath.completion;
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.patterns.PatternCondition;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
@@ -90,10 +89,6 @@ public class XPathCompletionContributor extends CompletionContributor {
}
final NamespaceContext namespaceContext = parent.getXPathContext().getNamespaceContext();
if (ApplicationManager.getApplication().isUnitTestMode()) {
System.out.println("XPathCompletionContributor.addCompletions");
System.out.println("namespaceContext = " + namespaceContext);
}
if (namespaceContext != null) {
final String prefixForURI = namespaceContext.getPrefixForURI(XPath2Type.XMLSCHEMA_NS, parent.getXPathContext().getContextElement());
if (prefixForURI != null && prefixForURI.length() > 0) {
@@ -16,19 +16,35 @@
package org.intellij.lang.xpath;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.xml.XmlElement;
import org.intellij.lang.xpath.context.ContextProvider;
import org.intellij.lang.xpath.context.NamespaceContext;
import org.intellij.lang.xpath.psi.XPath2Type;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.util.Collection;
import java.util.Collections;
class TestNamespaceContext implements NamespaceContext {
public static final TestNamespaceContext INSTANCE = new TestNamespaceContext();
private static final TestNamespaceContext INSTANCE = new TestNamespaceContext();
@TestOnly
public static void install(Disposable parent) {
final NamespaceContext old = ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT;
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
Disposer.register(parent, new Disposable() {
@Override
public void dispose() {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = old;
}
});
}
@Override
public String getNamespaceURI(String prefix, XmlElement context) {
@@ -13,21 +13,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.intellij.lang.xpath;
package org.intellij.lang.xpath
public class XPath2CompletionTest extends TestBase {
public void testCastInsert() throws Throwable {
final String name = getTestFileName();
myFixture.testCompletion(name + ".xpath2", name + "_after.xpath2");
TestNamespaceContext.install(getTestRootDisposable());
configure()
assert myFixture.lookupElementStrings.containsAll("xs:anyAtomicType", "xs:untypedAtomic", "xs:anyURI")
}
public void testTreatInsert() throws Throwable {
private void configure() {
final String name = getTestFileName();
myFixture.configureByFile(name + ".xpath2");
myFixture.completeBasic();
}
public void testTreatInsert() throws Throwable {
configure()
myFixture.type('\n');
myFixture.checkResultByFile(name + "_after.xpath2");
myFixture.checkResultByFile(getTestFileName() + "_after.xpath2");
}
@Override
@@ -15,7 +15,6 @@
*/
package org.intellij.lang.xpath;
import org.intellij.lang.xpath.context.ContextProvider;
import org.intellij.lang.xpath.psi.XPath2SequenceType;
import org.intellij.lang.xpath.psi.XPathBinaryExpression;
import org.intellij.lang.xpath.psi.XPathExpression;
@@ -32,7 +31,7 @@ public class XPath2ExpressionTest extends TestBase {
@Override
protected void setUp() throws Exception {
super.setUp();
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
}
public void testIntegerPlusInteger() throws Throwable {
@@ -15,8 +15,6 @@
*/
package org.intellij.lang.xpath;
import org.intellij.lang.xpath.context.ContextProvider;
/*
* Created by IntelliJ IDEA.
* User: sweinreuter
@@ -64,7 +62,7 @@ public class XPath2HighlightingTest extends XPath2HighlightingTestBase {
}
public void testValidOperations2() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
@@ -15,8 +15,6 @@
*/
package org.intellij.lang.xpath;
import org.intellij.lang.xpath.context.ContextProvider;
public class XPath2TypeTest extends XPath2HighlightingTestBase {
public void testQNameToQName() throws Throwable {
@@ -116,12 +114,12 @@ public class XPath2TypeTest extends XPath2HighlightingTestBase {
}
public void testDatePlusDuration() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
public void testDatePlusDate() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
@@ -142,37 +140,37 @@ public class XPath2TypeTest extends XPath2HighlightingTestBase {
}
public void testDateMinusDuration() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
public void testDateMinusDuration2() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
public void testDurationMinusDate() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
public void testNumericDivDuration() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
public void testNumericIDivDuration() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
public void testDurationDivNumeric() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
public void testDurationIDivNumeric() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
@@ -185,7 +183,7 @@ public class XPath2TypeTest extends XPath2HighlightingTestBase {
}
public void testRedundantTypeConversion() throws Throwable {
ContextProvider.DefaultProvider.NULL_NAMESPACE_CONTEXT = TestNamespaceContext.INSTANCE;
TestNamespaceContext.install(getTestRootDisposable());
doXPathHighlighting();
}
@@ -1 +0,0 @@
1 cast as a<caret>
+1
View File
@@ -22,6 +22,7 @@
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
<orderEntry type="module" module-name="testFramework" scope="TEST" />
<orderEntry type="module" module-name="dom-impl" scope="RUNTIME" />
<orderEntry type="library" scope="TEST" name="Groovy" level="project" />
</component>
</module>