private void validateIsListProperty(StructuralPropertyDescriptor property) { if (!property.isChildListProperty()) { String message= property.getId() + " is not a list property"; //$NON-NLS-1$ throw new IllegalArgumentException(message); } }
private void validateIsPropertyOfNode(StructuralPropertyDescriptor property, ASTNode node) { if (!property.getNodeClass().isInstance(node)) { String message= property.getId() + " is not a property of type " + node.getClass().getName(); //$NON-NLS-1$ throw new IllegalArgumentException(message); } }
private final int doVisit(ASTNode parent, StructuralPropertyDescriptor property, int offset) { Object node= getOriginalValue(parent, property); if (property.isChildProperty() && node != null) { return doVisit((ASTNode) node); } else if (property.isChildListProperty()) { return doVisitList((List) node, offset); } return offset; }
private void validatePropertyType(StructuralPropertyDescriptor prop, Object value) { if (prop.isChildListProperty()) { String message = "Can not modify a list property, use getListRewrite()"; //$NON-NLS-1$ throw new IllegalArgumentException(message); if (prop.isSimpleProperty() && ((SimplePropertyDescriptor) prop).isMandatory() || prop.isChildProperty() && ((ChildPropertyDescriptor) prop).isMandatory()) { String message = "Can not remove property " + prop.getId(); //$NON-NLS-1$ throw new IllegalArgumentException(message); if (prop.isSimpleProperty()) { SimplePropertyDescriptor p = (SimplePropertyDescriptor) prop; valueType = p.getValueType(); String message = value.getClass().getName() + " is not a valid type for " + prop.getNodeClass().getName() //$NON-NLS-1$ + " property '" + prop.getId() + '\''; //$NON-NLS-1$ throw new IllegalArgumentException(message);
/** * Returns a string suitable for debug purposes. * @return {@inheritDoc} */ public String toString() { StringBuffer b = new StringBuffer(); if (isChildListProperty()) { b.append("ChildList"); //$NON-NLS-1$ } if (isChildProperty()) { b.append("Child"); //$NON-NLS-1$ } if (isSimpleProperty()) { b.append("Simple"); //$NON-NLS-1$ } b.append("Property["); //$NON-NLS-1$ if (this.nodeClass != null) { b.append(this.nodeClass.getName()); } b.append(","); //$NON-NLS-1$ if (this.propertyId != null) { b.append(this.propertyId); } b.append("]"); //$NON-NLS-1$ return b.toString(); } }
StructuralPropertyDescriptor duplicateLoc = dupliacte.getLocationInParent(); if (originalParent != null && duplicateParent != null && originalLoc.getNodeClass().equals(duplicateLoc.getNodeClass()) && originalLoc.getId().equals(duplicateLoc.getId())) { if (originalLoc.isChildListProperty() && duplicateLoc.isChildListProperty()) { int indexOfOriginal = ((List<?>) originalParent.getStructuralProperty(originalLoc)).indexOf(original); int indexOfDuplicate = ((List<?>) duplicateParent.getStructuralProperty(duplicateLoc)).indexOf(dupliacte);
@Override public String toString() { StringBuffer buf= new StringBuffer(); buf.append(this.parent).append(" - "); //$NON-NLS-1$ buf.append(this.childProperty.getId()).append(": "); //$NON-NLS-1$ buf.append(this.event).append('\n'); return buf.toString(); } }
public Type resolveType() { SimpleName declSN = resolveDeclSimpleName(); if (declSN == null) throw new RuntimeException("Cannot resolve decl for: " + symbol); ASTNode maybeFrag = declSN.getParent(); ASTNode varDecl; if (maybeFrag instanceof VariableDeclarationFragment) { varDecl = maybeFrag.getParent(); } else if (maybeFrag instanceof SingleVariableDeclaration) { varDecl = maybeFrag; } else { throw new RuntimeException(maybeFrag.toString()); } List<StructuralPropertyDescriptor> props = varDecl.structuralPropertiesForType(); return props.stream().filter(p -> p.isChildProperty() && p.getId().equals("type")) .findAny().map(p -> (Type) varDecl.getStructuralProperty(p)) .orElseThrow(RuntimeException::new); }
private void validatePropertyType(StructuralPropertyDescriptor prop, Object node) { if (prop.isChildListProperty()) { String message= "Can not modify a list property, use a list rewriter"; //$NON-NLS-1$ throw new IllegalArgumentException(message); } }
/** * Internal helper method that adding a property descriptor. * * @param property the structural property descriptor * @param propertyList list beginning with the AST node class * followed by accumulated structural property descriptors */ static void addProperty(StructuralPropertyDescriptor property, List propertyList) { Class nodeClass = (Class) propertyList.get(0); if (property.getNodeClass() != nodeClass) { // easily made cut-and-paste mistake throw new RuntimeException("Structural property descriptor has wrong node class!"); //$NON-NLS-1$ } propertyList.add(property); }
private final void voidVisit(ASTNode parent, StructuralPropertyDescriptor property) { Object node= getOriginalValue(parent, property); if (property.isChildProperty() && node != null) { voidVisit((ASTNode) node); } else if (property.isChildListProperty()) { voidVisitList((List) node); } }
private void validatePropertyType(StructuralPropertyDescriptor prop, Object value) { if (prop.isChildListProperty()) { String message = "Can not modify a list property, use getListRewrite()"; //$NON-NLS-1$ throw new IllegalArgumentException(message); if (prop.isSimpleProperty() && ((SimplePropertyDescriptor) prop).isMandatory() || prop.isChildProperty() && ((ChildPropertyDescriptor) prop).isMandatory()) { String message = "Can not remove property " + prop.getId(); //$NON-NLS-1$ throw new IllegalArgumentException(message); if (prop.isSimpleProperty()) { SimplePropertyDescriptor p = (SimplePropertyDescriptor) prop; valueType = p.getValueType(); String message = value.getClass().getName() + " is not a valid type for " + prop.getNodeClass().getName() //$NON-NLS-1$ + " property '" + prop.getId() + '\''; //$NON-NLS-1$ throw new IllegalArgumentException(message);
/** * Returns a string suitable for debug purposes. * @return {@inheritDoc} */ public String toString() { StringBuffer b = new StringBuffer(); if (isChildListProperty()) { b.append("ChildList"); //$NON-NLS-1$ } if (isChildProperty()) { b.append("Child"); //$NON-NLS-1$ } if (isSimpleProperty()) { b.append("Simple"); //$NON-NLS-1$ } b.append("Property["); //$NON-NLS-1$ if (this.nodeClass != null) { b.append(this.nodeClass.getName()); } b.append(","); //$NON-NLS-1$ if (this.propertyId != null) { b.append(this.propertyId); } b.append("]"); //$NON-NLS-1$ return b.toString(); } }
&& originalLoc.getNodeClass().equals(duplicateLoc.getNodeClass()) && originalLoc.getId().equals(duplicateLoc.getId())) { if (originalLoc.isChildListProperty() && duplicateLoc.isChildListProperty()) { int indexOfOriginal= ((List<?>) originalParent.getStructuralProperty(originalLoc)).indexOf(original); int indexOfDuplicate= ((List<?>) duplicateParent.getStructuralProperty(duplicateLoc)).indexOf(dupliacte);
public String toString() { StringBuffer buf= new StringBuffer(); buf.append(this.parent).append(" - "); //$NON-NLS-1$ buf.append(this.childProperty.getId()).append(": "); //$NON-NLS-1$ buf.append(this.event).append('\n'); return buf.toString(); } }
static ASTNode[] getSiblingNodes(ASTNode node) { ASTNode parent= node.getParent(); StructuralPropertyDescriptor locationInParent= node.getLocationInParent(); if (locationInParent.isChildListProperty()) { List<? extends ASTNode> siblings= ASTNodes.getChildListProperty(parent, (ChildListPropertyDescriptor) locationInParent); return siblings.toArray(new ASTNode[siblings.size()]); } return null; }
/** * Internal helper method that adding a property descriptor. * * @param property the structural property descriptor * @param propertyList list beginning with the AST node class * followed by accumulated structural property descriptors */ static void addProperty(StructuralPropertyDescriptor property, List propertyList) { Class nodeClass = (Class) propertyList.get(0); if (property.getNodeClass() != nodeClass) { // easily made cut-and-paste mistake throw new RuntimeException("Structural property descriptor has wrong node class!"); //$NON-NLS-1$ } propertyList.add(property); }
private final int doVisit(ASTNode parent, StructuralPropertyDescriptor property, int offset) { Object node= getOriginalValue(parent, property); if (property.isChildProperty() && node != null) { return doVisit((ASTNode) node); } else if (property.isChildListProperty()) { return doVisitList((List) node, offset); } return offset; }
private void validateIsNodeProperty(StructuralPropertyDescriptor property) { if (property.isChildListProperty()) { String message= property.getId() + " is not a node property"; //$NON-NLS-1$ throw new IllegalArgumentException(message); } }
private void validatePropertyType(StructuralPropertyDescriptor prop, Object value) { if (prop.isChildListProperty()) { String message = "Can not modify a list property, use getListRewrite()"; //$NON-NLS-1$ throw new IllegalArgumentException(message); if (prop.isSimpleProperty() && ((SimplePropertyDescriptor) prop).isMandatory() || prop.isChildProperty() && ((ChildPropertyDescriptor) prop).isMandatory()) { String message = "Can not remove property " + prop.getId(); //$NON-NLS-1$ throw new IllegalArgumentException(message); if (prop.isSimpleProperty()) { SimplePropertyDescriptor p = (SimplePropertyDescriptor) prop; valueType = p.getValueType(); String message = value.getClass().getName() + " is not a valid type for " + prop.getNodeClass().getName() //$NON-NLS-1$ + " property '" + prop.getId() + '\''; //$NON-NLS-1$ throw new IllegalArgumentException(message);