use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSModelParser method insertBraceClose.
/**
*/
private CSSNodeImpl insertBraceClose(IStructuredDocumentRegion region) {
ICSSNode target = CSSModelUtil.findBraceContainer(fCreationContext.getTargetNode());
if (!(target instanceof CSSStructuredDocumentRegionContainer)) {
return null;
}
CSSStructuredDocumentRegionContainer parent = (CSSStructuredDocumentRegionContainer) target;
if (CSSModelUtil.isInterruption(parent, region)) {
ICSSNode node = parent.getParentNode();
if (node instanceof CSSNodeImpl) {
fCreationContext.setReparseStart(parent.getStartOffset());
fCreationContext.setReparseEnd(parent.getEndOffset());
((CSSNodeImpl) node).removeChild(parent);
}
return null;
}
if (parent instanceof ICSSPageRule || parent instanceof ICSSMediaRule || parent instanceof CSSFontFaceRule || parent instanceof ICSSStyleRule) {
CSSModelUtil.expandStructuredDocumentRegionContainer(parent, region);
if (!CSSModelUtil.isBraceClosed(target)) {
fCreationContext.setTargetNode(parent.getParentNode());
fCreationContext.setNextNode(parent.getNextSibling());
return parent;
}
}
return null;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSModelParser method getNodeAt.
/**
*/
private CSSNodeImpl getNodeAt(int offset) {
CSSNodeImpl rootNode = fCreationContext.getRootNode();
ICSSNode target = rootNode.getNodeAt(offset);
if (target instanceof CSSNodeImpl) {
return (CSSNodeImpl) target;
} else {
return null;
}
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSModelParser method cleanupLastNode.
/**
*/
boolean cleanupLastNode(IStructuredDocumentRegion lastNode, CSSStructuredDocumentRegionContainer target) {
if (lastNode == null || target == null) {
return false;
}
if (lastNode == target.getLastStructuredDocumentRegion()) {
IStructuredDocumentRegion prevNode = fStructuredDocumentWalker.getPrevNodeInCurrent(lastNode);
IStructuredDocumentRegion firstNode = target.getFirstStructuredDocumentRegion();
if (firstNode == null || fStructuredDocumentWalker.isOldNode(firstNode) || prevNode == null || prevNode.getStartOffset() < firstNode.getStartOffset()) {
target.setRangeStructuredDocumentRegion(null, null);
} else {
target.setLastStructuredDocumentRegion(prevNode);
}
ICSSNode parent = target.getParentNode();
if (parent instanceof CSSStructuredDocumentRegionContainer) {
cleanupLastNode(lastNode, (CSSStructuredDocumentRegionContainer) parent);
return true;
}
}
return false;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSModelParser method cleanupFirstNode.
/**
*/
boolean cleanupFirstNode(IStructuredDocumentRegion firstNode, CSSStructuredDocumentRegionContainer target) {
if (firstNode == null || target == null) {
return false;
}
if (firstNode == target.getFirstStructuredDocumentRegion()) {
IStructuredDocumentRegion nextNode = fStructuredDocumentWalker.getNextNodeInCurrent(firstNode);
IStructuredDocumentRegion lastNode = target.getLastStructuredDocumentRegion();
if (lastNode == null || fStructuredDocumentWalker.isOldNode(lastNode) || nextNode == null || lastNode.getStartOffset() < nextNode.getStartOffset()) {
target.setRangeStructuredDocumentRegion(null, null);
} else {
target.setFirstStructuredDocumentRegion(nextNode);
}
ICSSNode parent = target.getParentNode();
if (parent instanceof CSSStructuredDocumentRegionContainer) {
cleanupFirstNode(firstNode, (CSSStructuredDocumentRegionContainer) parent);
return true;
}
}
return false;
}
use of org.eclipse.wst.css.core.internal.provisional.document.ICSSNode in project webtools.sourceediting by eclipse.
the class CSSStyleDeclarationImpl method item.
/**
* Used to retrieve the properties that have been explicitly set in this
* declaration block. The order of the properties retrieved using this
* method does not have to be the order in which they were set. This
* method can be used to iterate over all properties in this declaration
* block.
*
* @param index
* Index of the property name to retrieve.
* @return The name of the property at this ordinal position. The empty
* string if no property exists at this position.
*/
public String item(int index) {
if (index < 0)
return null;
int i = 0;
ICSSNode node = getFirstChild();
while (node != null) {
if (node instanceof CSSStyleDeclItemImpl) {
if (i != index)
i++;
else {
CSSStyleDeclItemImpl item = (CSSStyleDeclItemImpl) node;
return item.getPropertyName();
}
}
node = node.getNextSibling();
}
return null;
}
Aggregations