id
stringlengths
5
19
content
stringlengths
94
57.5k
max_stars_repo_path
stringlengths
36
95
Chart-1
public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.plot == null) { return result; } int index = this.plot.getIndexOf(this); CategoryDataset dataset = this.plot.getDataset(index); if (dataset !=...
source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java
Chart-10
public String generateToolTipFragment(String toolTipText) { return " title=\"" + toolTipText + "\" alt=\"\""; } public String generateToolTipFragment(String toolTipText) { return " title=\"" + ImageMapUtilities.htmlEscape(toolTipText) + "\" alt=\"\""; }
source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.java
Chart-11
public static boolean equal(GeneralPath p1, GeneralPath p2) { if (p1 == null) { return (p2 == null); } if (p2 == null) { return false; } if (p1.getWindingRule() != p2.getWindingRule()) { return false; } PathIterator iterator...
source/org/jfree/chart/util/ShapeUtilities.java
Chart-12
public MultiplePiePlot(CategoryDataset dataset) { super(); this.dataset = dataset; PiePlot piePlot = new PiePlot(null); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgr...
source/org/jfree/chart/plot/MultiplePiePlot.java
Chart-13
protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, RectangleConstraint constraint) { double[] w = new double[5]; double[] h = new double[5]; w[0] = constraint.getWidth(); if (this.topBlock != null) { RectangleConstraint c1 =...
source/org/jfree/chart/block/BorderArrangement.java
Chart-17
public Object clone() throws CloneNotSupportedException { Object clone = createCopy(0, getItemCount() - 1); return clone; } public Object clone() throws CloneNotSupportedException { TimeSeries clone = (TimeSeries) super.clone(); clone.data = (List) ObjectUtilities.deepClone(...
source/org/jfree/data/time/TimeSeries.java
Chart-20
public ValueMarker(double value, Paint paint, Stroke stroke, Paint outlinePaint, Stroke outlineStroke, float alpha) { super(paint, stroke, paint, stroke, alpha); this.value = value; } public ValueMarker(double value, Paint paint, Stroke stroke, ...
source/org/jfree/chart/plot/ValueMarker.java
Chart-24
public Paint getPaint(double value) { double v = Math.max(value, this.lowerBound); v = Math.min(v, this.upperBound); int g = (int) ((value - this.lowerBound) / (this.upperBound - this.lowerBound) * 255.0); return new Color(g, g, g); } public Paint getPaint(d...
source/org/jfree/chart/renderer/GrayPaintScale.java
Chart-26
protected AxisState drawLabel(String label, Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState) { // it is unlikely that 'state' will be null, but check anyway... if (state == null) { thro...
source/org/jfree/chart/axis/Axis.java
Chart-3
public TimeSeries createCopy(int start, int end) throws CloneNotSupportedException { if (start < 0) { throw new IllegalArgumentException("Requires start >= 0."); } if (end < start) { throw new IllegalArgumentException("Requires start <= end."); } ...
source/org/jfree/data/time/TimeSeries.java
Chart-4
public Range getDataRange(ValueAxis axis) { Range result = null; List mappedDatasets = new ArrayList(); List includedAnnotations = new ArrayList(); boolean isDomainAxis = true; // is it a domain axis? int domainIndex = getDomainAxisIndex(axis); if (domainInd...
source/org/jfree/chart/plot/XYPlot.java
Chart-5
public XYDataItem addOrUpdate(Number x, Number y) { if (x == null) { throw new IllegalArgumentException("Null 'x' argument."); } // if we get to here, we know that duplicate X values are not permitted XYDataItem overwritten = null; int index = indexOf(x); ...
source/org/jfree/data/xy/XYSeries.java
Chart-6
public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof ShapeList)) { return false; } return super.equals(obj); } public boolean equals(Object obj) { if (obj == this) { return true; ...
source/org/jfree/chart/util/ShapeList.java
Chart-7
private void updateBounds(TimePeriod period, int index) { long start = period.getStart().getTime(); long end = period.getEnd().getTime(); long middle = start + ((end - start) / 2); if (this.minStartIndex >= 0) { long minStart = getDataItem(this.minStartIndex).ge...
source/org/jfree/data/time/TimePeriodValues.java
Chart-8
public Week(Date time, TimeZone zone) { // defer argument checking... this(time, RegularTimePeriod.DEFAULT_TIME_ZONE, Locale.getDefault()); } public Week(Date time, TimeZone zone) { // defer argument checking... this(time, zone, Locale.getDefault()); }
source/org/jfree/data/time/Week.java
Chart-9
public TimeSeries createCopy(RegularTimePeriod start, RegularTimePeriod end) throws CloneNotSupportedException { if (start == null) { throw new IllegalArgumentException("Null 'start' argument."); } if (end == null) { throw new IllegalArgumentException("Null '...
source/org/jfree/data/time/TimeSeries.java
Cli-11
private static void appendOption(final StringBuffer buff, final Option option, final boolean required) { if (!required) { buff.append("["); } if (option.getOpt() != null) { ...
src/java/org/apache/commons/cli/HelpFormatter.java
Cli-12
protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption) { List tokens = new ArrayList(); boolean eatTheRest = false; for (int i = 0; i < arguments.length; i++) { String arg = arguments[i]; if ("--".equals(arg)) ...
src/java/org/apache/commons/cli/GnuParser.java
Cli-14
public void validate(final WriteableCommandLine commandLine) throws OptionException { // number of options found int present = 0; // reference to first unexpected option Option unexpected = null; for (final Iterator i = options.iterator(); i.hasNext();) { ...
src/java/org/apache/commons/cli2/option/GroupImpl.java
Cli-15
public List getValues(final Option option, List defaultValues) { // initialize the return list List valueList = (List) values.get(option); // grab the correct default values if ((valueList == null) || valueList.isEmpty()) { valueList = defaultVa...
src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java
Cli-17
protected void burstToken(String token, boolean stopAtNonOption) { for (int i = 1; i < token.length(); i++) { String ch = String.valueOf(token.charAt(i)); if (options.hasOption(ch)) { tokens.add("-" + ch); currentOption = optio...
src/java/org/apache/commons/cli/PosixParser.java
Cli-19
private void processOptionToken(String token, boolean stopAtNonOption) { if (options.hasOption(token)) { currentOption = options.getOption(token); tokens.add(token); } else if (stopAtNonOption) { eatTheRest = true; tokens.ad...
src/java/org/apache/commons/cli/PosixParser.java
Cli-20
protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption) { init(); this.options = options; // an iterator for the command line tokens Iterator iter = Arrays.asList(arguments).iterator(); // process each command line token while (i...
src/java/org/apache/commons/cli/PosixParser.java
Cli-23
protected StringBuffer renderWrappedText(StringBuffer sb, int width, int nextLineTabStop, String text) { int pos = findWrapPos(text, width, 0); if (pos == -1) { sb.append(rtrim(text)); return sb; } sb...
src/java/org/apache/commons/cli/HelpFormatter.java
Cli-24
protected StringBuffer renderWrappedText(StringBuffer sb, int width, int nextLineTabStop, String text) { int pos = findWrapPos(text, width, 0); if (pos == -1) { sb.append(rtrim(text)); return sb; } sb...
src/java/org/apache/commons/cli/HelpFormatter.java
Cli-25
protected StringBuffer renderWrappedText(StringBuffer sb, int width, int nextLineTabStop, String text) { int pos = findWrapPos(text, width, 0); if (pos == -1) { sb.append(rtrim(text)); return sb; } sb...
src/java/org/apache/commons/cli/HelpFormatter.java
Cli-26
public static Option create(String opt) throws IllegalArgumentException { // create the option Option option = new Option(opt, description); // set the option properties option.setLongOpt(longopt); option.setRequired(required); option.setOptio...
src/java/org/apache/commons/cli/OptionBuilder.java
Cli-27
public void setSelected(Option option) throws AlreadySelectedException { if (option == null) { // reset the option previously selected selected = null; return; } // if no option has already been selected or the // same option ...
src/java/org/apache/commons/cli/OptionGroup.java
Cli-28
protected void processProperties(Properties properties) { if (properties == null) { return; } for (Enumeration e = properties.propertyNames(); e.hasMoreElements();) { String option = e.nextElement().toString(); if (!cmd.hasOption(opti...
src/java/org/apache/commons/cli/Parser.java
Cli-29
static String stripLeadingAndTrailingQuotes(String str) { if (str.startsWith("\"")) { str = str.substring(1, str.length()); } int length = str.length(); if (str.endsWith("\"")) { str = str.substring(0, length - 1); } ...
src/java/org/apache/commons/cli/Util.java
Cli-32
protected int findWrapPos(String text, int width, int startPos) { int pos; // the line ends before the max wrap pos or a new line char found if (((pos = text.indexOf('\n', startPos)) != -1 && pos <= width) || ((pos = text.indexOf('\t', startPos)) != -1 && pos <= ...
src/main/java/org/apache/commons/cli/HelpFormatter.java
Cli-35
public List<String> getMatchingOptions(String opt) { opt = Util.stripLeadingHyphens(opt); List<String> matchingOpts = new ArrayList<String>(); // for a perfect match return the single option only for (String longOpt : longOpts.keySet()) { if (longOp...
src/main/java/org/apache/commons/cli/Options.java
Cli-37
private boolean isShortOption(String token) { // short options (-S, -SV, -S=V, -SV1=V2, -S1S2) return token.startsWith("-") && token.length() >= 2 && options.hasShortOption(token.substring(1, 2)); // remove leading "-" and "=value" } private boolean isShortOption(String token) ...
src/main/java/org/apache/commons/cli/DefaultParser.java
Cli-38
private boolean isShortOption(String token) { // short options (-S, -SV, -S=V, -SV1=V2, -S1S2) if (!token.startsWith("-") || token.length() == 1) { return false; } // remove leading "-" and "=value" int pos = token.indexOf("="); String optName...
src/main/java/org/apache/commons/cli/DefaultParser.java
Cli-4
private void checkRequiredOptions() throws MissingOptionException { // if there are required options that have not been // processsed if (requiredOptions.size() > 0) { Iterator iter = requiredOptions.iterator(); StringBuffer buff = new StringBuffer...
src/java/org/apache/commons/cli/Parser.java
Cli-40
public static <T> T createValue(final String str, final Class<T> clazz) throws ParseException { if (PatternOptionBuilder.STRING_VALUE == clazz) { return (T) str; } else if (PatternOptionBuilder.OBJECT_VALUE == clazz) { return (T) createObject(str);...
src/main/java/org/apache/commons/cli/TypeHandler.java
Cli-5
static String stripLeadingHyphens(String str) { if (str.startsWith("--")) { return str.substring(2, str.length()); } else if (str.startsWith("-")) { return str.substring(1, str.length()); } return str; } static String stri...
src/java/org/apache/commons/cli/Util.java
Cli-8
protected StringBuffer renderWrappedText(StringBuffer sb, int width, int nextLineTabStop, String text) { int pos = findWrapPos(text, width, 0); if (pos == -1) { sb.append(rtrim(text)); return sb; } sb...
src/java/org/apache/commons/cli/HelpFormatter.java
Cli-9
protected void checkRequiredOptions() throws MissingOptionException { // if there are required options that have not been // processsed if (getRequiredOptions().size() > 0) { Iterator iter = getRequiredOptions().iterator(); StringBuffer buff = new ...
src/java/org/apache/commons/cli/Parser.java
Closure-1
private void removeUnreferencedFunctionArgs(Scope fnScope) { // Notice that removing unreferenced function args breaks // Function.prototype.length. In advanced mode, we don't really care // about this: we consider "length" the equivalent of reflecting on // the function's lexical source. // /...
src/com/google/javascript/jscomp/RemoveUnusedVars.java
Closure-10
static boolean mayBeString(Node n, boolean recurse) { if (recurse) { return allResultsMatch(n, MAY_BE_STRING_PREDICATE); } else { return mayBeStringHelper(n); } } static boolean mayBeString(Node n, boolean recurse) { if (recurse) { return anyResultsMatch(n, MAY_BE_STRING_PREDICA...
src/com/google/javascript/jscomp/NodeUtil.java
Closure-101
protected CompilerOptions createOptions() { CompilerOptions options = new CompilerOptions(); options.setCodingConvention(new ClosureCodingConvention()); CompilationLevel level = flags.compilation_level; level.setOptionsForCompilationLevel(options); if (flags.debug) { level.setDebugOptionsFor...
src/com/google/javascript/jscomp/CommandLineRunner.java
Closure-102
public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, this); if (MAKE_LOCAL_NAMES_UNIQUE) { MakeDeclaredNamesUnique renamer = new MakeDeclaredNamesUnique(); NodeTraversal t = new NodeTraversal(compiler, renamer); t.traverseRoots(externs, root); } remov...
src/com/google/javascript/jscomp/Normalize.java
Closure-104
JSType meet(JSType that) { UnionTypeBuilder builder = new UnionTypeBuilder(registry); for (JSType alternate : alternates) { if (alternate.isSubtype(that)) { builder.addAlternate(alternate); } } if (that instanceof UnionType) { for (JSType otherAlternate : ((UnionType) that)....
src/com/google/javascript/rhino/jstype/UnionType.java
Closure-105
void tryFoldStringJoin(NodeTraversal t, Node n, Node left, Node right, Node parent) { if (!NodeUtil.isGetProp(left) || !NodeUtil.isImmutableValue(right)) { return; } Node arrayNode = left.getFirstChild(); Node functionName = arrayNode.getNext(); if ((arrayNode.getT...
src/com/google/javascript/jscomp/FoldConstants.java
Closure-107
protected CompilerOptions createOptions() { CompilerOptions options = new CompilerOptions(); if (flags.processJqueryPrimitives) { options.setCodingConvention(new JqueryCodingConvention()); } else { options.setCodingConvention(new ClosureCodingConvention()); } options.setExtraAnnotatio...
src/com/google/javascript/jscomp/CommandLineRunner.java
Closure-109
private Node parseContextTypeExpression(JsDocToken token) { return parseTypeName(token); } private Node parseContextTypeExpression(JsDocToken token) { if (token == JsDocToken.QMARK) { return newNode(Token.QMARK); } else { return parseBasicTypeExpression(token); } }
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
Closure-11
private void visitGetProp(NodeTraversal t, Node n, Node parent) { // obj.prop or obj.method() // Lots of types can appear on the left, a call to a void function can // never be on the left. getPropertyType will decide what is acceptable // and what isn't. Node property = n.getLastChild(); Node...
src/com/google/javascript/jscomp/TypeCheck.java
Closure-111
protected JSType caseTopType(JSType topType) { return topType; } protected JSType caseTopType(JSType topType) { return topType.isAllType() ? getNativeType(ARRAY_TYPE) : topType; }
src/com/google/javascript/jscomp/type/ClosureReverseAbstractInterpreter.java
Closure-112
private boolean inferTemplatedTypesForCall( Node n, FunctionType fnType) { final ImmutableList<TemplateType> keys = fnType.getTemplateTypeMap() .getTemplateKeys(); if (keys.isEmpty()) { return false; } // Try to infer the template types Map<TemplateType, JSType> inferred = ...
src/com/google/javascript/jscomp/TypeInference.java
Closure-113
private void processRequireCall(NodeTraversal t, Node n, Node parent) { Node left = n.getFirstChild(); Node arg = left.getNext(); if (verifyLastArgumentIsString(t, left, arg)) { String ns = arg.getString(); ProvidedName provided = providedNames.get(ns); if (provided == null || !provided....
src/com/google/javascript/jscomp/ProcessClosurePrimitives.java
Closure-114
private void recordAssignment(NodeTraversal t, Node n, Node recordNode) { Node nameNode = n.getFirstChild(); Node parent = n.getParent(); NameInformation ns = createNameInformation(t, nameNode); if (ns != null) { if (parent.isFor() && !NodeUtil.isForIn(parent)) { // Patch f...
src/com/google/javascript/jscomp/NameAnalyzer.java
Closure-115
private CanInlineResult canInlineReferenceDirectly( Node callNode, Node fnNode) { if (!isDirectCallNodeReplacementPossible(fnNode)) { return CanInlineResult.NO; } Node block = fnNode.getLastChild(); boolean hasSideEffects = false; if (block.hasChildren()) { Preconditions.checkS...
src/com/google/javascript/jscomp/FunctionInjector.java
Closure-116
private CanInlineResult canInlineReferenceDirectly( Node callNode, Node fnNode) { if (!isDirectCallNodeReplacementPossible(fnNode)) { return CanInlineResult.NO; } Node block = fnNode.getLastChild(); // CALL NODE: [ NAME, ARG1, ARG2, ... ] Node cArg = callNode.getFirstChild().getNext...
src/com/google/javascript/jscomp/FunctionInjector.java
Closure-117
String getReadableJSTypeName(Node n, boolean dereference) { // The best type name is the actual type name. // If we're analyzing a GETPROP, the property may be inherited by the // prototype chain. So climb the prototype chain and find out where // the property was originally defined. if (n.isGet...
src/com/google/javascript/jscomp/TypeValidator.java
Closure-118
private void handleObjectLit(NodeTraversal t, Node n) { for (Node child = n.getFirstChild(); child != null; child = child.getNext()) { // Maybe STRING, GET, SET // We should never see a mix of numbers and strings. String name = child.getString(); T type = t...
src/com/google/javascript/jscomp/DisambiguateProperties.java
Closure-119
public void collect(JSModule module, Scope scope, Node n) { Node parent = n.getParent(); String name; boolean isSet = false; Name.Type type = Name.Type.OTHER; boolean isPropAssign = false; switch (n.getType()) { case Token.GETTER_DEF: case Token.SETTER_DEF: ...
src/com/google/javascript/jscomp/GlobalNamespace.java
Closure-12
private boolean hasExceptionHandler(Node cfgNode) { return false; } private boolean hasExceptionHandler(Node cfgNode) { List<DiGraphEdge<Node, Branch>> branchEdges = getCfg().getOutEdges(cfgNode); for (DiGraphEdge<Node, Branch> edge : branchEdges) { if (edge.getValue() == Branch.ON_EX) { ...
src/com/google/javascript/jscomp/MaybeReachingVariableUse.java
Closure-120
boolean isAssignedOnceInLifetime() { Reference ref = getOneAndOnlyAssignment(); if (ref == null) { return false; } // Make sure this assignment is not in a loop. for (BasicBlock block = ref.getBasicBlock(); block != null; block = block.getParent()) { if (blo...
src/com/google/javascript/jscomp/ReferenceCollectingCallback.java
Closure-121
private void inlineNonConstants( Var v, ReferenceCollection referenceInfo, boolean maybeModifiedArguments) { int refCount = referenceInfo.references.size(); Reference declaration = referenceInfo.references.get(0); Reference init = referenceInfo.getInitializingReference(); int...
src/com/google/javascript/jscomp/InlineVariables.java
Closure-122
private void handleBlockComment(Comment comment) { if (comment.getValue().indexOf("/* @") != -1 || comment.getValue().indexOf("\n * @") != -1) { errorReporter.warning( SUSPICIOUS_COMMENT_WARNING, sourceName, comment.getLineno(), "", 0); } } private void handleBlockComm...
src/com/google/javascript/jscomp/parsing/IRFactory.java
Closure-123
void add(Node n, Context context) { if (!cc.continueProcessing()) { return; } int type = n.getType(); String opstr = NodeUtil.opToStr(type); int childCount = n.getChildCount(); Node first = n.getFirstChild(); Node last = n.getLastChild(); // Handle all binary operators if (...
src/com/google/javascript/jscomp/CodeGenerator.java
Closure-124
private boolean isSafeReplacement(Node node, Node replacement) { // No checks are needed for simple names. if (node.isName()) { return true; } Preconditions.checkArgument(node.isGetProp()); node = node.getFirstChild(); if (node.isName() && isNameAssignedTo(node.getString(), re...
src/com/google/javascript/jscomp/ExploitAssigns.java
Closure-125
private void visitNew(NodeTraversal t, Node n) { Node constructor = n.getFirstChild(); JSType type = getJSType(constructor).restrictByNotNullOrUndefined(); if (type.isConstructor() || type.isEmptyType() || type.isUnknownType()) { FunctionType fnType = type.toMaybeFunctionType(); if (fnType != ...
src/com/google/javascript/jscomp/TypeCheck.java
Closure-126
void tryMinimizeExits(Node n, int exitType, String labelName) { // Just an 'exit'. if (matchingExitNode(n, exitType, labelName)) { NodeUtil.removeChild(n.getParent(), n); compiler.reportCodeChange(); return; } // Just an 'if'. if (n.isIf()) { Node ifBlock = n.getFirstChil...
src/com/google/javascript/jscomp/MinimizeExitPoints.java
Closure-128
static boolean isSimpleNumber(String s) { int len = s.length(); for (int index = 0; index < len; index++) { char c = s.charAt(index); if (c < '0' || c > '9') { return false; } } return len > 0 && s.charAt(0) != '0'; } static boolean isSimpleNumber(String s) { int len...
src/com/google/javascript/jscomp/CodeGenerator.java
Closure-129
private void annotateCalls(Node n) { Preconditions.checkState(n.isCall()); // Keep track of of the "this" context of a call. A call without an // explicit "this" is a free call. Node first = n.getFirstChild(); // ignore cast nodes. if (!NodeUtil.isGet(first)) { n.putB...
src/com/google/javascript/jscomp/PrepareAst.java
Closure-13
private void traverse(Node node) { // The goal here is to avoid retraversing // the entire AST to catch newly created opportunities. // So we track whether a "unit of code" has changed, // and revisit immediately. if (!shouldVisit(node)) { return; } int visits = 0; do { No...
src/com/google/javascript/jscomp/PeepholeOptimizationsPass.java
Closure-130
private void inlineAliases(GlobalNamespace namespace) { // Invariant: All the names in the worklist meet condition (a). Deque<Name> workList = new ArrayDeque<Name>(namespace.getNameForest()); while (!workList.isEmpty()) { Name name = workList.pop(); // Don't attempt to inline a getter or sett...
src/com/google/javascript/jscomp/CollapseProperties.java
Closure-131
public static boolean isJSIdentifier(String s) { int length = s.length(); if (length == 0 || !Character.isJavaIdentifierStart(s.charAt(0))) { return false; } for (int i = 1; i < length; i++) { if ( !Character.isJavaIdentifierPart(s.charAt(i))) { ...
src/com/google/javascript/rhino/TokenStream.java
Closure-132
private Node tryMinimizeIf(Node n) { Node parent = n.getParent(); Node cond = n.getFirstChild(); /* If the condition is a literal, we'll let other * optimizations try to remove useless code. */ if (NodeUtil.isLiteralValue(cond, true)) { return n; } Node thenBranch = cond.ge...
src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java
Closure-133
private String getRemainingJSDocLine() { String result = stream.getRemainingJSDocLine(); return result; } private String getRemainingJSDocLine() { String result = stream.getRemainingJSDocLine(); unreadToken = NO_UNREAD_TOKEN; return result; }
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
Closure-14
private static Node computeFollowNode( Node fromNode, Node node, ControlFlowAnalysis cfa) { /* * This is the case where: * * 1. Parent is null implies that we are transferring control to the end of * the script. * * 2. Parent is a function implies that we are transferring contr...
src/com/google/javascript/jscomp/ControlFlowAnalysis.java
Closure-145
private boolean isOneExactlyFunctionOrDo(Node n) { // For labels with block children, we need to ensure that a // labeled FUNCTION or DO isn't generated when extraneous BLOCKs // are skipped. // Either a empty statement or an block with more than one child, // way it isn'...
src/com/google/javascript/jscomp/CodeGenerator.java
Closure-146
public TypePair getTypesUnderInequality(JSType that) { // unions types if (that instanceof UnionType) { TypePair p = that.getTypesUnderInequality(this); return new TypePair(p.typeB, p.typeA); } // other types switch (this.testForEquality(that)) { case TRUE: return new Ty...
src/com/google/javascript/rhino/jstype/JSType.java
Closure-15
public boolean apply(Node n) { // When the node is null it means, we reached the implicit return // where the function returns (possibly without an return statement) if (n == null) { return false; } // TODO(user): We only care about calls to functions that ...
src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java
Closure-150
@Override public void visit(NodeTraversal t, Node n, Node parent) { if (n == scope.getRootNode()) return; if (n.getType() == Token.LP && parent == scope.getRootNode()) { handleFunctionInputs(parent); return; } attachLiteralTypes(n); switch (n.getType()) { case...
src/com/google/javascript/jscomp/TypedScopeCreator.java
Closure-152
JSType resolveInternal(ErrorReporter t, StaticScope<JSType> scope) { setResolvedTypeInternal(this); call = (ArrowType) safeResolve(call, t, scope); prototype = (FunctionPrototypeType) safeResolve(prototype, t, scope); // Warning about typeOfThis if it doesn't resolve to an ObjectType // is handl...
src/com/google/javascript/rhino/jstype/FunctionType.java
Closure-159
private void findCalledFunctions( Node node, Set<String> changed) { Preconditions.checkArgument(changed != null); // For each referenced function, add a new reference if (node.getType() == Token.CALL) { Node child = node.getFirstChild(); if (child.getType() == Token.NAME) { chang...
src/com/google/javascript/jscomp/InlineFunctions.java
Closure-160
public void initOptions(CompilerOptions options) { this.options = options; if (errorManager == null) { if (outStream == null) { setErrorManager( new LoggerErrorManager(createMessageFormatter(), logger)); } else { PrintStreamErrorManager printer = new PrintSt...
src/com/google/javascript/jscomp/Compiler.java
Closure-161
private Node tryFoldArrayAccess(Node n, Node left, Node right) { Node parent = n.getParent(); // If GETPROP/GETELEM is used as assignment target the array literal is // acting as a temporary we can't fold it here: // "[][0] += 1" if (right.getType() != Token.NUMBER) { // Sometimes people...
src/com/google/javascript/jscomp/PeepholeFoldConstants.java
Closure-164
public boolean isSubtype(JSType other) { if (!(other instanceof ArrowType)) { return false; } ArrowType that = (ArrowType) other; // This is described in Draft 2 of the ES4 spec, // Section 3.4.7: Subtyping Function Types. // this.returnType <: that.returnType (covariant) if (!thi...
src/com/google/javascript/rhino/jstype/ArrowType.java
Closure-166
public void matchConstraint(JSType constraint) { // We only want to match constraints on anonymous types. if (hasReferenceName()) { return; } // Handle the case where the constraint object is a record type. // // param constraint {{prop: (number|undefined)}} // function f(constraint...
src/com/google/javascript/rhino/jstype/PrototypeObjectType.java
Closure-168
@Override public void visit(NodeTraversal t, Node n, Node parent) { if (t.inGlobalScope()) { return; } if (n.isReturn() && n.getFirstChild() != null) { data.get(t.getScopeRoot()).recordNonEmptyReturn(); } if (t.getScopeDepth() <= 2) { // The first-order functi...
src/com/google/javascript/jscomp/TypedScopeCreator.java
Closure-17
private JSType getDeclaredType(String sourceName, JSDocInfo info, Node lValue, @Nullable Node rValue) { if (info != null && info.hasType()) { return getDeclaredTypeInAnnotation(sourceName, lValue, info); } else if (rValue != null && rValue.isFunction() && shouldUseFunctionLiter...
src/com/google/javascript/jscomp/TypedScopeCreator.java
Closure-172
private boolean isQualifiedNameInferred( String qName, Node n, JSDocInfo info, Node rhsValue, JSType valueType) { if (valueType == null) { return true; } // Prototypes of constructors and interfaces are always declared. if (qName != null && qName.endsWith(".prototype...
src/com/google/javascript/jscomp/TypedScopeCreator.java
Closure-176
private void updateScopeForTypeChange( FlowScope scope, Node left, JSType leftType, JSType resultType) { Preconditions.checkNotNull(resultType); switch (left.getType()) { case Token.NAME: String varName = left.getString(); Var var = syntacticScope.getVar(varName); boolean i...
src/com/google/javascript/jscomp/TypeInference.java
Closure-18
Node parseInputs() { boolean devMode = options.devMode != DevMode.OFF; // If old roots exist (we are parsing a second time), detach each of the // individual file parse trees. if (externsRoot != null) { externsRoot.detachChildren(); } if (jsRoot != null) { jsRoot.detachChildren();...
src/com/google/javascript/jscomp/Compiler.java
Closure-19
protected void declareNameInScope(FlowScope scope, Node node, JSType type) { switch (node.getType()) { case Token.NAME: scope.inferSlotType(node.getString(), type); break; case Token.GETPROP: String qualifiedName = node.getQualifiedName(); Preconditions.checkNotNull(qu...
src/com/google/javascript/jscomp/type/ChainableReverseAbstractInterpreter.java
Closure-2
private void checkInterfaceConflictProperties(NodeTraversal t, Node n, String functionName, HashMap<String, ObjectType> properties, HashMap<String, ObjectType> currentProperties, ObjectType interfaceType) { ObjectType implicitProto = interfaceType.getImplicitPrototype(); Set<String> currentP...
src/com/google/javascript/jscomp/TypeCheck.java
Closure-20
private Node tryFoldSimpleFunctionCall(Node n) { Preconditions.checkState(n.isCall()); Node callTarget = n.getFirstChild(); if (callTarget != null && callTarget.isName() && callTarget.getString().equals("String")) { // Fold String(a) to '' + (a) on immutable literals, // which allows...
src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java
Closure-21
public void visit(NodeTraversal t, Node n, Node parent) { // VOID nodes appear when there are extra semicolons at the BLOCK level. // I've been unable to think of any cases where this indicates a bug, // and apparently some people like keeping these semicolons around, // so we'll allow it. if (n.i...
src/com/google/javascript/jscomp/CheckSideEffects.java
Closure-22
public void visit(NodeTraversal t, Node n, Node parent) { // VOID nodes appear when there are extra semicolons at the BLOCK level. // I've been unable to think of any cases where this indicates a bug, // and apparently some people like keeping these semicolons around, // so we'll allow it. if (n.i...
src/com/google/javascript/jscomp/CheckSideEffects.java
Closure-23
private Node tryFoldArrayAccess(Node n, Node left, Node right) { Node parent = n.getParent(); // If GETPROP/GETELEM is used as assignment target the array literal is // acting as a temporary we can't fold it here: // "[][0] += 1" if (isAssignmentTarget(n)) { return n; } if (!righ...
src/com/google/javascript/jscomp/PeepholeFoldConstants.java
Closure-24
private void findAliases(NodeTraversal t) { Scope scope = t.getScope(); for (Var v : scope.getVarIterable()) { Node n = v.getNode(); int type = n.getType(); Node parent = n.getParent(); if (parent.isVar()) { if (n.hasChildren() && n.getFirstChild().isQualifiedNa...
src/com/google/javascript/jscomp/ScopedAliases.java
Closure-25
private FlowScope traverseNew(Node n, FlowScope scope) { Node constructor = n.getFirstChild(); scope = traverse(constructor, scope); JSType constructorType = constructor.getJSType(); JSType type = null; if (constructorType != null) { constructorType = constructorType.restrictByNotNullOrUnde...
src/com/google/javascript/jscomp/TypeInference.java
Closure-29
private boolean isInlinableObject(List<Reference> refs) { boolean ret = false; for (Reference ref : refs) { Node name = ref.getNode(); Node parent = ref.getParent(); Node gramps = ref.getGrandparent(); // Ignore indirect references, like x.y (except x.y(), since ...
src/com/google/javascript/jscomp/InlineObjectLiterals.java
Closure-31
Node parseInputs() { boolean devMode = options.devMode != DevMode.OFF; // If old roots exist (we are parsing a second time), detach each of the // individual file parse trees. if (externsRoot != null) { externsRoot.detachChildren(); } if (jsRoot != null) { jsRoot.detachChildren();...
src/com/google/javascript/jscomp/Compiler.java
Closure-32
private ExtractionInfo extractMultilineTextualBlock(JsDocToken token, WhitespaceOption option) { if (token == JsDocToken.EOC || token == JsDocToken.EOL || token == JsDocToken.EOF) { return new ExtractionInfo("", token); } stream.update(...
src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java
Closure-33
public void matchConstraint(ObjectType constraintObj) { // We only want to match contraints on anonymous types. // Handle the case where the constraint object is a record type. // // param constraintObj {{prop: (number|undefined)}} // function f(constraintObj) {} // f({}); // // We wa...
src/com/google/javascript/rhino/jstype/PrototypeObjectType.java