public final void setLineno(int lineno) { int charno = getCharno(); if (charno == -1) { charno = 0; } sourcePosition = mergeLineCharNo(lineno, charno); }
public void setLineno(int lineno) { int charno = getCharno(); if (charno == -1) { charno = 0; } sourcePosition = mergeLineCharNo(lineno, charno); }
/** * Creates a JSError for a source file location. Private to avoid * any entanglement with code outside of the compiler. */ private JSError(String sourceName, @Nullable Node node, DiagnosticType type, String... arguments) { this(sourceName, node, (node != null) ? node.getLineno() : -1, (node != null) ? node.getCharno() : -1, type, null, arguments); }
/** * Creates a JSError for a source file location. Private to avoid * any entanglement with code outside of the compiler. */ private JSError(String sourceName, @Nullable Node node, DiagnosticType type, String... arguments) { this(sourceName, node, (node != null) ? node.getLineno() : -1, (node != null) ? node.getCharno() : -1, type, null, arguments); }
private Node wrapNode(int type, Node n) { return n == null ? null : new Node(type, n, n.getLineno(), n.getCharno()).clonePropsFrom(templateNode); }
public int getSourceOffset() { StaticSourceFile file = getStaticSourceFile(); if (file == null) { return -1; } int lineno = getLineno(); if (lineno == -1) { return -1; } return file.getLineOffset(lineno) + getCharno(); }
public int getSourceOffset() { StaticSourceFile file = getStaticSourceFile(); if (file == null) { return -1; } int lineno = getLineno(); if (lineno == -1) { return -1; } return file.getLineOffset(lineno) + getCharno(); }
private void visitImport(NodeTraversal t, Node importNode) { String specifier = importNode.getLastChild().getString(); Node duplicateImport = importSpecifiers.putIfAbsent(specifier, importNode); if (duplicateImport != null) { t.report( importNode, DUPLICATE_IMPORT, specifier, "" + duplicateImport.getLineno(), "" + duplicateImport.getCharno()); } }
private String formatNodePosition(Node n) { String sourceFileName = getBestSourceFileName(n); if (sourceFileName == null) { return MISSING_SOURCE + "\n"; } int lineNumber = n.getLineno(); int columnNumber = n.getCharno(); String src = compiler.getSourceLine(sourceFileName, lineNumber); if (src == null) { src = MISSING_SOURCE; } return sourceFileName + ":" + lineNumber + ":" + columnNumber + "\n" + src + "\n"; }
static String getIdForGeneratorNode(boolean consistent, Node n) { checkState(n.isString() || n.isStringKey(), n); if (consistent) { return n.getString(); } else { return n.getSourceFileName() + ':' + n.getLineno() + ":" + n.getCharno(); } } }
static String getIdForGeneratorNode(boolean consistent, Node n) { Preconditions.checkState(n.isString() || n.isStringKey(), n); if (consistent) { return n.getString(); } else { return n.getSourceFileName() + ':' + n.getLineno() + ":" + n.getCharno(); } } }
void setSourceInfo(Node node, Node ref) { node.setLineno(ref.getLineno()); node.setCharno(ref.getCharno()); setLengthFrom(node, ref); }
void setSourceInfo(Node node, Node ref) { node.setLineno(ref.getLineno()); node.setCharno(ref.getCharno()); maybeSetLengthFrom(node, ref); }
void maybeWarnForFeature(Node node, Feature feature) { features = features.with(feature); if (!isSupportedForInputLanguageMode(feature)) { errorReporter.warning( languageFeatureWarningMessage(feature), sourceName, node.getLineno(), node.getCharno()); } }
private void validateReturn(Node n) { if (n.isReturn()) { Node parent = n; while ((parent = parent.getParent()) != null) { if (parent.isFunction()) { return; } } errorReporter.error(UNEXPECTED_RETURN, sourceName, n.getLineno(), n.getCharno()); } }
private void maybeWarnKeywordProperty(Node node) { if (TokenStream.isKeyword(node.getString())) { features = features.require(Feature.KEYWORDS_AS_PROPERTIES); if (config.languageMode == LanguageMode.ECMASCRIPT3) { errorReporter.warning(INVALID_ES3_PROP_NAME, sourceName, node.getLineno(), node.getCharno()); } } }
private void validateReturn(Node n) { if (n.isReturn()) { Node parent = n; while ((parent = parent.getParent()) != null) { if (parent.isFunction()) { return; } } errorReporter.error(UNEXPECTED_RETURN, sourceName, n.getLineno(), n.getCharno()); } }
private void validateNewDotTarget(Node n) { if (n.getToken() == Token.NEW_TARGET) { Node parent = n; while ((parent = parent.getParent()) != null) { if (parent.isFunction()) { return; } } errorReporter.error(UNEXPECTED_NEW_DOT_TARGET, sourceName, n.getLineno(), n.getCharno()); } }
private void maybeWarnKeywordProperty(Node node) { if (TokenStream.isKeyword(node.getString())) { features = features.with(Feature.KEYWORDS_AS_PROPERTIES); if (config.languageMode() == LanguageMode.ECMASCRIPT3) { errorReporter.warning(INVALID_ES3_PROP_NAME, sourceName, node.getLineno(), node.getCharno()); } } }
private String getImportedModuleName(NodeTraversal t, Node n, String importPath) { ModulePath modulePath = t.getInput() .getPath() .resolveJsModule(importPath, n.getSourceFileName(), n.getLineno(), n.getCharno()); if (modulePath == null) { return ModuleIdentifier.forFile(importPath).getModuleName(); } return modulePath.toModuleName(); }