本文整理汇总了Java中com.sun.mirror.declaration.MethodDeclaration类的典型用法代码示例。如果您正苦于以下问题:Java MethodDeclaration类的具体用法?Java MethodDeclaration怎么用?Java MethodDeclaration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MethodDeclaration类属于com.sun.mirror.declaration包,在下文中一共展示了MethodDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSymbolAddresses
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
static void generateSymbolAddresses(final PrintWriter writer, final InterfaceDeclaration d) {
final Alias alias_annotation = d.getAnnotation(Alias.class);
final boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0;
boolean foundNative = false;
for ( final MethodDeclaration method : d.getMethods() ) {
if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
continue;
if ( !foundNative ) {
//writer.println("\t// " + d.getSimpleName());
writer.println("\tstatic final boolean " + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + ";");
foundNative = true;
}
writer.print("\tstatic final long " + Utils.getFunctionAddressName(d, method) + " = CL.getFunctionAddress(");
if ( aliased )
writer.println("new String [] {\"" + Utils.getFunctionAddressName(d, method) + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"});");
else
writer.println("\"" + Utils.getFunctionAddressName(d, method) + "\");");
}
if ( foundNative )
writer.println();
}
示例2: printErrorCheckMethod
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
final Check check = method.getAnnotation(Check.class);
if ( check != null ) // Get the error code from an IntBuffer output parameter
writer.println(tabs + "Util.checkCLError(" + check.value() + ".get(" + check.value() + ".position()));");
else {
final Class return_type = Utils.getJavaType(method.getReturnType());
if ( return_type == int.class )
writer.println(tabs + "Util.checkCLError(__result);");
else {
boolean hasErrCodeParam = false;
for ( final ParameterDeclaration param : method.getParameters() ) {
if ( "errcode_ret".equals(param.getSimpleName()) && Utils.getJavaType(param.getType()) == IntBuffer.class ) {
hasErrCodeParam = true;
break;
}
}
if ( hasErrCodeParam )
throw new RuntimeException("A method is missing the @Check annotation: " + method.toString());
}
}
}
示例3: parseLex
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private void parseLex (Lex lex, MethodDeclaration method, int lineNumber)
{
if (lex == null)
return;
RuleDoc rule = new RuleDoc (getLexer ());
rule.setAction (getLexAction (method, lex.token ()));
PatternDoc pattern = new PatternDoc (false);
pattern.setPattern (lex.pattern ());
if (lineNumber < 0)
pattern.setLineNumber (getAnnotationLineNumber (method, Lex.class.getName ()));
else
pattern.setLineNumber (lineNumber);
rule.addPattern (pattern);
rule.addStates (lex.state ());
}
示例4: parseRule
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private void parseRule (Rule rule, MethodDeclaration method, int lineNumber)
{
if (rule == null)
return;
GrammarDoc grammar = getParser ().getGrammar (rule.lhs ());
RhsDoc rhs = new RhsDoc ();
rhs.setTerms (rule.rhs ());
if (lineNumber < 0)
rhs.setLineNumber (getAnnotationLineNumber (method, Rule.class.getName ()));
else
rhs.setLineNumber (lineNumber);
String precedence = rule.precedence ().trim ();
if (precedence.length () > 0)
rhs.setPrecedence (precedence);
String action = getParseAction (method, rule.args ());
rhs.setAction (action);
grammar.addRhs (rhs);
}
示例5: ProcessedHttpUrlAnnotation
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
public ProcessedHttpUrlAnnotation(String typeName, Declaration declaration, String value, int weight) {
MethodDeclaration methodDeclaration = (MethodDeclaration) declaration;
String className = methodDeclaration.getDeclaringType().getQualifiedName();
this.methodName = declaration.getSimpleName();
this.docComment = declaration.getDocComment();
this.className = className;
this.value = value;
this.weight = weight;
this.setParams(methodDeclaration.getParameters());
String typeNameShort = typeName.substring(typeName.lastIndexOf("."));
SourcePosition positionInCode = declaration.getPosition();
sourceRef = positionInCode.file().getName() + ":" + positionInCode.line();
if (!(declaration instanceof MethodDeclaration)) {
messager.printWarning(positionInCode, "@" + typeNameShort + " declared on a non-method " + positionInCode);
}
if (showPositionsOfAnnotations) {
messager.printNotice(positionInCode, "@" + typeNameShort + " value " + value + " weight " + weight);
}
}
示例6: generateExceptionBeans
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private boolean generateExceptionBeans(MethodDeclaration method) {
String beanPackage = packageName + PD_JAXWS_PACKAGE_PD;
if (packageName.length() == 0)
beanPackage = JAXWS_PACKAGE_PD;
boolean beanGenerated = false;
for (ReferenceType thrownType : method.getThrownTypes()) {
ClassDeclaration typeDecl = ((ClassType)thrownType).getDeclaration();
if (typeDecl == null){
builder.onError(WebserviceapMessages.WEBSERVICEAP_COULD_NOT_FIND_TYPEDECL(thrownType.toString(), context.getRound()));
return false;
}
boolean tmp = generateExceptionBean(typeDecl, beanPackage);
beanGenerated = beanGenerated || tmp;
}
return beanGenerated;
}
示例7: getSchemaGenerator
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private synchronized XmlSchemaGenerator<TypeMirror, TypeDeclaration, FieldDeclaration, MethodDeclaration> getSchemaGenerator() {
if(xsdgen==null) {
xsdgen = new XmlSchemaGenerator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>( types.getNavigator(), types );
for (Map.Entry<QName, Reference> e : additionalElementDecls.entrySet()) {
Reference value = e.getValue();
if(value!=null) {
NonElement<TypeMirror, TypeDeclaration> typeInfo = refMap.get(value);
if(typeInfo==null)
throw new IllegalArgumentException(e.getValue()+" was not specified to JavaCompiler.bind");
xsdgen.add(e.getKey(),!(value.type instanceof PrimitiveType),typeInfo);
} else {
xsdgen.add(e.getKey(),false,null);
}
}
}
return xsdgen;
}
示例8: isOverriding
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
public boolean isOverriding(MethodDeclaration method, TypeDeclaration base) {
ClassDeclaration sc = (ClassDeclaration) base;
Declarations declUtil = env.getDeclarationUtils();
while(true) {
for (MethodDeclaration m : sc.getMethods()) {
if(declUtil.overrides(method,m))
return true;
}
if(sc.getSuperclass()==null)
return false;
sc = sc.getSuperclass().getDeclaration();
}
}
示例9: visitMethodDeclaration
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
@Override
public void visitMethodDeclaration(MethodDeclaration methodDeclaration) {
ERROR_PREFIX = methodDeclaration.getSimpleName() + ERROR_PREFIX_STATIC;
// return type must be void
if (!(methodDeclaration.getReturnType() instanceof VoidType))
reportError(methodDeclaration,
"the method shouldn't have any return value, but instead returns " +
methodDeclaration.getReturnType().toString());
// method must not have arguments
if (!methodDeclaration.getParameters().isEmpty())
reportError(methodDeclaration, "the method accepts parameters");
}
示例10: visitMethodDeclaration
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
@Override
public void visitMethodDeclaration(MethodDeclaration methodDeclaration) {
boolean correctSignature = false;
Collection<ParameterDeclaration> methodParams = methodDeclaration.getParameters();
// return type must be void
if (methodDeclaration.getReturnType() instanceof VoidType && methodParams.size() == 2) {
Iterator<ParameterDeclaration> it = methodParams.iterator();
ParameterDeclaration param = it.next();
ParameterDeclaration param2 = it.next();
if (param.getType().toString().equals(Node.class.getName()) &&
param2.getType().toString().equals(String.class.getName())) {
correctSignature = true;
}
}
if (!correctSignature) {
reportError(methodDeclaration,
ErrorMessages.INCORRECT_METHOD_SIGNATURE_FOR_NODE_ATTACHEMENT_CALLBACK);
}
}
示例11: visitMethodDeclaration
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
@Override
public void visitMethodDeclaration(MethodDeclaration methodDeclaration) {
boolean correctSignature = false;
Collection<ParameterDeclaration> methodParams = methodDeclaration.getParameters();
// return type must be void
if (methodDeclaration.getReturnType() instanceof VoidType && methodParams.size() == 1) {
Iterator<ParameterDeclaration> it = methodParams.iterator();
ParameterDeclaration param = it.next();
if (param.getType().toString().equals(String.class.getName())) {
correctSignature = true;
}
}
if (!correctSignature) {
reportError(methodDeclaration, ErrorMessages.INCORRECT_METHOD_SIGNATURE_FOR_ISREADY_CALLBACK);
}
}
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:20,代码来源:VirtualNodeIsReadyCallbackVisitorAPT.java
示例12: checkGettersSetters
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private boolean checkGettersSetters(String fieldName) {
final String getField = GenerateGettersSetters.getterPattern(fieldName);
boolean foundGet = false;
final String setField = GenerateGettersSetters.setterPattern(fieldName);
boolean foundSet = false;
Collection<MethodDeclaration> methods = _containingClassMethods;
for (MethodDeclaration methodDeclaration : methods) {
if (!foundGet && methodDeclaration.getSimpleName().matches(getField)) {
foundGet = true;
}
if (!foundSet && methodDeclaration.getSimpleName().matches(setField)) {
foundSet = true;
}
if (foundGet && foundSet)
return true;
}
return false;
}
示例13: generateSymbolAddresses
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) {
boolean first = true;
for ( final MethodDeclaration method : d.getMethods() ) {
if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
continue;
if ( first ) {
writer.println("\t// " + d.getSimpleName());
first = false;
}
writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";");
}
}
示例14: generateClearsFromParameters
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
for (ParameterDeclaration param : method.getParameters()) {
CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
Class nio_type = Utils.getNIOBufferType(param.getType());
String reference_name = Utils.getReferenceName(interface_decl, method, param);
writer.println("\t\tthis." + reference_name + " = null;");
}
}
}
示例15: generateCopiesFromParameters
import com.sun.mirror.declaration.MethodDeclaration; //导入依赖的package包/类
private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
for (ParameterDeclaration param : method.getParameters()) {
CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
if (cached_reference_annotation != null && cached_reference_annotation.name().length() == 0) {
Class nio_type = Utils.getNIOBufferType(param.getType());
String reference_name = Utils.getReferenceName(interface_decl, method, param);
writer.print("\t\t\tthis." + reference_name + " = ");
writer.println(REFERENCES_PARAMETER_NAME + "." + reference_name + ";");
}
}
}