/*
Attach Groovydoc annotation to the target element
504845
private void attachGroovydocAnnotation(ASTNode node, String docCommentNodeText) {
        if (!runtimeGroovydocEnabled) {
            return;
        }

        if (!(node instanceof AnnotatedNode)) {
            return;
        }

        if (!docCommentNodeText.startsWith(RUNTIME_GROOVYDOC_PREFIX)) {
            return;
        }

        AnnotatedNode annotatedNode = (AnnotatedNode) node;
        AnnotationNode annotationNode = new AnnotationNode(ClassHelper.make(Groovydoc.class));
        annotationNode.addMember(VALUE, new ConstantExpression(docCommentNodeText));
        annotatedNode.addAnnotation(annotationNode);
    }
754478
def save_xml(self, doc, element):
        '''

        '''
        super(TargetExecutionContext, self).save_xml(doc, element)
        element.setAttributeNS(RTS_NS, RTS_NS_S + 'id', self.id)
503665
private static void applyAttribute(Annotated member, Schema property) {
        final XmlAttribute attribute = member.getAnnotation(XmlAttribute.class);
        if (attribute != null) {
            final XML xml = getXml(property);
            xml.setAttribute(true);
            setName(attribute.namespace(), attribute.name(), property);
        }
    }
981828
public static Object fetchAnnotationElementValue(Annotation annotation, Method element) throws ReflectiveOperationException {
		Object value = element.invoke(annotation);
		if (value == null) {
			String errorMsg = "@" + annotation.annotationType().getName() + "." +
					element.getName() + "() returned null";
			throw new NullPointerException(errorMsg);
		}
		return value;
	}
737450
function(markup, targetdoc) {
		var elm, doc = this._document ||
			(this._document = document.implementation.createHTMLDocument(""));
		return gui.Guide.suspend(function() {
			doc.body.innerHTML = this._unsanitize(markup);
			elm = doc.querySelector("." + this._classname) || doc.body;
			return Array.map(elm.childNodes, function(node) {
				return (targetdoc || document).importNode(node, true);
			});
		}, this);
	}
562264
private void mergeExtensionsIntoDocument(Node target, Node extensions) throws Exception {
        final XPathFactory factory = XPathFactory.newInstance();
        final NodeList nodes = (NodeList) factory.newXPath().evaluate("//extensions", extensions, XPathConstants.NODESET);
        for (int i = 0; i < nodes.getLength(); i++) {
            final Node extensionNode = nodes.item(i);
            String nameBasedXpath =  DomUtils.getNameBasedXPath(extensionNode, false);
            log.debug("Processing extension node: " + nameBasedXpath);

            final NodeList targetNodes = (NodeList) factory.newXPath().evaluate(nameBasedXpath, target, XPathConstants.NODESET);
            if (targetNodes.getLength() != 1) {
                throw new IllegalArgumentException("XPath "+nameBasedXpath+" not found in target");
            }
            Node targetNode = targetNodes.item(0);
            Node importedNode = targetNode.getOwnerDocument().importNode(extensionNode, true);
            targetNode.appendChild(importedNode);
        }
    }
660046
function injectDocumentWrite(targetWindow, doc) {
  var stackContainer = new Error();
  function processMarkup(markup) {
    if (markup.indexOf('<script ') == -1) {
      // Probably not a script tag. Ignore.
      return false;
    }

    // Try really hard to get base URLs.
    var baseUrl = arguments.callee.caller.caller ?
        arguments.callee.caller.caller['__src'] : null;
    if (!baseUrl) {
      var originalPrepare = Error.prepareStackTrace;
      Error.prepareStackTrace = function(e, callSites) {
        return callSites;
      };
      Error.captureStackTrace(stackContainer);
      var stack = stackContainer.stack;
      Error.prepareStackTrace = originalPrepare;
      baseUrl = stack[2].getFileName();
    }

    // We hackily do this by creating the DOM inside of a non-document-rooted
    // div and query all scripts. This lets us find multiple scripts/etc and
    // not have to worry about parsing HTML ourselves.
    var div = doc.createElement('div');
    div.innerHTML = markup;
    var scripts = div.querySelectorAll('script');
    if (!scripts || !scripts.length) {
      return false;
    }

    log('document.write* of scripts', scripts);

    // Process each script.
    // Since document.write* is synchronous, we must fetch and process inline.
    for (var n = 0; n < scripts.length; n++) {
      var script = scripts[n];
      var processedScript = processScript(script, true, baseUrl);
      // Eval in window context - with our sourceURL tag this lets the code
      // show in the dev tools correctly.
      eval.call(targetWindow, processedScript.text);
    }

    // TODO(benvanik): ensure we aren't eating other stuff that needs to go
    // into the DOM.
    return true;
  };

  var originalDocWrite = doc.write;
  doc.write = function write(markup) {
    if (processMarkup(markup)) {
      return;
    } else {
      return originalDocWrite.apply(this, arguments);
    }
  };
  doc.write['raw'] = originalDocWrite;

  var originalDocWriteLn = doc.writeln;
  doc.writeln = function writeln(line) {
    if (processMarkup(line)) {
      return;
    } else {
      return originalDocWriteLn.apply(this, arguments);
    }
  };
  doc.writeln['raw'] = originalDocWriteLn;
}
3598
protected void makeAnnotationTypeElementDoc(MethodSymbol meth, TreePath treePath) {
        AnnotationTypeElementDocImpl result =
            (AnnotationTypeElementDocImpl)methodMap.get(meth);
        if (result != null) {
            if (treePath != null) result.setTreePath(treePath);
        } else {
            result =
                new AnnotationTypeElementDocImpl(this, meth, treePath);
            methodMap.put(meth, result);
        }
    }
462519
private void bindAttribute(Annotation annotation)
    {
        String fieldname = ((AttributeOverride) annotation).name();
        Column column = ((AttributeOverride) annotation).column();
        ((AbstractManagedType) this.superClazzType).columnBindings.put(fieldname, column);
    }
694153
public void addAnnotationInfo(Element element, Content htmltree) {
        addAnnotationInfo(element, element.getAnnotationMirrors(), htmltree);
    }
768137
function insertAnno(anno, newHTML) {
    var annoID = 'SB-anno-' + anno.__id;
    var startTag = '<span id="' + annoID + '" class="sbAnnotation sbAnnotation-b">', endTag = '</span>';

    anno.offset = findInstanceOffset(anno, newHTML);
    return newHTML.substring(0, anno.offset) + startTag + anno.exact + endTag + newHTML.substring(anno.offset + anno.exact.length);
  }
463493
@Override
    public void attachScriptFile(IScriptable target, IScriptFile scriptFile) {
        mScriptMap.put(target, scriptFile);
        scriptFile.invokeFunction("onAttach", new Object[] { target });
    }
1008953
private <T extends Element> void mapAnnotations(final Map<TypeElement, List<T>> map,
            Element e, final T holder) {
        new SimpleElementVisitor9<Void, Void>() {

            void addAnnotations(Element e) {
                for (AnnotationMirror a : e.getAnnotationMirrors()) {
                    add(map, (TypeElement) a.getAnnotationType().asElement(), holder);
                }
            }

            @Override
            public Void visitPackage(PackageElement e, Void p) {
                for (AnnotationMirror a : e.getAnnotationMirrors()) {
                    refList(map, a.getAnnotationType().asElement()).add(holder);
                }
                return null;
            }

            @Override
            protected Void defaultAction(Element e, Void p) {
                addAnnotations(e);
                return null;
            }
        }.visit(e);
    }
142644
void attach(JCTree tree, Comment dc) {
        if (keepDocComments && dc != null) {
//          System.out.println("doc comment = ");System.out.println(dc);//DEBUG
            docComments.putComment(tree, dc);
        }
    }
1054039
@Override
    public void renderDoc(Doc doc) {
        // hide text that looks like tags (such as annotations in source code) from Javadoc
        doc.setRawCommentText(doc.getRawCommentText().replaceAll("@([A-Z])", "{@literal @}$1"));

        StringBuilder buffer = new StringBuilder();
        buffer.append(render(doc.commentText(), false));
        buffer.append('\n');
        for (Tag tag : doc.tags()) {
            renderTag(tag, buffer);
            buffer.append('\n');
        }
        doc.setRawCommentText(buffer.toString());
    }
290133
<A extends Annotation> A findAnnotation(TypeElement element, Class<A> anno) {

    final A annotation = element.getAnnotation(anno);
    if (annotation != null) {
      return annotation;
    }
    final TypeMirror typeMirror = element.getSuperclass();
    if (typeMirror.getKind() == TypeKind.NONE) {
      return null;
    }
    final TypeElement element1 = (TypeElement)typeUtils.asElement(typeMirror);
    return findAnnotation(element1, anno);
  }
933944
public void buildFieldDoc(XMLNode node, Content memberDetailsTree) {
        if (writer == null) {
            return;
        }
        int size = fields.size();
        if (size > 0) {
            Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(
                    classDoc, memberDetailsTree);
            for (currentFieldIndex = 0; currentFieldIndex < size;
                    currentFieldIndex++) {
                Content fieldDocTree = writer.getFieldDocTreeHeader(
                        (FieldDoc) fields.get(currentFieldIndex),
                        fieldDetailsTree);
                buildChildren(node, fieldDocTree);
                fieldDetailsTree.addContent(writer.getFieldDoc(
                        fieldDocTree, (currentFieldIndex == size - 1)));
            }
            memberDetailsTree.addContent(
                    writer.getFieldDetails(fieldDetailsTree));
        }
    }