blob: 41abd98901ab5a0c536e6a43526e3ab63a30e0b1 (
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) 2009, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.common.core.internal.resource.java.binary;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.ITypeParameter;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jpt.common.core.JptCommonCorePlugin;
import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
/**
* binary field
*/
final class BinaryField
extends BinaryAttribute
implements JavaResourceField {
BinaryField(JavaResourceType parent, IField field) {
super(parent, new FieldAdapter(field));
}
public Kind getKind() {
return Kind.FIELD;
}
@Override
protected ITypeBinding getJdtTypeBinding(IBinding jdtBinding) {
return ((IVariableBinding) jdtBinding).getType();
}
public void synchronizeWith(FieldDeclaration fieldDeclaration, VariableDeclarationFragment variableDeclaration) {
throw new UnsupportedOperationException();
}
public void resolveTypes(FieldDeclaration fieldDeclaration, VariableDeclarationFragment variableDeclaration) {
throw new UnsupportedOperationException();
}
// ********** adapters **********
/**
* IField adapter
*/
static class FieldAdapter
implements BinaryAttribute.Adapter {
final IField field;
FieldAdapter(IField field) {
super();
this.field = field;
}
public IField getElement() {
return this.field;
}
public Iterable<ITypeParameter> getTypeParameters() {
try {
return new ArrayIterable<ITypeParameter>(this.field.getDeclaringType().getTypeParameters());
}
catch (JavaModelException jme) {
JptCommonCorePlugin.log(jme);
}
return EmptyIterable.instance();
}
public IAnnotation[] getAnnotations() throws JavaModelException {
return this.field.getAnnotations();
}
public String getAttributeName() {
return this.field.getElementName();
}
public String getTypeSignature() throws JavaModelException {
return this.field.getTypeSignature();
}
}
}
|