Author: scabanovich
Date: 2011-07-22 11:47:54 -0400 (Fri, 22 Jul 2011)
New Revision: 33141
Added:
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/JavaContentAssistantTestCase.java
Modified:
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/AbstractContentAssistantTestCase.java
Log:
JBIDE-9380
https://issues.jboss.org/browse/JBIDE-9380
Modified:
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/AbstractContentAssistantTestCase.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/AbstractContentAssistantTestCase.java 2011-07-22
14:50:44 UTC (rev 33140)
+++
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/AbstractContentAssistantTestCase.java 2011-07-22
15:47:54 UTC (rev 33141)
@@ -11,6 +11,7 @@
package org.jboss.tools.common.base.test.contentassist;
+import java.lang.reflect.Field;
import java.util.List;
import junit.framework.TestCase;
@@ -20,11 +21,11 @@
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.test.util.WorkbenchUtils;
@@ -33,7 +34,7 @@
protected String fileName;
protected IProject project = null;
protected IEditorPart editorPart = null;
- protected StructuredTextEditor textEditor = null;
+ protected ITextEditor textEditor = null;
protected ISourceViewer viewer = null;
protected IContentAssistant contentAssistant = null;
protected IDocument document = null;
@@ -44,23 +45,32 @@
obtainTextEditor(editorPart);
- viewer = textEditor.getTextViewer();
+ viewer = getTextViewer();
document = viewer.getDocument();
SourceViewerConfiguration config = CATestUtil
.getSourceViewerConfiguration(textEditor);
- contentAssistant = (config == null ? null : config
- .getContentAssistant(viewer));
+ contentAssistant = getContentAssistantInternal();
+ //(config == null ? null : config.getContentAssistant(viewer));
assertTrue(
"Cannot get the Content Assistant instance for the editor for page \""
//$NON-NLS-1$
+ fileName + "\"", (contentAssistant != null)); //$NON-NLS-1$
- assertTrue("The IDocument is not instance of IStructuredDocument for page
\"" //$NON-NLS-1$
- + fileName + "\"", //$NON-NLS-1$
- (document instanceof IStructuredDocument));
+ }
+ private IContentAssistant getContentAssistantInternal() {
+ try {
+ Field f = SourceViewer.class.getDeclaredField("fContentAssistant");
+ f.setAccessible(true);
+ return (IContentAssistant)f.get(viewer);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
}
+ protected abstract ISourceViewer getTextViewer();
+
/**
* Looks into editorPart for the test editor to apply content assist to.
*
@@ -194,7 +204,7 @@
/**
* @return the jspTextEditor
*/
- public StructuredTextEditor getTextEditor() {
+ public ITextEditor getTextEditor() {
return textEditor;
}
Added:
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/JavaContentAssistantTestCase.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/JavaContentAssistantTestCase.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/JavaContentAssistantTestCase.java 2011-07-22
15:47:54 UTC (rev 33141)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.base.test.contentassist;
+
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+public class JavaContentAssistantTestCase extends AbstractContentAssistantTestCase {
+
+ protected void obtainTextEditor(IEditorPart editorPart) {
+ if(editorPart instanceof JavaEditor) {
+ textEditor = (ITextEditor)editorPart;
+ }
+ }
+
+ @Override
+ protected ISourceViewer getTextViewer() {
+ return ((JavaEditor)textEditor).getViewer();
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/contentassist/JavaContentAssistantTestCase.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain