use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction in project webtools.sourceediting by eclipse.
the class AbstractXMLModelQueryCompletionProposalComputer method getAvailableChildElementDeclarations.
/**
* returns a list of CMNodes that are available within this parent context
* Given the grammar shown below and a snippet of XML code (where the '|'
* indicated the cursor position)
* the list would return all of the element declarations that are
* potential child elements of Foo.
*
* grammar : Foo -> (A, B, C)
* snippet : <Foo><A>|
* result : {A, B, C}
*
* TODO cs... do we need to pass in the 'kindOfAction'? Seems to me we
* could assume it's always an insert.
*
* @param parent
* @param childPosition
* @param kindOfAction
* @return
*/
private List getAvailableChildElementDeclarations(Element parent, int childPosition, int kindOfAction) {
List modelQueryActions = getAvailableModelQueryActionsAtIndex(parent, childPosition, ModelQuery.VALIDITY_NONE);
Iterator iterator = modelQueryActions.iterator();
List cmnodes = new Vector();
while (iterator.hasNext()) {
ModelQueryAction action = (ModelQueryAction) iterator.next();
if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
CMNode actionCMNode = action.getCMNode();
if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
cmnodes.add(actionCMNode);
}
}
}
return cmnodes;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction in project webtools.sourceediting by eclipse.
the class AbstractXMLModelQueryCompletionProposalComputer method getValidChildElementDeclarations.
/**
* returns a list of CMNodes that can be validly inserted at this
* childPosition
* Given the grammar shown below and a snippet of XML code (where the '|'
* indicated the cursor position)
* the list would return only the element declarations can be inserted
* while maintaing validity of the content.
*
* grammar : Foo -> (A, B, C)
* snippet : <Foo><A>|
* result : {B}
*
* @param parent
* @param childPosition
* @param kindOfAction
* @return
*/
private List getValidChildElementDeclarations(Element parent, int childPosition, int kindOfAction) {
List modelQueryActions = getAvailableModelQueryActionsAtIndex(parent, childPosition, ModelQuery.VALIDITY_STRICT);
Iterator iterator = modelQueryActions.iterator();
List cmnodes = new Vector();
while (iterator.hasNext()) {
ModelQueryAction action = (ModelQueryAction) iterator.next();
if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
CMNode actionCMNode = action.getCMNode();
if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
cmnodes.add(actionCMNode);
}
}
}
return cmnodes;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction in project webtools.sourceediting by eclipse.
the class CMValidatorValidationTest method verify.
private void verify(Element parentElement, String[] childElementsAvailable) {
List list = new ArrayList();
ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parentElement.getOwnerDocument());
CMElementDeclaration cmElementDeclaration = modelQuery.getCMElementDeclaration(parentElement);
modelQuery.getInsertActions(parentElement, cmElementDeclaration, -1, ModelQuery.INCLUDE_CHILD_NODES, ModelQuery.VALIDITY_STRICT, list);
assertEquals(childElementsAvailable.length, list.size());
List availableNodeNameList = new ArrayList();
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
availableNodeNameList.add(((ModelQueryAction) iterator.next()).getCMNode().getNodeName());
}
for (int i = 0; i < childElementsAvailable.length; i++) {
if (availableNodeNameList.indexOf(childElementsAvailable[i]) == -1) {
fail();
}
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction in project webtools.sourceediting by eclipse.
the class AbstractContentAssistProcessor method getValidChildElementDeclarations.
// returns a list of CMNodes that can be validly inserted at this
// childPosition
// Given the grammar shown below and a snippet of XML code (where the '|'
// indicated the cursor position)
// the list would return only the element declarations can be inserted
// while maintaing validity of the content.
//
// grammar : Foo -> (A, B, C)
// snippet : <Foo><A>|
// result : {B}
//
protected List getValidChildElementDeclarations(Element parent, int childPosition, int kindOfAction) {
List modelQueryActions = getAvailableChildrenAtIndex(parent, childPosition, ModelQuery.VALIDITY_STRICT);
Iterator iterator = modelQueryActions.iterator();
List cmnodes = new Vector();
while (iterator.hasNext()) {
ModelQueryAction action = (ModelQueryAction) iterator.next();
if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
CMNode actionCMNode = action.getCMNode();
if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
cmnodes.add(actionCMNode);
}
}
}
return cmnodes;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction in project webtools.sourceediting by eclipse.
the class AbstractContentAssistProcessor method getAvailableChildElementDeclarations.
// returns a list of CMNodes that are available within this parent context
// Given the grammar shown below and a snippet of XML code (where the '|'
// indicated the cursor position)
// the list would return all of the element declarations that are
// potential child elements of Foo.
//
// grammar : Foo -> (A, B, C)
// snippet : <Foo><A>|
// result : {A, B, C}
//
// TODO cs... do we need to pass in the 'kindOfAction'? Seems to me we
// could assume it's always an insert.
protected List getAvailableChildElementDeclarations(Element parent, int childPosition, int kindOfAction) {
List modelQueryActions = getAvailableChildrenAtIndex(parent, childPosition, ModelQuery.VALIDITY_NONE);
Iterator iterator = modelQueryActions.iterator();
List cmnodes = new Vector();
while (iterator.hasNext()) {
ModelQueryAction action = (ModelQueryAction) iterator.next();
if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
CMNode actionCMNode = action.getCMNode();
if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
cmnodes.add(actionCMNode);
}
}
}
return cmnodes;
}
Aggregations