blob: 3d31be1c697205e84f0646a86a5ef1f4596d4594 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*******************************************************************************
* Copyright (c) 2000, 2011 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.ISourceMethod;
/**
* Element info for IMethod elements.
*/
public abstract class SourceMethodElementInfo extends AnnotatableInfo implements ISourceMethod {
/**
* For a source method (that is, a method contained in a compilation unit)
* this is a collection of the names of the parameters for this method,
* in the order the parameters are delcared. For a binary method (that is,
* a method declared in a binary type), these names are invented as
* "arg"i where i starts at 1. This is an empty array if this method
* has no parameters.
*/
protected char[][] argumentNames;
/**
* A collection of type names of the exceptions this
* method throws, or an empty collection if this method
* does not declare to throw any exceptions. A name is a simple
* name or a qualified, dot separated name.
* For example, Hashtable or java.util.Hashtable.
*/
protected char[][] exceptionTypes;
protected ILocalVariable[] arguments;
/*
* The type parameters of this source type. Empty if none.
*/
protected ITypeParameter[] typeParameters = TypeParameter.NO_TYPE_PARAMETERS;
@Override
public char[][] getArgumentNames() {
return this.argumentNames;
}
@Override
public char[][] getExceptionTypeNames() {
return this.exceptionTypes;
}
@Override
public abstract char[] getReturnTypeName();
@Override
public char[][][] getTypeParameterBounds() {
int length = this.typeParameters.length;
char[][][] typeParameterBounds = new char[length][][];
for (int i = 0; i < length; i++) {
try {
TypeParameterElementInfo info = (TypeParameterElementInfo) ((JavaElement)this.typeParameters[i]).getElementInfo();
typeParameterBounds[i] = info.bounds;
} catch (JavaModelException e) {
// type parameter does not exist: ignore
}
}
return typeParameterBounds;
}
@Override
public char[][] getTypeParameterNames() {
int length = this.typeParameters.length;
if (length == 0) return CharOperation.NO_CHAR_CHAR;
char[][] typeParameterNames = new char[length][];
for (int i = 0; i < length; i++) {
typeParameterNames[i] = this.typeParameters[i].getElementName().toCharArray();
}
return typeParameterNames;
}
@Override
public abstract boolean isConstructor();
public abstract boolean isAnnotationMethod();
protected void setArgumentNames(char[][] names) {
this.argumentNames = names;
}
protected void setExceptionTypeNames(char[][] types) {
this.exceptionTypes = types;
}
protected abstract void setReturnType(char[] type);
}
|