use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement in project webtools.sourceediting by eclipse.
the class CommentElementFactory method create.
public Element create(String name, int nodeType) {
IDOMElement element = (IDOMElement) fDocument.createElement(name);
if (element == null)
return null;
element.setCommentTag(true);
if (nodeType == IS_EMPTY) {
element.setEmptyTag(true);
}
element.setJSPTag(fJSPTag);
CommentElementAdapter adapter = new CommentElementAdapter((nodeType == IS_END), fHandler);
element.addAdapter(adapter);
return element;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement in project webtools.sourceediting by eclipse.
the class XMLSearchParticipant method locateMatches.
private void locateMatches(SearchPattern pattern, SearchDocument document, SearchRequestor requestor, Map searchOptions, IProgressMonitor monitor) {
//
if (pattern.getMatchRule() == SearchPattern.R_PATTERN_MATCH) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(document.getPath()));
// TODO.. don't assume the category is COMPONENT_DECL... handle any arbitarty category
Entry[] entries = document.getEntries(IXMLSearchConstants.COMPONENT_DECL, null, 0);
for (int i = 0; i < entries.length; i++) {
// TODO.. don't assume this is just a component declaration entry
ComponentDeclarationEntry entry = (ComponentDeclarationEntry) entries[i];
SearchMatch searchMatch = new SearchMatch(null, 0, 0, file);
// $NON-NLS-1$
searchMatch.map.put("name", entry.getName());
// $NON-NLS-1$
searchMatch.map.put("metaName", entry.getMetaName());
try {
requestor.acceptSearchMatch(searchMatch);
} catch (Exception e) {
}
}
} else {
if (document.getModel() instanceof IDOMModel) {
IDOMModel domModel = (IDOMModel) document.getModel();
IDOMElement contextNode = (IDOMElement) domModel.getDocument().getDocumentElement();
DOMVisitor visitor = new DOMVisitor(document.getPath(), pattern, requestor);
visitor.visit(contextNode);
}
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement in project webtools.sourceediting by eclipse.
the class ElementNodeCleanupHandler method isCommentTag.
/**
* @param renamedNode
* @return
*/
private boolean isCommentTag(Node renamedNode) {
boolean result = false;
if (renamedNode instanceof IDOMElement) {
IDOMElement element = (IDOMElement) renamedNode;
result = element.isCommentTag();
}
return result;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement in project webtools.sourceediting by eclipse.
the class RenameComponentProcessor method addDeclarationUpdate.
final void addDeclarationUpdate(TextChangeManager manager, IFile file) throws CoreException {
String componentName = selectedComponent.getName();
String componentNamespace = selectedComponent.getNamespaceURI();
QualifiedName elementQName = new QualifiedName(componentNamespace, componentName);
QualifiedName typeQName = selectedComponent.getTypeQName();
SearchScope scope = new WorkspaceSearchScope();
if (file != null) {
scope = new SelectionSearchScope(new IResource[] { file });
}
CollectingSearchRequestor requestor = new CollectingSearchRequestor();
SearchPattern pattern = new XMLComponentDeclarationPattern(file, elementQName, typeQName);
SearchEngine searchEngine = new SearchEngine();
HashMap map = new HashMap();
if (singleFileOnly) {
map.put("searchDirtyContent", Boolean.TRUE);
}
searchEngine.search(pattern, requestor, scope, map, new NullProgressMonitor());
List results = requestor.getResults();
// more than one declaration found, so use offset as additional check
Position offsetPosition = null;
if (results.size() > 1) {
IDOMElement selectedElement = selectedComponent.getElement();
if (selectedElement != null) {
int startOffset = selectedElement.getStartOffset();
offsetPosition = new Position(startOffset, (selectedElement.getEndOffset() - startOffset));
}
}
for (Iterator iter = results.iterator(); iter.hasNext(); ) {
SearchMatch match = (SearchMatch) iter.next();
if (match != null) {
boolean addTextChange = true;
// additional check to verify correct declaration is changed
if (offsetPosition != null) {
addTextChange = offsetPosition.overlapsWith(match.getOffset(), match.getLength());
}
if (addTextChange) {
TextChange textChange = manager.get(match.getFile());
String newName = getNewElementName();
newName = quoteString(newName);
ReplaceEdit replaceEdit = new ReplaceEdit(match.getOffset(), match.getLength(), newName);
String editName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_update_declatation");
TextChangeCompatibility.addTextEdit(textChange, editName, replaceEdit);
}
}
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement in project webtools.sourceediting by eclipse.
the class XSLContentAssistRequestFactory method getContentAssistRequest.
/**
* Get the appropriate content assist request class for the XSL request.
* @return
*/
public IContentAssistProposalRequest getContentAssistRequest() {
NamedNodeMap nodeMap = xmlNode.getAttributes();
IDOMElement element = (IDOMElement) xmlNode;
IContentAssistProposalRequest proposal = commonAttributeProposals(nodeMap);
if (proposal instanceof NullContentAssistRequest) {
if (isElementProposal(element)) {
proposal = getElementProposals(nodeMap, element);
}
}
return proposal;
}
Aggregations