APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.parser

public Class ReferenceParser

extends Object
Class Inheritance
Imports
com.sun.source.tree.AnnotatedTypeTree, .Tree, com.sun.source.util.TreeScanner, com.sun.tools.javac.parser.Tokens.TokenKind, com.sun.tools.javac.tree.JCTree, com.sun.tools.javac.util.JCDiagnostic, .List, .ListBuffer, .Log, .Name, javax.tools.JavaFileObject

A utility class to parse a string in a doc comment containing a reference to an API element, such as a type, field or method.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ReferenceParser.Mode

Context dependent parsing mode which either disallows, allows or requires a member reference.

public static class
ReferenceParser.ParseException

An exception that indicates an error occurred while parsing a signature.

public static class
ReferenceParser.Reference

An object to contain the result of parsing a reference to an API element.

pack-priv static class

Field Summary

Modifier and TypeField and Description
private final ParserFactory

Constructor Summary

AccessConstructor and Description
public
ReferenceParser(ParserFactory
a factory for parsing Java source code.
fac
)

Create a parser object to parse reference signatures.

Method Summary

Modifier and TypeMethod and Description
private void
public ReferenceParser.Reference

Returns:

a Reference object containing the result of parsing the signature
parse
(String
the signature to be parsed
sig
,
ReferenceParser.Mode
the parsing mode
mode
)

Parse a reference to an API element as may be found in doc comment.

private Name
parseMember(String sig, int beginIndex, int endIndex, Log.DeferredDiagnosticHandler dh)

private JCTree.JCExpression
parseModule(String sig, int beginIndex, int endIndex, Log.DeferredDiagnosticHandler dh)

private List<JCTree>
parseParams(String sig, int beginIndex, int endIndex, Log.DeferredDiagnosticHandler dh)

private JCTree
parseType(String sig, int beginIndex, int endIndex, Log.DeferredDiagnosticHandler dh)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

facback to summary
private final ParserFactory fac

Constructor Detail

ReferenceParserback to summary
public ReferenceParser(ParserFactory fac)

Create a parser object to parse reference signatures.

Parameters
fac:ParserFactory

a factory for parsing Java source code.

Method Detail

checkDiagsback to summary
private void checkDiags(Log.DeferredDiagnosticHandler h, int offset) throws ParseException
parseback to summary
public ReferenceParser.Reference parse(String sig, ReferenceParser.Mode mode) throws ParseException

Parse a reference to an API element as may be found in doc comment.

Parameters
sig:String

the signature to be parsed

mode:ReferenceParser.Mode

the parsing mode

Returns:ReferenceParser.Reference

a Reference object containing the result of parsing the signature

Exceptions
ParseException:
if there is an error while parsing the signature
parseMemberback to summary
private Name parseMember(String sig, int beginIndex, int endIndex, Log.DeferredDiagnosticHandler dh) throws ParseException
parseModuleback to summary
private JCTree.JCExpression parseModule(String sig, int beginIndex, int endIndex, Log.DeferredDiagnosticHandler dh) throws ParseException
parseParamsback to summary
private List<JCTree> parseParams(String sig, int beginIndex, int endIndex, Log.DeferredDiagnosticHandler dh) throws ParseException
parseTypeback to summary
private JCTree parseType(String sig, int beginIndex, int endIndex, Log.DeferredDiagnosticHandler dh) throws ParseException
com.sun.tools.javac.parser back to summary

public final Enum ReferenceParser.Mode

extends Enum<ReferenceParser.Mode>
Class Inheritance

Context dependent parsing mode which either disallows, allows or requires a member reference. The MEMBER_OPTIONAL value also allows arbitrary URI fragments using a double hash mark.

Field Summary

Modifier and TypeField and Description
public static final ReferenceParser.Mode
public static final ReferenceParser.Mode
public static final ReferenceParser.Mode

Constructor Summary

AccessConstructor and Description
private
Mode()

Method Summary

Modifier and TypeMethod and Description
public static ReferenceParser.Mode
public static ReferenceParser.Mode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

MEMBER_DISALLOWEDback to summary
public static final ReferenceParser.Mode MEMBER_DISALLOWED
MEMBER_OPTIONALback to summary
public static final ReferenceParser.Mode MEMBER_OPTIONAL
MEMBER_REQUIREDback to summary
public static final ReferenceParser.Mode MEMBER_REQUIRED

Constructor Detail

Modeback to summary
private Mode()

Method Detail

valueOfback to summary
public static ReferenceParser.Mode valueOf(String name)
valuesback to summary
public static ReferenceParser.Mode[] values()
com.sun.tools.javac.parser back to summary

public Class ReferenceParser.ParseException

extends Exception
Class Inheritance

An exception that indicates an error occurred while parsing a signature.

Field Summary

Modifier and TypeField and Description
pack-priv final int
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv
ParseException(int pos, String message)

Field Detail

posback to summary
pack-priv final int pos
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

ParseExceptionback to summary
pack-priv ParseException(int pos, String message)
com.sun.tools.javac.parser back to summary

public Class ReferenceParser.Reference

extends Object
Class Inheritance

An object to contain the result of parsing a reference to an API element. Any, but not all, of the member fields may be null.

Field Summary

Modifier and TypeField and Description
public final Name
member

The member name, if any, in the signature.

public final JCTree.JCExpression
public final List<JCTree>
paramTypes

The parameter types, if any, in the signature.

public final JCTree
qualExpr

The type, if any, in the signature.

Constructor Summary

AccessConstructor and Description
pack-priv
Reference(JCTree.JCExpression moduleName, JCTree qualExpr, Name member, List<JCTree> paramTypes)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

memberback to summary
public final Name member

The member name, if any, in the signature.

moduleNameback to summary
public final JCTree.JCExpression moduleName
paramTypesback to summary
public final List<JCTree> paramTypes

The parameter types, if any, in the signature.

qualExprback to summary
public final JCTree qualExpr

The type, if any, in the signature.

Constructor Detail

Referenceback to summary
pack-priv Reference(JCTree.JCExpression moduleName, JCTree qualExpr, Name member, List<JCTree> paramTypes)
com.sun.tools.javac.parser back to summary

pack-priv Class ReferenceParser.TypeAnnotationFinder

extends TreeScanner<Tree, Void>
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Tree
reduce(Tree t1, Tree t2)

Overrides com.sun.source.util.TreeScanner.reduce.

Reduces two results into a combined result.

public Tree
Inherited from com.sun.source.util.TreeScanner:
scanscanvisitAnnotationvisitAnyPatternvisitArrayAccessvisitArrayTypevisitAssertvisitAssignmentvisitBinaryvisitBindingPatternvisitBlockvisitBreakvisitCasevisitCatchvisitClassvisitCompilationUnitvisitCompoundAssignmentvisitConditionalExpressionvisitConstantCaseLabelvisitContinuevisitDeconstructionPatternvisitDefaultCaseLabelvisitDoWhileLoopvisitEmptyStatementvisitEnhancedForLoopvisitErroneousvisitExportsvisitExpressionStatementvisitForLoopvisitIdentifiervisitIfvisitImportvisitInstanceOfvisitIntersectionTypevisitLabeledStatementvisitLambdaExpressionvisitLiteralvisitMemberReferencevisitMemberSelectvisitMethodvisitMethodInvocationvisitModifiersvisitModulevisitNewArrayvisitNewClassvisitOpensvisitOthervisitPackagevisitParameterizedTypevisitParenthesizedvisitPatternCaseLabelvisitPrimitiveTypevisitProvidesvisitRequiresvisitReturnvisitSwitchvisitSwitchExpressionvisitSynchronizedvisitThrowvisitTryvisitTypeCastvisitTypeParametervisitUnaryvisitUnionTypevisitUsesvisitVariablevisitVarTypevisitWhileLoopvisitWildcardvisitYield

Constructor Detail

TypeAnnotationFinderback to summary
pack-priv TypeAnnotationFinder()

Method Detail

reduceback to summary
public Tree reduce(Tree t1, Tree t2)

Overrides com.sun.source.util.TreeScanner.reduce.

Doc from com.sun.source.util.TreeScanner.reduce.

Reduces two results into a combined result. The default implementation is to return the first parameter. The general contract of the method is that it may take any action whatsoever.

Annotations
@Override
visitAnnotatedTypeback to summary
public Tree visitAnnotatedType(AnnotatedTypeTree t, Void ignore)

Overrides com.sun.source.util.TreeScanner.visitAnnotatedType.

Implements com.sun.source.tree.TreeVisitor.visitAnnotatedType.

Doc from com.sun.source.util.TreeScanner.visitAnnotatedType.

Visits an AnnotatedTypeTree node.

Annotations
@Override