used when breaking a node to transfer annotations to the new property
517588
function transferAnnotations (doc, path, offset, newPath, newOffset) {
  var index = doc.getIndex('annotations')
  var annotations = index.get(path, offset)
  for (let i = 0; i < annotations.length; i++) {
    let a = annotations[i]
    var isInside = (offset > a.start.offset && offset < a.end.offset)
    var start = a.start.offset
    var end = a.end.offset
    // 1. if the cursor is inside an annotation it gets either split or truncated
    if (isInside) {
      // create a new annotation if the annotation is splittable
      if (a.canSplit()) {
        let newAnno = a.toJSON()
        newAnno.id = uuid(a.type + '_')
        newAnno.start.path = newPath
        newAnno.start.offset = newOffset
        newAnno.end.path = newPath
        newAnno.end.offset = newOffset + a.end.offset - offset
        doc.create(newAnno)
      }
      // in either cases truncate the first part
      let newStartOffset = a.start.offset
      let newEndOffset = offset
      // if after truncate the anno is empty, delete it
      if (newEndOffset === newStartOffset) {
        doc.delete(a.id)
      // ... otherwise update the range
      } else {
        // TODO: Use coordintate ops!
        if (newStartOffset !== start) {
          doc.set([a.id, 'start', 'offset'], newStartOffset)
        }
        if (newEndOffset !== end) {
          doc.set([a.id, 'end', 'offset'], newEndOffset)
        }
      }
    // 2. if the cursor is before an annotation then simply transfer the annotation to the new node
    } else if (a.start.offset >= offset) {
      // TODO: Use coordintate ops!
      // Note: we are preserving the annotation so that anything which is connected to the annotation
      // remains valid.
      doc.set([a.id, 'start', 'path'], newPath)
      doc.set([a.id, 'start', 'offset'], newOffset + a.start.offset - offset)
      doc.set([a.id, 'end', 'path'], newPath)
      doc.set([a.id, 'end', 'offset'], newOffset + a.end.offset - offset)
    }
  }

  // TODO: fix support for container annotations
  // // same for container annotation anchors
  // index = doc.getIndex('container-annotation-anchors');
  // var anchors = index.get(path);
  // var containerAnnoIds = [];
  // forEach(anchors, function(anchor) {
  //   containerAnnoIds.push(anchor.id);
  //   var start = anchor.offset;
  //   if (offset <= start) {
  //     // TODO: Use coordintate ops!
  //     let coor = anchor.isStart?'start':'end'
  //     doc.set([anchor.id, coor, 'path'], newPath);
  //     doc.set([anchor.id, coor, 'offset'], newOffset + anchor.offset - offset);
  //   }
  // });
  // // check all anchors after that if they have collapsed and remove the annotation in that case
  // forEach(uniq(containerAnnoIds), function(id) {
  //   var anno = doc.get(id);
  //   var annoSel = anno.getSelection();
  //   if(annoSel.isCollapsed()) {
  //     // console.log("...deleting container annotation because it has collapsed" + id);
  //     doc.delete(id);
  //   }
  // });
}
349078
def parse_property_reference(parser, event, node): #pylint: disable=unused-argument
    

    name = _get_required_attribute(node, 'NAME')

    class_origin = _get_attribute(node, 'CLASSORIGIN')
    propagated = _get_attribute(node, 'PROPAGATED')

    qualifiers = []
    value = None

    (next_event, next_node) = six.next(parser)

    if _is_start(next_event, next_node, 'QUALIFIER'):

        qualifiers.append(parse_qualifier(parser, next_event, next_node))

        while 1:

            (next_event, next_node) = six.next(parser)

            if _is_start(next_event, next_node, 'VALUE.REFERENCE'):
                break

            if _is_start(next_event, next_node, 'QUALIFIER'):
                qualifiers.append(
                    parse_qualifier(parser, next_event, next_node))

            else:
                raise ParseError('Expecting QUALIFIER')

    if _is_start(next_event, next_node, 'VALUE.REFERENCE'):

        value = parse_value_reference(parser, next_event, next_node)
        (next_event, next_node) = six.next(parser)

    if not _is_end(next_event, next_node, 'PROPERTY.REFERENCE'):
        raise ParseError('Expecting end PROPERTY.REFERENCE')

    return CIMProperty(
        name,
        value,
        class_origin=class_origin,
        propagated=propagated,
        type='reference',
        qualifiers=dict([(x.name, x) for x in qualifiers]))
807096
function parsePropertyFunction(node, paramInfo) {
        var previousStrict, body;

        previousStrict = strict;
        body = parseFunctionSourceElements();

        if (strict && paramInfo.firstRestricted) {
            tolerateUnexpectedToken(paramInfo.firstRestricted, paramInfo.message);
        }
        if (strict && paramInfo.stricted) {
            tolerateUnexpectedToken(paramInfo.stricted, paramInfo.message);
        }

        strict = previousStrict;
        return node.finishFunctionExpression(null, paramInfo.params, paramInfo.defaults, body);
    }
373699
function handleProperties(schema, properties, node, stack) {
    var name = handleTagName(schema, node.tagName, node, stack)
    var attrs = schema.attributes
    var props = properties || {}
    var result = {}
    var allowed
    var prop
    var value

    allowed = own.call(attrs, name) ? attrs[name] : []
    allowed = [].concat(allowed, attrs['*'])

    for (prop in props) {
        value = props[prop]

        if (
            allowed.indexOf(prop) === -1 &&
            !(data(prop) && allowed.indexOf('data*') !== -1)
        ) {
            continue
        }

        if (value && typeof value === 'object' && 'length' in value) {
            value = handlePropertyValues(schema, value, prop)
        } else {
            value = handlePropertyValue(schema, value, prop)
        }

        if (value !== null && value !== undefined) {
            result[prop] = value
        }
    }

    return result
}
253018
def node_properties_update(new_node_properties)
      collection = connection[node_properties_collection]
      old_names = collection.find.batch_size(999).projection(_id: 1).map { |k| k[:_id] }
      delete = old_names - new_node_properties.keys
      data = new_node_properties.map do |k, v|
        {
          replace_one:
          {
            filter: { _id: k },
            replacement: v,
            upsert: true
          }
        }
      end
      collection.bulk_write(data)
      collection.delete_many(_id: { '$in' => delete })
    end
180037
function wrapANodeMethods (obj) {
  var newObj = {};
  var ANodeMethods = [
    'attachedCallback',
    'attributeChangedCallback',
    'createdCallback',
    'detachedCallback'
  ];
  wrapMethods(newObj, ANodeMethods, obj, ANode.prototype);
  copyProperties(obj, newObj);
  return newObj;
}
424863
def apply(self, cls, originalMemberNameList, memberName, classNamingConvention, getter, setter):
        
        # The new property.
        originalProperty = None
        if memberName in originalMemberNameList:
            member = getattr(cls, memberName)
            
            # There's already a member with that name and it's not a property
            if not isinstance(member, property):
                raise InvalidPropertyOverrideError(memberName, cls.__name__)
            
            # If property already exists, we will just modify it.
            originalProperty = member
        
        kwargs = {self._KEY_PROPERTY_GET: getattr(originalProperty, self._KEY_PROPERTY_GET, None) or getter,
                  self._KEY_PROPERTY_SET: getattr(originalProperty, self._KEY_PROPERTY_SET, None) or setter,
                  self._KEY_PROPERTY_DEL: getattr(originalProperty, self._KEY_PROPERTY_DEL, None) or None,
                  self._KEY_PROPERTY_DOC: getattr(originalProperty, self._KEY_PROPERTY_DOC, None) or None}
        setattr(cls, memberName, property(**kwargs))
1186646
public void visitAnnotations(AnnotatedNode node) {
        super.visitAnnotations(node);
        for (AnnotationNode an : node.getAnnotations()) {
            String name = an.getClassNode().getName();
            if ((GRAB_CLASS_NAME.equals(name))
                    || (allowShortGrab && GRAB_SHORT_NAME.equals(name))
                    || (grabAliases.contains(name))) {
                grabAnnotations.add(an);
            }
            if ((GRABEXCLUDE_CLASS_NAME.equals(name))
                    || (allowShortGrabExcludes && GRABEXCLUDE_SHORT_NAME.equals(name))
                    || (grabExcludeAliases.contains(name))) {
                grabExcludeAnnotations.add(an);
            }
            if ((GRABCONFIG_CLASS_NAME.equals(name))
                    || (allowShortGrabConfig && GRABCONFIG_SHORT_NAME.equals(name))
                    || (grabConfigAliases.contains(name))) {
                grabConfigAnnotations.add(an);
            }
            if ((GRAPES_CLASS_NAME.equals(name))
                    || (allowShortGrapes && GRAPES_SHORT_NAME.equals(name))
                    || (grapesAliases.contains(name))) {
                grapesAnnotations.add(an);
            }
            if ((GRABRESOLVER_CLASS_NAME.equals(name))
                    || (allowShortGrabResolver && GRABRESOLVER_SHORT_NAME.equals(name))
                    || (grabResolverAliases.contains(name))) {
                grabResolverAnnotations.add(an);
            }
        }
    }
274933
private void addJavaFXPropertyToClass(SourceUnit source, AnnotationNode node, ClassNode classNode) {
        for (PropertyNode propertyNode : classNode.getProperties()) {
            FieldNode field = propertyNode.getField();
            // look to see if per-field handlers will catch this one...
            if (hasFXBindableAnnotation(field)
                || ((field.getModifiers() & Modifier.FINAL) != 0)
                || field.isStatic()) {
                // explicitly labeled properties are already handled,
                // don't transform final properties
                // don't transform static properties
                continue;
            }
            createPropertyGetterSetter(classNode, propertyNode);
        }
    }
485768
@SuppressWarnings("unchecked")
    public A replace(Property property) {
        Data data = getData();
        Data replaced = data.replace(property);
        if (!replaced.isEmpty()) {
            return copy(delegate.put("data", Property.toArrayNode(replaced)));
        }
        return (A)this;
    }
803482
public void setProperty(final String property, final Object newValue) {
        if (property.startsWith("@")) {
            if (newValue instanceof String || newValue instanceof GString) {
                final Iterator iter = iterator();

                while (iter.hasNext()) {
                    final NodeChild child = (NodeChild) iter.next();

                    child.attributes().put(property.substring(1), newValue);
                }
            }
        } else {
            final GPathResult result = new NodeChildren(this, property, this.namespaceTagHints);

            if (newValue instanceof Map) {
                for (Object o : ((Map) newValue).entrySet()) {
                    final Map.Entry entry = (Map.Entry) o;
                    result.setProperty("@" + entry.getKey(), entry.getValue());
                }
            } else {
                if (newValue instanceof Closure) {
                    result.replaceNode((Closure) newValue);
                } else {
                    result.replaceBody(newValue);
                }
            }
        }
    }
867418
private Node renameProperty(Node propertyName) {
    checkArgument(propertyName.isString());
    if (!renameProperties) {
      return propertyName;
    }
    Node call = IR.call(
        IR.name(NodeUtil.JSC_PROPERTY_NAME_FN).srcref(propertyName),
        propertyName);
    call.srcref(propertyName);
    call.putBooleanProp(Node.FREE_CALL, true);
    call.putBooleanProp(Node.IS_CONSTANT_NAME, true);
    return call;
  }
1228447
function fuseAnnotation (tx, annos) {
  if (!isArray(annos) || annos.length < 2) {
    throw new Error('fuseAnnotation(): at least two annotations are necessary.')
  }
  let sel, annoType
  annos.forEach(function (anno, idx) {
    if (idx === 0) {
      sel = anno.getSelection()
      annoType = anno.type
    } else {
      if (anno.type !== annoType) {
        throw new Error('fuseAnnotation(): all annotations must be of the same type.')
      }
      sel = sel.expand(anno.getSelection())
    }
  })
  // expand the first and delete the others
  for (var i = 1; i < annos.length; i++) {
    tx.delete(annos[i].id)
  }
  expandAnnotation(tx, annos[0], sel)
  tx.setSelection(sel)
}
668495
function (node, name, value) {
    var propertyInfo = DOMProperty_1.getPropertyInfo(name);

    if (propertyInfo && DOMProperty_1.shouldSetAttribute(name, value)) {
      var mutationMethod = propertyInfo.mutationMethod;
      if (mutationMethod) {
        mutationMethod(node, value);
      } else if (shouldIgnoreValue(propertyInfo, value)) {
        DOMPropertyOperations.deleteValueForProperty(node, name);
        return;
      } else if (propertyInfo.mustUseProperty) {
        // Contrary to `setAttribute`, object properties are properly
        // `toString`ed by IE8/9.
        node[propertyInfo.propertyName] = value;
      } else {
        var attributeName = propertyInfo.attributeName;
        var namespace = propertyInfo.attributeNamespace;
        // `setAttribute` with objects becomes only `[object]` in IE8/9,
        // ('' + value) makes it output the correct toString()-value.
        if (namespace) {
          node.setAttributeNS(namespace, attributeName, '' + value);
        } else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
          node.setAttribute(attributeName, '');
        } else {
          node.setAttribute(attributeName, '' + value);
        }
      }
    } else {
      DOMPropertyOperations.setValueForAttribute(node, name, DOMProperty_1.shouldSetAttribute(name, value) ? value : null);
      return;
    }

    {
      var payload = {};
      payload[name] = value;
      ReactInstrumentation.debugTool.onHostOperation({
        instanceID: ReactDOMComponentTree_1.getInstanceFromNode(node)._debugID,
        type: 'update attribute',
        payload: payload
      });
    }
  }
112238
function(startNode, type, endNode, properties, callback) {
    if (typeof properties === 'function') {
      callback = properties;
      properties = null;
    }

    if (Array.isArray(startNode)) {
      var txn = this._safeBatch();
      var args = [ type, endNode, properties ];
      async.map(startNode, naan.ecurry(txn.rel.create, args, [1,2,3]), 
          function(err, rels) {
            if (!err && Array.isArray(endNode))
              return callback(err, _.flatten(rels));
            callback(err, rels);
          });
      return this._safeBatchCommit(txn);
    } else if (Array.isArray(endNode)) {
      var txn = this._safeBatch();
      var args = [ startNode, type, properties ];
      async.map(endNode, naan.ecurry(txn.rel.create, args, [0,1,3]), callback);
      return this._safeBatchCommit(txn);
    }
    
    var startNodeId = this._getId(startNode),
        endNodeId = this._getId(endNode);

    if (!this._isValidId(startNodeId) ||
        !this._isValidId(endNodeId)) {
      return callback(new Error("Invalid ID"));
    }

    var request = {
      to: this._location('node', endNodeId),
      type: type,
    };

    if (properties) {
      request['data'] = properties;
    }

    var endpoint = util.format('%s/relationships', this._nodeRoot(startNodeId));
    var op = this.operation(endpoint, 'POST', request);
    this.call(op, function(err, rel) {
      if (err) {
        callback(err);
      } else {
        callback(null, this._createRelationshipObject(rel));
      }
    });
  }
418985
function (node, name, expected) {
    {
      var propertyInfo = DOMProperty_1.getPropertyInfo(name);
      if (propertyInfo) {
        var mutationMethod = propertyInfo.mutationMethod;
        if (mutationMethod || propertyInfo.mustUseProperty) {
          return node[propertyInfo.propertyName];
        } else {
          var attributeName = propertyInfo.attributeName;

          var stringValue = null;

          if (propertyInfo.hasOverloadedBooleanValue) {
            if (node.hasAttribute(attributeName)) {
              var value = node.getAttribute(attributeName);
              if (value === '') {
                return true;
              }
              if (shouldIgnoreValue(propertyInfo, expected)) {
                return value;
              }
              if (value === '' + expected) {
                return expected;
              }
              return value;
            }
          } else if (node.hasAttribute(attributeName)) {
            if (shouldIgnoreValue(propertyInfo, expected)) {
              // We had an attribute but shouldn't have had one, so read it
              // for the error message.
              return node.getAttribute(attributeName);
            }
            if (propertyInfo.hasBooleanValue) {
              // If this was a boolean, it doesn't matter what the value is
              // the fact that we have it is the same as the expected.
              return expected;
            }
            // Even if this property uses a namespace we use getAttribute
            // because we assume its namespaced name is the same as our config.
            // To use getAttributeNS we need the local name which we don't have
            // in our config atm.
            stringValue = node.getAttribute(attributeName);
          }

          if (shouldIgnoreValue(propertyInfo, expected)) {
            return stringValue === null ? expected : stringValue;
          } else if (stringValue === '' + expected) {
            return expected;
          } else {
            return stringValue;
          }
        }
      }
    }
  }
1191018
protected void addAnnotation(EObject element, XAnnotation annotation,
			IModificationContext context) throws Exception {
		final ICompositeNode node = NodeModelUtils.findActualNodeFor(annotation);
		if (node != null) {
			final IXtextDocument document = context.getXtextDocument();
			final int startOffset = node.getOffset();
			final int parameterOffset = getTools().getOffsetForPattern(document, startOffset,
					"@\\s*" + toPattern(annotation.getAnnotationType().getQualifiedName()) //$NON-NLS-1$
					+ "\\s*\\(\\s*"); //$NON-NLS-1$
			final int insertOffset;
			if (document.getChar(parameterOffset) == '{') {
				insertOffset = parameterOffset + getTools().getSpaceSize(document, parameterOffset + 1) + 1;
			} else {
				insertOffset = parameterOffset;
			}
			final ReplacingAppendable appendable = getTools().getAppendableFactory().create(document,
					(XtextResource) element.eResource(), insertOffset, 0);
			appendable.append("\""); //$NON-NLS-1$
			appendable.append(extractId(this.code));
			appendable.append("\", "); //$NON-NLS-1$
			appendable.commitChanges();
		}
	}