Search in sources :

Example 26 with IDOMAttr

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr in project webtools.sourceediting by eclipse.

the class SelectAttributeContentAssist method getCompletionProposals.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest#getCompletionProposals()
 */
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    proposals.clear();
    adjustXPathStart(SELECT_ATTRIBUTE);
    int offset = getReplacementBeginPosition();
    IDOMAttr attrNode = getAttribute(SELECT_ATTRIBUTE);
    this.matchString = extractXPathMatchString(attrNode, getRegion(), getReplacementBeginPosition());
    addSelectProposals((Element) getNode().getParentNode(), offset);
    return getAllCompletionProposals();
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)

Example 27 with IDOMAttr

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr in project webtools.sourceediting by eclipse.

the class XMLComponentRenameParticipant method createChange.

// private RefactoringStatus createRenameChanges(final IProgressMonitor monitor) throws CoreException {
// Assert.isNotNull(monitor);
// final RefactoringStatus status= new RefactoringStatus();
// try {
// monitor.beginTask("RefactoringMessages.RenameComponentRefactoring_searching", 1);
// createRenameChanges(new SubProgressMonitor(monitor, 1));
// //updateChangeManager(new SubProgressMonitor(monitor, 1), status);
// } finally {
// monitor.done();
// }
// return status;
// }
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
    for (Iterator iter = matches.iterator(); iter.hasNext(); ) {
        SearchMatch match = (SearchMatch) iter.next();
        TextChange textChange = getChangeManager().get(match.getFile());
        String newName = getArguments().getNewName();
        String qualifier = "";
        if (getArguments() instanceof ComponentRenameArguments) {
            qualifier = ((ComponentRenameArguments) getArguments()).getQualifier();
        }
        if (match.getObject() instanceof Node) {
            Node node = (Node) match.getObject();
            if (node instanceof IDOMAttr) {
                IDOMAttr attr = (IDOMAttr) node;
                IDOMElement element = (IDOMElement) attr.getOwnerElement();
                newName = getNewQName(element, qualifier, newName);
            }
            newName = RenameComponentProcessor.quoteString(newName);
        }
        ReplaceEdit replaceEdit = new ReplaceEdit(match.getOffset(), match.getLength(), newName);
        String editName = RefactoringMessages.getString("RenameComponentProcessor.Component_Refactoring_update_reference");
        TextChangeCompatibility.addTextEdit(textChange, editName, replaceEdit);
    }
    // don't create any change now, all the changes are in changeManger variable and will be combined in RenameComponentProcessor.postCreateChange method
    return null;
}
Also used : SearchMatch(org.eclipse.wst.common.core.search.SearchMatch) IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) Node(org.w3c.dom.Node) Iterator(java.util.Iterator) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) TextChange(org.eclipse.ltk.core.refactoring.TextChange) IDOMElement(org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)

Example 28 with IDOMAttr

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr in project liferay-ide by liferay.

the class LiferayJspValidator method validateReferenceToJava.

@Override
protected void validateReferenceToJava(IXMLReferenceTo referenceTo, IDOMNode node, IFile file, IValidator validator, IReporter reporter, boolean batchMode) {
    if (node instanceof AttrImpl) {
        AttrImpl attrNode = (AttrImpl) node;
        Node parentNode = attrNode.getOwnerElement();
        if (_isSupportedTag(parentNode.getNodeName())) {
            IDOMAttr nameAttr = DOMUtils.getAttr((IDOMElement) parentNode, "name");
            if ((nameAttr != null) && (nameAttr.getNodeValue().contains(_action_request_action_name) || nameAttr.getNodeValue().contains(_javax_portlet_action))) {
                super.validateReferenceToJava(referenceTo, attrNode, file, validator, reporter, batchMode);
            }
        }
    }
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) Node(org.w3c.dom.Node) AttrImpl(org.eclipse.wst.xml.core.internal.document.AttrImpl)

Example 29 with IDOMAttr

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr in project jbosstools-hibernate by jbosstools.

the class BaseXMLHyperlinkSupport method getHyperlinkRegion.

protected IRegion getHyperlinkRegion(Node node) {
    IRegion hyperRegion = null;
    if (node != null) {
        short nodeType = node.getNodeType();
        if (nodeType == Node.DOCUMENT_TYPE_NODE) {
            // handle doc type node
            IDOMNode docNode = (IDOMNode) node;
            hyperRegion = new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset());
        } else if (nodeType == Node.ATTRIBUTE_NODE) {
            // handle attribute nodes
            IDOMAttr att = (IDOMAttr) node;
            // do not include quotes in attribute value region
            int regOffset = att.getValueRegionStartOffset();
            int regLength = att.getValueRegion().getTextLength();
            String attValue = att.getValueRegionText();
            if (org.eclipse.wst.sse.core.utils.StringUtils.isQuoted(attValue)) {
                ++regOffset;
                regLength = regLength - 2;
            }
            hyperRegion = new Region(regOffset, regLength);
        }
    }
    return hyperRegion;
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) Region(org.eclipse.jface.text.Region) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion)

Aggregations

IDOMAttr (org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)29 IDOMElement (org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)10 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)10 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)9 NamedNodeMap (org.w3c.dom.NamedNodeMap)9 IRegion (org.eclipse.jface.text.IRegion)7 Region (org.eclipse.jface.text.Region)7 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)6 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)5 Node (org.w3c.dom.Node)5 Attr (org.w3c.dom.Attr)3 Element (org.w3c.dom.Element)3 SearchMatch (org.eclipse.wst.common.core.search.SearchMatch)2 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)2 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)2 ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)2 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)2 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)2 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)2 IDOMText (org.eclipse.wst.xml.core.internal.provisional.document.IDOMText)2