Stringify a reference label. Because link references are easily, mistakingly, created (for example, `[foo]`), reference nodes have an extra property depicting how it looked in the original document, so stringification can cause minimal changes.
166530
function label(node) {
  var type = node.referenceType

  if (type === shortcut) {
    return ''
  }

  return (
    leftSquareBracket +
    (type === collapsed ? '' : node.label || node.identifier) +
    rightSquareBracket
  )
}
857635
function HyperlinkView() {
        NodeView.apply(this, arguments);

        /** @member {LabelView} */
        this.nameLabel = new LabelView();
        this.nameLabel.parentStyle = true;
        this.addSubView(this.nameLabel);

        /** @member {LabelView} */
        this.typeLabel = new LabelView();
        this.typeLabel.parentStyle = true;
        this.addSubView(this.typeLabel);
    }
523097
def _reference_keys(self, reference):
        
        if not isinstance(reference, six.string_types):
            raise TypeError(
                'When using ~ to reference dynamic attributes ref must be a str. a {0} was provided.'.format(type(reference).__name__)
            )

        if '~' in reference:
            reference = reference[1:]

            scheme = self._scheme_references.get(reference)
            if not scheme:
                # TODO: need to create nice error here as well and print pretty message.
                raise LookupError(
                    "Was unable to find {0} in the scheme references. "
                    "available references {1}".format(reference, ', '.join(self._scheme_references.keys()))
                )

            return scheme['keys']
        else:
            raise AttributeError('references must start with ~. Please update {0} and retry.'.format(reference))
1074454
private void addValueInRefsTable(XPathContext xctxt, XMLString ref, int node) {
    
    XNodeSet nodes = (XNodeSet) m_refsTable.get(ref);
    if (nodes == null)
    {
      nodes = new XNodeSet(node, xctxt.getDTMManager());
      nodes.nextNode();
      m_refsTable.put(ref, nodes);
    }
    else
    {
      // Nodes are passed to this method in document order.  Since we need to
      // suppress duplicates, we only need to check against the last entry
      // in each nodeset.  We use nodes.nextNode after each entry so we can
      // easily compare node against the current node.
      if (nodes.getCurrentNode() != node) {
          nodes.mutableNodeset().addNode(node);
          nodes.nextNode();
      }    
    }
  }
110618
def process_refs_for_node(cls, manifest, current_project, node):
        """"""
        target_model = None
        target_model_name = None
        target_model_package = None

        for ref in node.refs:
            if len(ref) == 1:
                target_model_name = ref[0]
            elif len(ref) == 2:
                target_model_package, target_model_name = ref

            target_model = cls.resolve_ref(
                manifest,
                target_model_name,
                target_model_package,
                current_project,
                node.get('package_name'))

            if target_model is None or target_model is cls.DISABLED:
                # This may raise. Even if it doesn't, we don't want to add
                # this node to the graph b/c there is no destination node
                node.config['enabled'] = False
                dbt.utils.invalid_ref_fail_unless_test(
                    node, target_model_name, target_model_package,
                    disabled=(target_model is cls.DISABLED)
                )

                continue

            target_model_id = target_model.get('unique_id')

            node.depends_on['nodes'].append(target_model_id)
            manifest.nodes[node['unique_id']] = node
440583
function attr(loc, reference, attrName, value) {
  if (plainAttributes.indexOf(attrName) != -1) {
    return sourceNode(loc, [reference, '.', attrName, ' = ', value, ';']);
  } else {
    return sourceNode(loc, [reference, '.setAttribute(', esc(attrName), ', ', value, ');']);
  }
}
336503
def __addNode(self, name, cls):
        '''
        
        '''
        if name in self.nodes:
            raise Exception("A node by the name {} already exists.  Can't add a duplicate.".format(name))
        self.__nxgraph.add_node(name)
        self.__nxgraph.node[name]['label'] = name
        self.__nxgraph.node[name]['nodeobj'] = cls()
        self.__nxgraph.node[name]['type'] = cls.__name__
1051872
function(markup) {

        if (!markup) return undefined;

        var fragment = markup.fragment;
        if (!(markup.fragment instanceof DocumentFragment) || !markup.fragment.hasChildNodes()) throw new Error('dia.LinkView: invalid label markup.');

        var vNode;
        var childNodes = fragment.childNodes;

        if ((childNodes.length > 1) || childNodes[0].nodeName.toUpperCase() !== 'G') {
            // default markup fragment is not wrapped in <g />
            // add a <g /> container
            vNode = V('g').append(fragment);
        } else {
            vNode = V(childNodes[0]);
        }

        vNode.addClass('label');

        return { node: vNode.node, selectors: markup.selectors };
    }
1292389
protected function parseReferenceLinks()
	{
		$labels = $this->getLabels();
		foreach ($labels as $startPos => $id)
		{
			$labelPos = $startPos + 2 + strlen($id);
			$endPos   = $labelPos - 1;
			$endLen   = 1;

			if ($this->text->charAt($labelPos) === ' ')
			{
				++$labelPos;
			}
			if (isset($labels[$labelPos], $this->text->linkReferences[$labels[$labelPos]]))
			{
				$id     = $labels[$labelPos];
				$endLen = $labelPos + 2 + strlen($id) - $endPos;
			}
			if (isset($this->text->linkReferences[$id]))
			{
				$this->addLinkTag($startPos, $endPos, $endLen, $this->text->linkReferences[$id]);
			}
		}
	}
1145961
private List<String> parseReference(String reference) {
		List<String> references = new ArrayList<String>();
		Matcher matcher = REFERENCE_PATTERN.matcher(reference);
		while (matcher.find()) {
			references.add(matcher.group(1));
		}
		return references;
	}
1278765
function _assignRef(element) {
  var refString = element.getAttribute('ref');

  // assign element to refs object
  this.refs[ refString ] = element;

  // memoize ref string, clean ref attribute
  element.__refString__ = refString;
  element.removeAttribute('ref');
}
664806
public void write_ref(final String node, final int id, final int creation) {
	/* Always encode as an extended reference; all
	   participating parties are now expected to be
	   able to decode extended references. */
	int ids[] = new int[1];
	ids[0] = id;
	write_ref(node, ids, creation);
    }
237576
public static InsnList addLabel(LabelNode labelNode) {
        Validate.notNull(labelNode);

        InsnList ret = new InsnList();
        ret.add(labelNode);

        return ret;
    }
148356
function(s, refmap) {
  this.subject = s;
  this.pos = 0;
  var rawlabel;
  var dest;
  var title;
  var matchChars;
  var startpos = this.pos;
  var match;

  // label:
  matchChars = this.parseLinkLabel();
  if (matchChars === 0) {
    return 0;
  } else {
    rawlabel = this.subject.substr(0, matchChars);
  }

  // colon:
  if (this.peek() === ':') {
    this.pos++;
  } else {
    this.pos = startpos;
    return 0;
  }

  //  link url
  this.spnl();

  dest = this.parseLinkDestination();
  if (dest === null || dest.length === 0) {
    this.pos = startpos;
    return 0;
  }

  var beforetitle = this.pos;
  this.spnl();
  title = this.parseLinkTitle();
  if (title === null) {
    title = '';
    // rewind before spaces
    this.pos = beforetitle;
  }

  // make sure we're at line end:
  if (this.match(/^ *(?:\n|$)/) === null) {
    this.pos = startpos;
    return 0;
  }

  var normlabel = normalizeReference(rawlabel);

  if (!refmap[normlabel]) {
    refmap[normlabel] = { destination: dest, title: title };
  }
  return this.pos - startpos;
}
667553
def apply_link_ref(offset: int, length: int, value: bytes, bytecode: bytes) -> bytes:
    
    try:
        validate_empty_bytes(offset, length, bytecode)
    except ValidationError:
        raise BytecodeLinkingError("Link references cannot be applied to bytecode")

    new_bytes = (
        # Ignore linting error b/c conflict b/w black & flake8
        bytecode[:offset]
        + value
        + bytecode[offset + length :]  # noqa: E201, E203
    )
    return new_bytes
91264
function markAsUsed(node) {
            if (!node.label) {
                return;
            }

            const label = node.label.name;
            let info = scopeInfo;

            while (info) {
                if (info.label === label) {
                    info.used = true;
                    break;
                }
                info = info.upper;
            }
        }
1291811
function references(node, scope, state) {
  var declared = state.letRefs[node.name];
  if (!declared) return false;

  // declared node is different in this scope
  return scope.getBindingIdentifier(node.name) === declared;
}