Available Methods
- getType ( )
- getFirstChild ( )
- getParent ( )
- getLastChild ( )
- addChildToBack ( )
- getNext ( )
- getString ( )
- isName ( )
- getChildCount ( )
- isFunction ( )
- replaceChild ( )
- putBooleanProp ( )
- getJSDocInfo ( )
- isGetProp ( )
- hasChildren ( )
- isExprResult ( )
- removeChild ( )
- getJSType ( )
- isVar ( )
- setJSType ( )
- isQualifiedName ( )
- isCall ( )
- isAssign ( )
- isString ( )
- getQualifiedName ( )
- newString ( )
- isScript ( )
- hasOneChild ( )
- getDouble ( )
- isBlock ( )
- getBooleanProp ( )
- setJSDocInfo ( )
- addChildToFront ( )
- getAncestors ( )
- children ( )
- isEmpty ( )
- copyInformationFromForTree ( )
- isObjectLit ( )
- setLineno ( )
- detachFromParent ( )
- getChildAtIndex ( )
- copyInformationFrom ( )
- addChildAfter ( )
- detachChildren ( )
- isComma ( )
- isNew ( )
- setType ( )
- setCharno ( )
- putProp ( )
- isOr ( )
- isNumber ( )
- isFor ( )
- newNumber ( )
- setString ( )
- isTry ( )
- isReturn ( )
- isThis ( )
- getLineno ( )
- isAnd ( )
- addChildBefore ( )
- getSourceFileName ( )
- isParamList ( )
- removeFirstChild ( )
- isFromExterns ( )
- isVarArgs ( )
- isInc ( )
- cloneTree ( )
- isHook ( )
- isGetElem ( )
- getCharno ( )
- isNull ( )
- addChildrenToBack ( )
- tokenToName ( )
- isLabel ( )
- isCase ( )
- isEquivalentTo ( )
- setLength ( )
- isCatch ( )
- isOptionalArg ( )
- getProp ( )
- getInputId ( )
- isIf ( )
- FileLevelJsDocBuilder ( )
- isOnlyModifiesThisCall ( )
- setOptionalArg ( )
- addChildrenToFront ( )
- isDec ( )
- getSideEffectFlags ( )
- setStaticSourceFile ( )
- FLAG_LOCAL_RESULTS
- checkTreeEquals ( )
- isStringKey ( )
- removeChildAfter ( )
- getSecondChild ( )
- isNoSideEffectsCall ( )
- isThrow ( )
- setDirectives ( )
- isSyntheticBlock ( )
- isDo ( )
- hasMoreThanOneChild ( )
- isLet ( )
- isQuotedString ( )
- isEquivalentToTyped ( )
- detach ( )
- getStaticSourceFile ( )
- setIsSyntheticBlock ( )
- setInputId ( )
- isMemberFunctionDef ( )
- srcrefTree ( )
- setWasEmptyNode ( )
- SideEffectFlags ( )
- addChildrenAfter ( )
- setSourceEncodedPositionForTree ( )
- getJsDocBuilderForNode ( )
- toString ( )
- isArrayLit ( )
- toStringTree ( )
- getGrandparent ( )
- isAssignAdd ( )
- isDelProp ( )
- srcref ( )
- isDefaultValue ( )
- setStaticMember ( )
- getOnlyChild ( )
- useSourceInfoIfMissingFromForTree ( )
- isIn ( )
- isClass ( )
- replaceWith ( )
- getFirstFirstChild ( )
- isSwitch ( )
- addSuppression ( )
- getDirectives ( )
- isGetterDef ( )
- removeProp ( )
- getToken ( )
- getLastSibling ( )
Related Classes
- java.util.Collections
- java.util.Iterator
- java.util.concurrent.Callable
- java.util.logging.Logger
- java.util.TreeSet
- com.google.common.collect.Lists
- com.google.common.collect.ImmutableList
- javax.annotation.Nullable
- com.google.common.collect.Maps
- com.google.common.collect.Sets
- java.util.Deque
- com.google.common.base.Preconditions
- com.google.common.collect.ImmutableSet
- java.util.SortedSet
- com.google.common.base.Joiner
- com.google.common.collect.Iterables
- java.util.BitSet
- com.google.common.annotations.VisibleForTesting
- com.google.common.base.Predicate
- com.google.common.base.Predicates
- com.google.javascript.rhino.jstype.FunctionType
- com.google.javascript.rhino.jstype.ObjectType
- com.google.javascript.rhino.jstype.JSTypeRegistry
- com.google.javascript.jscomp.CheckLevel
- com.google.javascript.rhino.jstype.JSType
Java Code Examples for com.google.javascript.rhino.Node#isClass()
The following examples show how to use
com.google.javascript.rhino.Node#isClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeInspector.java From js-dossier with Apache License 2.0 | 5 votes |
private Iterable<Function.Detail> buildThrowsData( final NominalType context, Node node, JsDoc jsDoc) { if (node.isClass()) { final JSDocInfo info = findClassConstructorDocs(node); if (info != null) { jsDoc = JsDoc.from(info); } } final LinkFactory contextLinkFactory = linkFactory.withTypeContext(context); final TypeExpressionParser typeParser = expressionParserFactory.create(contextLinkFactory); return jsDoc .getThrowsClauses() .stream() .map( input -> { Detail.Builder detail = Detail.newBuilder(); Comment comment = parser.parseComment(input.getDescription(), contextLinkFactory); if (comment.getTokenCount() > 0) { detail.setDescription(comment); } if (input.getType().isPresent()) { JSTypeExpression expression = input.getType().get(); JSType thrownType = evaluate(expression); detail.setType(typeParser.parse(thrownType)); } return detail.build(); }) .collect(toImmutableList()); }
Example 2
Source File: StyleFixPass.java From clutz with MIT License | 4 votes |
private boolean isTypeDefinition(Node rhs) { return rhs.isClass() || rhs.getToken() == Token.INTERFACE; }
Example 3
Source File: DeclarationGenerator.java From clutz with MIT License | 4 votes |
private void visitFunctionParameters( FunctionType ftype, boolean emitTemplatizedTypes, List<String> alreadyEmittedTemplateType) { final boolean shouldEmitThis = shouldEmitThisParam(ftype); if (!shouldEmitThis) { // alreadyEmittedTemplateType might be an immutable list. alreadyEmittedTemplateType = new ArrayList<>(alreadyEmittedTemplateType); alreadyEmittedTemplateType.add(ftype.getTypeOfThis().getDisplayName()); } if (emitTemplatizedTypes) { visitTemplateTypes(ftype, alreadyEmittedTemplateType, true); } // When all the parameters to the function are unknown, it might be the // case that the function is overriding/implementing a superclass or interface that is in an // unseen input. // If so, we can't know whether the parameters are optional or not, so mark them optional. // This is too broad (we also affect callback types) but we can fix that if it's a problem. boolean makeAllParametersOptional = allParametersUnknown(ftype); emit("("); Iterator<Parameter> parameters = ftype.getParameters().iterator(); if (shouldEmitThis) { emitThisParameter(ftype, parameters); } Iterator<String> names = null; Node functionSource = ftype.getSource(); if (functionSource != null && functionSource.isClass()) { Node members = functionSource.getLastChild(); for (Node member : members.children()) { if (member.isMemberFunctionDef() && member.getString().equals("constructor")) { functionSource = member.getOnlyChild(); break; } } } if (functionSource != null && functionSource.isFunction()) { // functionSource AST: FUNCTION -> (NAME, PARAM_LIST, BLOCK ...) Iterable<Node> parameterNodes = functionSource.getFirstChild().getNext().children(); // TODO(bradfordcsmith): This will need to be updated when transpilation of default // and destructured parameters stops happening in checks-only compilation. names = transform(parameterNodes, (node) -> this.getParameterName(node)).iterator(); } int paramCount = 0; while (parameters.hasNext()) { Parameter param = parameters.next(); if (param.isVariadic()) { emit("..."); } String pName = ""; if (names != null && names.hasNext()) { pName = names.next(); } if (pName.isEmpty()) { // If we cannot find a name for the parameter, just generate one. if (paramCount < 26) { pName = Character.toString((char) (97 + paramCount)); } else { pName = "p" + (paramCount - 26); } } emitNoSpace(pName); paramCount++; // In TypeScript ...a?: any[] is illegal, so we can only make non-varargs optional. if ((param.isOptional() || makeAllParametersOptional) && !param.isVariadic()) { emit("?"); visitTypeDeclaration(param.getJSType(), param.isVariadic(), true); } else { visitTypeDeclaration(param.getJSType(), param.isVariadic(), false); } if (parameters.hasNext()) { emit(", "); } } emit(")"); }
Example 4
Source File: TypeCollectionPass.java From js-dossier with Apache License 2.0 | 4 votes |
private boolean shouldConvertToConstructor(Symbol s) { Node n = s.getNode(); return n != null && (n.isClass() || (n.getJSType() != null && n.getJSType().isConstructor())); }
Example 5
Source File: Nodes.java From js-dossier with Apache License 2.0 | 4 votes |
public static boolean isUnnamedClass(Node n) { return n != null && n.isClass() && n.getFirstChild() != null && n.getFirstChild().isEmpty(); }