~ubuntu-branches/ubuntu/natty/aspectj/natty

« back to all changes in this revision

Viewing changes to org.aspectj/modules/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePattern.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2009-10-04 16:37:23 UTC
  • mfrom: (1.1.3 upstream) (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091004163723-ck4y7j7fhjxskkie
Tags: 1.6.6+dfsg-1
* New upstream release.
  - Update 02_use_gjdoc.diff patch
* Update my email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* *******************************************************************
 
2
 * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
 
3
 * All rights reserved. 
 
4
 * This program and the accompanying materials are made available 
 
5
 * under the terms of the Eclipse Public License v1.0 
 
6
 * which accompanies this distribution and is available at 
 
7
 * http://www.eclipse.org/legal/epl-v10.html 
 
8
 *  
 
9
 * Contributors: 
 
10
 *     PARC     initial implementation 
 
11
 * ******************************************************************/
 
12
 
 
13
package org.aspectj.weaver.patterns;
 
14
 
 
15
import java.io.DataOutputStream;
 
16
import java.io.IOException;
 
17
import java.lang.reflect.Modifier;
 
18
import java.util.Iterator;
 
19
import java.util.Map;
 
20
 
 
21
import org.aspectj.bridge.MessageUtil;
 
22
import org.aspectj.util.FuzzyBoolean;
 
23
import org.aspectj.weaver.BCException;
 
24
import org.aspectj.weaver.ISourceContext;
 
25
import org.aspectj.weaver.IntMap;
 
26
import org.aspectj.weaver.ResolvedType;
 
27
import org.aspectj.weaver.TypeVariableReference;
 
28
import org.aspectj.weaver.UnresolvedType;
 
29
import org.aspectj.weaver.VersionedDataInputStream;
 
30
import org.aspectj.weaver.WeaverMessages;
 
31
import org.aspectj.weaver.World;
 
32
 
 
33
/**
 
34
 * On creation, type pattern only contains WildTypePattern nodes, not BindingType or ExactType.
 
35
 * 
 
36
 * <p>
 
37
 * Then we call resolveBindings() during compilation During concretization of enclosing pointcuts, we call remapAdviceFormals
 
38
 * 
 
39
 * @author Erik Hilsdale
 
40
 * @author Jim Hugunin
 
41
 */
 
42
public abstract class TypePattern extends PatternNode {
 
43
        public static class MatchKind {
 
44
                private String name;
 
45
 
 
46
                public MatchKind(String name) {
 
47
                        this.name = name;
 
48
                }
 
49
 
 
50
                public String toString() {
 
51
                        return name;
 
52
                }
 
53
        }
 
54
 
 
55
        public static final MatchKind STATIC = new MatchKind("STATIC");
 
56
        public static final MatchKind DYNAMIC = new MatchKind("DYNAMIC");
 
57
 
 
58
        public static final TypePattern ELLIPSIS = new EllipsisTypePattern();
 
59
        public static final TypePattern ANY = new AnyTypePattern();
 
60
        public static final TypePattern NO = new NoTypePattern();
 
61
 
 
62
        protected boolean includeSubtypes;
 
63
        protected boolean isVarArgs = false;
 
64
        protected AnnotationTypePattern annotationPattern = AnnotationTypePattern.ANY;
 
65
        protected TypePatternList typeParameters = TypePatternList.EMPTY;
 
66
 
 
67
        protected TypePattern(boolean includeSubtypes, boolean isVarArgs, TypePatternList typeParams) {
 
68
                this.includeSubtypes = includeSubtypes;
 
69
                this.isVarArgs = isVarArgs;
 
70
                this.typeParameters = (typeParams == null ? TypePatternList.EMPTY : typeParams);
 
71
        }
 
72
 
 
73
        protected TypePattern(boolean includeSubtypes, boolean isVarArgs) {
 
74
                this(includeSubtypes, isVarArgs, null);
 
75
        }
 
76
 
 
77
        public AnnotationTypePattern getAnnotationPattern() {
 
78
                return annotationPattern;
 
79
        }
 
80
 
 
81
        public boolean isVarArgs() {
 
82
                return isVarArgs;
 
83
        }
 
84
 
 
85
        public boolean isStarAnnotation() {
 
86
                return annotationPattern == AnnotationTypePattern.ANY;
 
87
        }
 
88
 
 
89
        public boolean isArray() {
 
90
                return false;
 
91
        }
 
92
 
 
93
        protected TypePattern(boolean includeSubtypes) {
 
94
                this(includeSubtypes, false);
 
95
        }
 
96
 
 
97
        public void setAnnotationTypePattern(AnnotationTypePattern annPatt) {
 
98
                this.annotationPattern = annPatt;
 
99
        }
 
100
 
 
101
        public void setTypeParameters(TypePatternList typeParams) {
 
102
                this.typeParameters = typeParams;
 
103
        }
 
104
 
 
105
        public TypePatternList getTypeParameters() {
 
106
                return this.typeParameters;
 
107
        }
 
108
 
 
109
        public void setIsVarArgs(boolean isVarArgs) {
 
110
                this.isVarArgs = isVarArgs;
 
111
        }
 
112
 
 
113
        // answer conservatively...
 
114
        protected boolean couldEverMatchSameTypesAs(TypePattern other) {
 
115
                if (this.includeSubtypes || other.includeSubtypes)
 
116
                        return true;
 
117
                if (this.annotationPattern != AnnotationTypePattern.ANY)
 
118
                        return true;
 
119
                if (other.annotationPattern != AnnotationTypePattern.ANY)
 
120
                        return true;
 
121
                return false;
 
122
        }
 
123
 
 
124
        // XXX non-final for Not, && and ||
 
125
        public boolean matchesStatically(ResolvedType type) {
 
126
                if (includeSubtypes) {
 
127
                        return matchesSubtypes(type);
 
128
                } else {
 
129
                        return matchesExactly(type);
 
130
                }
 
131
        }
 
132
 
 
133
        public abstract FuzzyBoolean matchesInstanceof(ResolvedType type);
 
134
 
 
135
        public final FuzzyBoolean matches(ResolvedType type, MatchKind kind) {
 
136
                // FuzzyBoolean typeMatch = null;
 
137
                // ??? This is part of gracefully handling missing references
 
138
                if (type.isMissing())
 
139
                        return FuzzyBoolean.NO;
 
140
 
 
141
                if (kind == STATIC) {
 
142
                        // typeMatch = FuzzyBoolean.fromBoolean(matchesStatically(type));
 
143
                        // return typeMatch.and(annotationPattern.matches(type));
 
144
                        return FuzzyBoolean.fromBoolean(matchesStatically(type));
 
145
                } else if (kind == DYNAMIC) {
 
146
                        // System.err.println("matching: " + this + " with " + type);
 
147
                        // typeMatch = matchesInstanceof(type);
 
148
                        // System.err.println("    got: " + ret);
 
149
                        // return typeMatch.and(annotationPattern.matches(type));
 
150
                        return matchesInstanceof(type);
 
151
                } else {
 
152
                        throw new IllegalArgumentException("kind must be DYNAMIC or STATIC");
 
153
                }
 
154
        }
 
155
 
 
156
        protected abstract boolean matchesExactly(ResolvedType type);
 
157
 
 
158
        protected abstract boolean matchesExactly(ResolvedType type, ResolvedType annotatedType);
 
159
 
 
160
        protected boolean matchesSubtypes(ResolvedType type) {
 
161
                // System.out.println("matching: " + this + " to " + type);
 
162
                if (matchesExactly(type)) {
 
163
                        return true;
 
164
                }
 
165
 
 
166
                // pr124808
 
167
                Iterator typesIterator = null;
 
168
                if (type.isTypeVariableReference()) {
 
169
                        typesIterator = ((TypeVariableReference) type).getTypeVariable().getFirstBound().resolve(type.getWorld())
 
170
                                        .getDirectSupertypes();
 
171
                } else {
 
172
                        // pr223605
 
173
                        if (type.isRawType()) {
 
174
                                type = type.getGenericType();
 
175
                        }
 
176
                        typesIterator = type.getDirectSupertypes();
 
177
                }
 
178
 
 
179
                for (Iterator i = typesIterator; i.hasNext();) {
 
180
                        ResolvedType superType = (ResolvedType) i.next();
 
181
                        if (matchesSubtypes(superType, type)) {
 
182
                                return true;
 
183
                        }
 
184
                }
 
185
                return false;
 
186
        }
 
187
 
 
188
        protected boolean matchesSubtypes(ResolvedType superType, ResolvedType annotatedType) {
 
189
                // System.out.println("matching2: " + this + " to " + superType);
 
190
                if (matchesExactly(superType, annotatedType)) {
 
191
                        // System.out.println("    true");
 
192
                        return true;
 
193
                }
 
194
                // If an ITD is applied, it will be put onto the generic type, not the parameterized or raw form
 
195
                if (superType.isParameterizedType() || superType.isRawType()) {
 
196
                        superType = superType.getGenericType();
 
197
                }
 
198
                // FuzzyBoolean ret = FuzzyBoolean.NO; // ??? -eh
 
199
                for (Iterator i = superType.getDirectSupertypes(); i.hasNext();) {
 
200
                        ResolvedType superSuperType = (ResolvedType) i.next();
 
201
                        if (matchesSubtypes(superSuperType, annotatedType))
 
202
                                return true;
 
203
                }
 
204
                return false;
 
205
        }
 
206
 
 
207
        public UnresolvedType resolveExactType(IScope scope, Bindings bindings) {
 
208
                TypePattern p = resolveBindings(scope, bindings, false, true);
 
209
                if (!(p instanceof ExactTypePattern))
 
210
                        return ResolvedType.MISSING;
 
211
                return ((ExactTypePattern) p).getType();
 
212
        }
 
213
 
 
214
        public UnresolvedType getExactType() {
 
215
                if (this instanceof ExactTypePattern)
 
216
                        return ((ExactTypePattern) this).getType();
 
217
                else
 
218
                        return ResolvedType.MISSING;
 
219
        }
 
220
 
 
221
        protected TypePattern notExactType(IScope s) {
 
222
                s.getMessageHandler().handleMessage(
 
223
                                MessageUtil.error(WeaverMessages.format(WeaverMessages.EXACT_TYPE_PATTERN_REQD), getSourceLocation()));
 
224
                return NO;
 
225
        }
 
226
 
 
227
        // public boolean assertExactType(IMessageHandler m) {
 
228
        // if (this instanceof ExactTypePattern) return true;
 
229
        //              
 
230
        // //XXX should try harder to avoid multiple errors for one problem
 
231
        // m.handleMessage(MessageUtil.error("exact type pattern required", getSourceLocation()));
 
232
        // return false;
 
233
        // }
 
234
 
 
235
        /**
 
236
         * This can modify in place, or return a new TypePattern if the type changes.
 
237
         */
 
238
        public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType) {
 
239
                annotationPattern = annotationPattern.resolveBindings(scope, bindings, allowBinding);
 
240
                return this;
 
241
        }
 
242
 
 
243
        public void resolve(World world) {
 
244
                annotationPattern.resolve(world);
 
245
        }
 
246
 
 
247
        /**
 
248
         * return a version of this type pattern in which all type variable references have been replaced by their corresponding entry
 
249
         * in the map.
 
250
         */
 
251
        public abstract TypePattern parameterizeWith(Map typeVariableMap, World w);
 
252
 
 
253
        public void postRead(ResolvedType enclosingType) {
 
254
        }
 
255
 
 
256
        public boolean isStar() {
 
257
                return false;
 
258
        }
 
259
 
 
260
        /**
 
261
         * This is called during concretization of pointcuts, it is used by BindingTypePattern to return a new BindingTypePattern with a
 
262
         * formal index appropiate for the advice, rather than for the lexical declaration, i.e. this handles transforamtions through
 
263
         * named pointcuts.
 
264
         * 
 
265
         * <pre>
 
266
         * pointcut foo(String name): args(name);
 
267
         * --&gt; This makes a BindingTypePattern(0) pointing to the 0th formal
 
268
         * 
 
269
         * before(Foo f, String n): this(f) &amp;&amp; foo(n) { ... }
 
270
         * --&gt; when resolveReferences is called on the args from the above, it
 
271
         *     will return a BindingTypePattern(1)
 
272
         * 
 
273
         * before(Foo f): this(f) &amp;&amp; foo(*) { ... }
 
274
         * --&gt; when resolveReferences is called on the args from the above, it
 
275
         *     will return an ExactTypePattern(String)
 
276
         * </pre>
 
277
         */
 
278
        public TypePattern remapAdviceFormals(IntMap bindings) {
 
279
                return this;
 
280
        }
 
281
 
 
282
        public static final byte WILD = 1;
 
283
        public static final byte EXACT = 2;
 
284
        public static final byte BINDING = 3;
 
285
        public static final byte ELLIPSIS_KEY = 4;
 
286
        public static final byte ANY_KEY = 5;
 
287
        public static final byte NOT = 6;
 
288
        public static final byte OR = 7;
 
289
        public static final byte AND = 8;
 
290
        public static final byte NO_KEY = 9;
 
291
        public static final byte ANY_WITH_ANNO = 10;
 
292
        public static final byte HAS_MEMBER = 11;
 
293
 
 
294
        public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
 
295
                byte key = s.readByte();
 
296
                switch (key) {
 
297
                case WILD:
 
298
                        return WildTypePattern.read(s, context);
 
299
                case EXACT:
 
300
                        return ExactTypePattern.read(s, context);
 
301
                case BINDING:
 
302
                        return BindingTypePattern.read(s, context);
 
303
                case ELLIPSIS_KEY:
 
304
                        return ELLIPSIS;
 
305
                case ANY_KEY:
 
306
                        return ANY;
 
307
                case NO_KEY:
 
308
                        return NO;
 
309
                case NOT:
 
310
                        return NotTypePattern.read(s, context);
 
311
                case OR:
 
312
                        return OrTypePattern.read(s, context);
 
313
                case AND:
 
314
                        return AndTypePattern.read(s, context);
 
315
                case ANY_WITH_ANNO:
 
316
                        return AnyWithAnnotationTypePattern.read(s, context);
 
317
                case HAS_MEMBER:
 
318
                        return HasMemberTypePattern.read(s, context);
 
319
                }
 
320
                throw new BCException("unknown TypePattern kind: " + key);
 
321
        }
 
322
 
 
323
        public boolean isIncludeSubtypes() {
 
324
                return includeSubtypes;
 
325
        }
 
326
 
 
327
}
 
328
 
 
329
class EllipsisTypePattern extends TypePattern {
 
330
 
 
331
        /**
 
332
         * Constructor for EllipsisTypePattern.
 
333
         * 
 
334
         * @param includeSubtypes
 
335
         */
 
336
        public EllipsisTypePattern() {
 
337
                super(false, false, new TypePatternList());
 
338
        }
 
339
 
 
340
        /*
 
341
         * (non-Javadoc)
 
342
         * 
 
343
         * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern)
 
344
         */
 
345
        protected boolean couldEverMatchSameTypesAs(TypePattern other) {
 
346
                return true;
 
347
        }
 
348
 
 
349
        /**
 
350
         * @see org.aspectj.weaver.patterns.TypePattern#matchesExactly(IType)
 
351
         */
 
352
        protected boolean matchesExactly(ResolvedType type) {
 
353
                return false;
 
354
        }
 
355
 
 
356
        protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) {
 
357
                return false;
 
358
        }
 
359
 
 
360
        /**
 
361
         * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType)
 
362
         */
 
363
        public FuzzyBoolean matchesInstanceof(ResolvedType type) {
 
364
                return FuzzyBoolean.NO;
 
365
        }
 
366
 
 
367
        /**
 
368
         * @see org.aspectj.weaver.patterns.PatternNode#write(DataOutputStream)
 
369
         */
 
370
        public void write(DataOutputStream s) throws IOException {
 
371
                s.writeByte(ELLIPSIS_KEY);
 
372
        }
 
373
 
 
374
        public String toString() {
 
375
                return "..";
 
376
        }
 
377
 
 
378
        /*
 
379
         * (non-Javadoc)
 
380
         * 
 
381
         * @see java.lang.Object#equals(java.lang.Object)
 
382
         */
 
383
        public boolean equals(Object obj) {
 
384
                return (obj instanceof EllipsisTypePattern);
 
385
        }
 
386
 
 
387
        /*
 
388
         * (non-Javadoc)
 
389
         * 
 
390
         * @see java.lang.Object#hashCode()
 
391
         */
 
392
        public int hashCode() {
 
393
                return 17 * 37;
 
394
        }
 
395
 
 
396
        public Object accept(PatternNodeVisitor visitor, Object data) {
 
397
                return visitor.visit(this, data);
 
398
        }
 
399
 
 
400
        public TypePattern parameterizeWith(Map typeVariableMap, World w) {
 
401
                return this;
 
402
        }
 
403
 
 
404
}
 
405
 
 
406
class AnyTypePattern extends TypePattern {
 
407
 
 
408
        /**
 
409
         * Constructor for EllipsisTypePattern.
 
410
         * 
 
411
         * @param includeSubtypes
 
412
         */
 
413
        public AnyTypePattern() {
 
414
                super(false, false, new TypePatternList());
 
415
        }
 
416
 
 
417
        /*
 
418
         * (non-Javadoc)
 
419
         * 
 
420
         * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern)
 
421
         */
 
422
        protected boolean couldEverMatchSameTypesAs(TypePattern other) {
 
423
                return true;
 
424
        }
 
425
 
 
426
        /**
 
427
         * @see org.aspectj.weaver.patterns.TypePattern#matchesExactly(IType)
 
428
         */
 
429
        protected boolean matchesExactly(ResolvedType type) {
 
430
                return true;
 
431
        }
 
432
 
 
433
        protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) {
 
434
                return true;
 
435
        }
 
436
 
 
437
        /**
 
438
         * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType)
 
439
         */
 
440
        public FuzzyBoolean matchesInstanceof(ResolvedType type) {
 
441
                return FuzzyBoolean.YES;
 
442
        }
 
443
 
 
444
        /**
 
445
         * @see org.aspectj.weaver.patterns.PatternNode#write(DataOutputStream)
 
446
         */
 
447
        public void write(DataOutputStream s) throws IOException {
 
448
                s.writeByte(ANY_KEY);
 
449
        }
 
450
 
 
451
        /**
 
452
         * @see org.aspectj.weaver.patterns.TypePattern#matches(IType, MatchKind)
 
453
         */
 
454
        // public FuzzyBoolean matches(IType type, MatchKind kind) {
 
455
        // return FuzzyBoolean.YES;
 
456
        // }
 
457
        /**
 
458
         * @see org.aspectj.weaver.patterns.TypePattern#matchesSubtypes(IType)
 
459
         */
 
460
        protected boolean matchesSubtypes(ResolvedType type) {
 
461
                return true;
 
462
        }
 
463
 
 
464
        public boolean isStar() {
 
465
                return true;
 
466
        }
 
467
 
 
468
        public String toString() {
 
469
                return "*";
 
470
        }
 
471
 
 
472
        public boolean equals(Object obj) {
 
473
                return (obj instanceof AnyTypePattern);
 
474
        }
 
475
 
 
476
        public int hashCode() {
 
477
                return 37;
 
478
        }
 
479
 
 
480
        public Object accept(PatternNodeVisitor visitor, Object data) {
 
481
                return visitor.visit(this, data);
 
482
        }
 
483
 
 
484
        public TypePattern parameterizeWith(Map arg0, World w) {
 
485
                return this;
 
486
        }
 
487
}
 
488
 
 
489
/**
 
490
 * This type represents a type pattern of '*' but with an annotation specified, e.g. '@Color *'
 
491
 */
 
492
class AnyWithAnnotationTypePattern extends TypePattern {
 
493
 
 
494
        public AnyWithAnnotationTypePattern(AnnotationTypePattern atp) {
 
495
                super(false, false);
 
496
                annotationPattern = atp;
 
497
        }
 
498
 
 
499
        public Object accept(PatternNodeVisitor visitor, Object data) {
 
500
                return visitor.visit(this, data);
 
501
        }
 
502
 
 
503
        protected boolean couldEverMatchSameTypesAs(TypePattern other) {
 
504
                return true;
 
505
        }
 
506
 
 
507
        protected boolean matchesExactly(ResolvedType type) {
 
508
                annotationPattern.resolve(type.getWorld());
 
509
                boolean b = false;
 
510
                if (type.temporaryAnnotationTypes != null) {
 
511
                        b = annotationPattern.matches(type, type.temporaryAnnotationTypes).alwaysTrue();
 
512
                } else {
 
513
                        b = annotationPattern.matches(type).alwaysTrue();
 
514
                }
 
515
                return b;
 
516
        }
 
517
 
 
518
        protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) {
 
519
                annotationPattern.resolve(type.getWorld());
 
520
                return annotationPattern.matches(annotatedType).alwaysTrue();
 
521
        }
 
522
 
 
523
        public FuzzyBoolean matchesInstanceof(ResolvedType type) {
 
524
                if (Modifier.isFinal(type.getModifiers())) {
 
525
                        return FuzzyBoolean.fromBoolean(matchesExactly(type));
 
526
                }
 
527
                return FuzzyBoolean.MAYBE;
 
528
        }
 
529
 
 
530
        public TypePattern parameterizeWith(Map typeVariableMap, World w) {
 
531
                AnyWithAnnotationTypePattern ret = new AnyWithAnnotationTypePattern(this.annotationPattern.parameterizeWith(
 
532
                                typeVariableMap, w));
 
533
                ret.copyLocationFrom(this);
 
534
                return ret;
 
535
        }
 
536
 
 
537
        public void write(DataOutputStream s) throws IOException {
 
538
                s.writeByte(TypePattern.ANY_WITH_ANNO);
 
539
                annotationPattern.write(s);
 
540
                writeLocation(s);
 
541
        }
 
542
 
 
543
        public static TypePattern read(VersionedDataInputStream s, ISourceContext c) throws IOException {
 
544
                AnnotationTypePattern annPatt = AnnotationTypePattern.read(s, c);
 
545
                AnyWithAnnotationTypePattern ret = new AnyWithAnnotationTypePattern(annPatt);
 
546
                ret.readLocation(c, s);
 
547
                return ret;
 
548
        }
 
549
 
 
550
        // public FuzzyBoolean matches(IType type, MatchKind kind) {
 
551
        // return FuzzyBoolean.YES;
 
552
        // }
 
553
 
 
554
        protected boolean matchesSubtypes(ResolvedType type) {
 
555
                return true;
 
556
        }
 
557
 
 
558
        public boolean isStar() {
 
559
                return false;
 
560
        }
 
561
 
 
562
        public String toString() {
 
563
                return annotationPattern + " *";
 
564
        }
 
565
 
 
566
        public boolean equals(Object obj) {
 
567
                if (!(obj instanceof AnyWithAnnotationTypePattern))
 
568
                        return false;
 
569
                AnyWithAnnotationTypePattern awatp = (AnyWithAnnotationTypePattern) obj;
 
570
                return (annotationPattern.equals(awatp.annotationPattern));
 
571
        }
 
572
 
 
573
        public int hashCode() {
 
574
                return annotationPattern.hashCode();
 
575
        }
 
576
}
 
577
 
 
578
class NoTypePattern extends TypePattern {
 
579
 
 
580
        public NoTypePattern() {
 
581
                super(false, false, new TypePatternList());
 
582
        }
 
583
 
 
584
        /*
 
585
         * (non-Javadoc)
 
586
         * 
 
587
         * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern)
 
588
         */
 
589
        protected boolean couldEverMatchSameTypesAs(TypePattern other) {
 
590
                return false;
 
591
        }
 
592
 
 
593
        /**
 
594
         * @see org.aspectj.weaver.patterns.TypePattern#matchesExactly(IType)
 
595
         */
 
596
        protected boolean matchesExactly(ResolvedType type) {
 
597
                return false;
 
598
        }
 
599
 
 
600
        protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) {
 
601
                return false;
 
602
        }
 
603
 
 
604
        /**
 
605
         * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType)
 
606
         */
 
607
        public FuzzyBoolean matchesInstanceof(ResolvedType type) {
 
608
                return FuzzyBoolean.NO;
 
609
        }
 
610
 
 
611
        /**
 
612
         * @see org.aspectj.weaver.patterns.PatternNode#write(DataOutputStream)
 
613
         */
 
614
        public void write(DataOutputStream s) throws IOException {
 
615
                s.writeByte(NO_KEY);
 
616
        }
 
617
 
 
618
        /**
 
619
         * @see org.aspectj.weaver.patterns.TypePattern#matches(IType, MatchKind)
 
620
         */
 
621
        // public FuzzyBoolean matches(IType type, MatchKind kind) {
 
622
        // return FuzzyBoolean.YES;
 
623
        // }
 
624
        /**
 
625
         * @see org.aspectj.weaver.patterns.TypePattern#matchesSubtypes(IType)
 
626
         */
 
627
        protected boolean matchesSubtypes(ResolvedType type) {
 
628
                return false;
 
629
        }
 
630
 
 
631
        public boolean isStar() {
 
632
                return false;
 
633
        }
 
634
 
 
635
        public String toString() {
 
636
                return "<nothing>";
 
637
        }// FIXME AV - bad! toString() cannot be parsed back (not idempotent)
 
638
 
 
639
        /*
 
640
         * (non-Javadoc)
 
641
         * 
 
642
         * @see java.lang.Object#equals(java.lang.Object)
 
643
         */
 
644
        public boolean equals(Object obj) {
 
645
                return (obj instanceof NoTypePattern);
 
646
        }
 
647
 
 
648
        /*
 
649
         * (non-Javadoc)
 
650
         * 
 
651
         * @see java.lang.Object#hashCode()
 
652
         */
 
653
        public int hashCode() {
 
654
                return 17 * 37 * 37;
 
655
        }
 
656
 
 
657
        public Object accept(PatternNodeVisitor visitor, Object data) {
 
658
                return visitor.visit(this, data);
 
659
        }
 
660
 
 
661
        public TypePattern parameterizeWith(Map arg0, World w) {
 
662
                return this;
 
663
        }
 
664
}