use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class HTMLDocumentLoader method preLoadAdapt.
protected void preLoadAdapt(IStructuredModel structuredModel) {
// DMW: just added this preload on 8/16/2002
// I noticed the ProagatingAdapterFactory was being added,
// that that the ProagatingAdapterAdapter was not being
// preload adapted -- I'm assuing it ALWAYS has to be.
IDOMModel domModel = (IDOMModel) structuredModel;
// if there is a model in the adapter, this will adapt it to
// first node. After that the PropagatingAdater spreads over the
// children being
// created. Each time that happends, a side effect is to
// also "spread" sprecific registered adapters,
// they two can propigate is needed.
((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class);
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class HTMLModelLoader method preLoadAdapt.
protected void preLoadAdapt(IStructuredModel structuredModel) {
super.preLoadAdapt(structuredModel);
// DMW: just added this preload on 8/16/2002
// I noticed the ProagatingAdapterFactory was being added,
// that that the ProagatingAdapterAdapter was not being
// preload adapted -- I'm assuing it ALWAYS has to be.
IDOMModel domModel = (IDOMModel) structuredModel;
// if there is a model in the adapter, this will adapt it to
// first node. After that the PropagatingAdater spreads over the
// children being
// created. Each time that happends, a side effect is to
// also "spread" sprecific registered adapters,
// they two can propigate is needed.
((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class);
if (Debug.debugNotificationAndEvents) {
PropagatingAdapter propagatingAdapter = (PropagatingAdapter) ((INodeNotifier) domModel.getDocument()).getAdapterFor(PropagatingAdapter.class);
propagatingAdapter.addAdaptOnCreateFactory(new DebugAdapterFactory());
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class TEIValidation method testCustomTagInAttribute.
public void testCustomTagInAttribute() throws Exception {
// $NON-NLS-1$
final String path = "/" + PROJECT_NAME + "/WebContent/test.jsp";
final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
IStructuredModel model = StructuredModelManager.getModelManager().getModelForRead(file);
try {
assertTrue("Not an IDOMModel", model instanceof IDOMModel);
NodeList divs = ((IDOMModel) model).getDocument().getElementsByTagName("div");
assertTrue("Missing a div", divs.getLength() > 0);
IDOMNode node = (IDOMNode) divs.item(0);
IStructuredDocumentRegion region = node.getStartStructuredDocumentRegion();
ITextRegionList regions = region.getRegions();
assertTrue(regions.size() > 2);
/* This test is failing as of 20180213 so until someone can debug and fix it, comment it out */
/* JSPJavaTranslatorCoreTest.waitForBuildAndValidation(getProject()); */
final TaglibHelper helper = new TaglibHelper(getProject());
final List problems = new ArrayList();
final IStructuredDocument document = model.getStructuredDocument();
ITextRegion embedded = regions.get(2);
assertTrue("Not a container region", embedded instanceof ITextRegionContainer);
helper.getCustomTag("test:foo", document, (ITextRegionContainer) embedded, problems);
/* assertEquals("No problems should be generated", 0, problems.size()); */
} finally {
if (model != null)
model.releaseFromRead();
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class JSPJavaTranslatorCoreTest method testIterationTagsIncomplete.
/**
* Tests that an iteration tag will generate
* @throws Exception
*/
public void testIterationTagsIncomplete() throws Exception {
String testName = "testIterationTags";
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(testName);
if (!project.isAccessible()) {
// Create new project
project = BundleResourceUtil.createSimpleProject(testName, null, null);
assertTrue(project.exists());
BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/" + testName, "/" + testName);
}
/* This test is failing as of 20180213 so until someone can debug and fix it, comment it out */
/* waitForBuildAndValidation(project); */
IFile testFile = project.getFile("/WebContent/test_missing_end_tag.jsp");
assertTrue("test_missing_end_tag.jsp is not accessible", testFile.isAccessible());
IDOMModel model = null;
try {
model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(testFile);
ModelHandlerForJSP.ensureTranslationAdapterFactory(model);
JSPTranslationAdapter translationAdapter = (JSPTranslationAdapter) model.getDocument().getAdapterFor(IJSPTranslation.class);
JSPTranslationExtension translation = translationAdapter.getJSPTranslation();
String javaText = translation.getJavaText();
int startOffset = javaText.indexOf("} // [</plain:loop>]");
assertTrue("Missing end tag was not accounted for.", startOffset != -1);
} finally {
if (model != null)
model.releaseFromEdit();
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class JSPJavaTranslatorCoreTest method testIterationTags.
public void testIterationTags() throws Exception {
String testName = "testIterationTags";
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(testName);
if (!project.isAccessible()) {
// Create new project
project = BundleResourceUtil.createSimpleProject(testName, null, null);
assertTrue(project.exists());
BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/" + testName, "/" + testName);
}
/* This test is failing as of 20180213 so until someone can debug and fix it, comment it out */
/* waitForBuildAndValidation(project); */
IFile testFile = project.getFile("/WebContent/test.jsp");
assertTrue("test.jsp is not accessible", testFile.isAccessible());
IDOMModel model = null;
try {
model = (IDOMModel) StructuredModelManager.getModelManager().getModelForEdit(testFile);
ModelHandlerForJSP.ensureTranslationAdapterFactory(model);
JSPTranslationAdapter translationAdapter = (JSPTranslationAdapter) model.getDocument().getAdapterFor(IJSPTranslation.class);
JSPTranslationExtension translation = translationAdapter.getJSPTranslation();
translation.setProblemCollectingActive(true);
assertNotNull("No Java translation found", translation);
translation.reconcileCompilationUnit();
translation.setProblemCollectingActive(false);
List<IProblem> problems = translation.getProblems();
assertNotNull("Translation had a null problems list.", problems);
Iterator<IProblem> it = problems.iterator();
String javaText = translation.getJavaText();
int startOffset = javaText.indexOf("<plain:simple>");
assertTrue("<plan:simple> scope not found.", startOffset > 0);
int endOffset = javaText.indexOf("</plain:simple>", startOffset);
assertTrue("</plan:simple> scope not found.", endOffset > 0);
// Finds all errors caused by "continue cannot be used outside of a loop" - should only occur between <plain:simple></plain:simple>
while (it.hasNext()) {
IProblem problem = it.next();
if (problem.isError()) {
if ("continue cannot be used outside of a loop".equals(problem.getMessage())) {
assertTrue("'continue cannot be used outside of a loop' outside of iteration tag: ", problem.getSourceStart() > startOffset && problem.getSourceEnd() < endOffset);
}
}
}
} finally {
if (model != null)
model.releaseFromEdit();
}
}
Aggregations