/** @return whether the {@code @code} is present within this {@link JSDocInfo}. */ public boolean isAtSignCodePresent() { final String entireComment = getOriginalCommentString(); return (entireComment == null) ? false : entireComment.contains("@code"); }
@VisibleForTesting public String toStringVerbose() { return MoreObjects.toStringHelper(this) .add("bitset", (bitset == 0) ? null : Integer.toHexString(bitset)) .add("documentation", documentation) .add("info", info) .add("originalComment", getOriginalCommentString()) .add("thisType", thisType) .add("type", type) .add("visibility", visibility) .omitNullValues() .toString(); }
@VisibleForTesting public String toStringVerbose() { return MoreObjects.toStringHelper(this) .add("bitset", (bitset == 0) ? null : Integer.toHexString(bitset)) .add("documentation", documentation) .add("info", info) .add("originalComment", getOriginalCommentString()) .add("thisType", thisType) .add("type", type) .add("visibility", visibility) .omitNullValues() .toString(); }
private List<String> getGoogRequiresFromPattern(Pattern pattern) { JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(beforeTemplate); if (jsDoc == null) { return ImmutableList.of(); } String jsDocContent = jsDoc.getOriginalCommentString(); if (jsDocContent == null) { return ImmutableList.of(); } ImmutableList.Builder<String> requires = ImmutableList.builder(); Matcher m = pattern.matcher(jsDocContent); while (m.find()) { requires.add(m.group(1)); } return requires.build(); } }
private void maybeSetInlineTypeExpression( Node nameNode, Node commentNode, JSDocInfo docInfo, boolean isReturnType) { if (docInfo == null) { return; } JSTypeExpression type = docInfo.getType(); if (type == null) { return; } setTypeExpression(nameNode, type, isReturnType); // Remove the part of comment that sets the inline type. String toRemove = docInfo.getOriginalCommentString(); String nodeComment = nodeComments.getComment(commentNode); if (nodeComment == null) { return; } nodeComment = nodeComment.replaceFirst("\\n?" + Pattern.quote(toRemove), ""); nodeComments.setComment(commentNode, nodeComment); compiler.reportChangeToEnclosingScope(commentNode); }
/** * Changes the JS Doc Type of the given node. */ public Builder changeJsDocType(Node n, AbstractCompiler compiler, String type) { JSDocInfo info = NodeUtil.getBestJSDocInfo(n); Preconditions.checkNotNull(info, "Node %s does not have JS Doc associated with it.", n); Node typeNode = JsDocInfoParser.parseTypeString(type); Preconditions.checkNotNull(typeNode, "Invalid type: %s", type); JSTypeExpression typeExpr = new JSTypeExpression(typeNode, "jsflume"); JSType newJsType = typeExpr.evaluate(null, compiler.getTypeRegistry()); if (newJsType == null) { throw new RuntimeException("JS Compiler does not recognize type: " + type); } String originalComment = info.getOriginalCommentString(); int originalPosition = info.getOriginalCommentPosition(); // TODO(mknichel): Support multiline @type annotations. Pattern typeDocPattern = Pattern.compile( "@(type|private|protected|public|const|return) *\\{?[^\\s}]+\\}?"); Matcher m = typeDocPattern.matcher(originalComment); while (m.find()) { replacements.put( n.getSourceFileName(), new CodeReplacement( originalPosition + m.start(), m.end() - m.start(), "@" + m.group(1) + " {" + type + "}")); } return this; }
private static SuggestedFix getFixForUnsortedRequiresOrProvides( String closureFunction, JSError error, AbstractCompiler compiler) { SuggestedFix.Builder fix = new SuggestedFix.Builder(); fix.setOriginalMatchedNode(error.node); Node script = NodeUtil.getEnclosingScript(error.node); RequireProvideSorter cb = new RequireProvideSorter(closureFunction); NodeTraversal.traverseEs6(compiler, script, cb); Node first = cb.calls.get(0); Node last = Iterables.getLast(cb.calls); cb.sortCallsAlphabetically(); StringBuilder sb = new StringBuilder(); for (Node n : cb.calls) { String statement = fix.generateCode(compiler, n); JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(n); if (jsDoc != null) { statement = jsDoc.getOriginalCommentString() + "\n" + statement; } sb.append(statement); } // Trim to remove the newline after the last goog.require/provide. String newContent = sb.toString().trim(); return fix.replaceRange(first, last, newContent).build(); }
String comment = getComment().getOriginalCommentString(); int c = comment.indexOf("IArrayLike"); int c1 = comment.indexOf('<', c);
String comment = getComment().getOriginalCommentString(); int c = comment.indexOf("IArrayLike"); int c1 = comment.indexOf('<', c);
String comment = getComment().getOriginalCommentString(); int c = comment.indexOf("IArrayLike"); int c1 = comment.indexOf('<', c);
&& Objects.equals(jsDoc1.getMeaning(), jsDoc2.getMeaning()) && Objects.equals(jsDoc1.getModifies(), jsDoc2.getModifies()) && Objects.equals(jsDoc1.getOriginalCommentString(), jsDoc2.getOriginalCommentString()) && (jsDoc1.getPropertyBitField() == jsDoc2.getPropertyBitField()) && Objects.equals(jsDoc1.getReferences(), jsDoc2.getReferences())
&& Objects.equals(jsDoc1.getMeaning(), jsDoc2.getMeaning()) && Objects.equals(jsDoc1.getModifies(), jsDoc2.getModifies()) && Objects.equals(jsDoc1.getOriginalCommentString(), jsDoc2.getOriginalCommentString()) && Objects.equals(jsDoc1.getPropertyBitField(), jsDoc2.getPropertyBitField()) && Objects.equals(jsDoc1.getReferences(), jsDoc2.getReferences())