annotate truffle/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/model/GeneratedPackageElement.java @ 22157:dc83cc1f94f2

Using fully qualified imports
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 16 Sep 2015 11:33:22 +0200
parents 9c8c0937da41
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16763
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
1 /*
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
4 *
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
7 * published by the Free Software Foundation.
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
8 *
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
13 * accompanied this code).
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
14 *
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
15 * You should have received a copy of the GNU General Public License version
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
18 *
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
21 * questions.
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
22 */
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
23 package com.oracle.truffle.dsl.processor.java.model;
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
24
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
25 import java.util.Collections;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
26 import javax.lang.model.element.Element;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
27 import javax.lang.model.element.ElementKind;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
28 import javax.lang.model.element.ElementVisitor;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
29 import javax.lang.model.element.Modifier;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
30 import javax.lang.model.element.Name;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
31 import javax.lang.model.element.PackageElement;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
32 import javax.lang.model.type.TypeMirror;
16763
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
33
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
34 public final class GeneratedPackageElement extends CodeElement<Element> implements PackageElement {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
35
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
36 private final Name qualifiedName;
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
37 private final Name simpleName;
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
38
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
39 public GeneratedPackageElement(String qualifiedName) {
16909
62cfffca9be2 Truffle-DSL: some more performance optimizations.
Christian Humer <christian.humer@gmail.com>
parents: 16763
diff changeset
40 super(Collections.<Modifier> emptySet());
16763
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
41 this.qualifiedName = CodeNames.of(qualifiedName);
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
42 int lastIndex = qualifiedName.lastIndexOf('.');
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
43 if (lastIndex == -1) {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
44 simpleName = CodeNames.of("");
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
45 } else {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
46 simpleName = CodeNames.of(qualifiedName.substring(lastIndex, qualifiedName.length()));
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
47 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
48 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
49
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
50 public TypeMirror asType() {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
51 throw new UnsupportedOperationException();
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
52 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
53
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
54 public ElementKind getKind() {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
55 return ElementKind.PACKAGE;
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
56 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
57
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
58 public <R, P> R accept(ElementVisitor<R, P> v, P p) {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
59 return v.visitPackage(this, p);
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
60 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
61
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
62 public Name getQualifiedName() {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
63 return qualifiedName;
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
64 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
65
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
66 public Name getSimpleName() {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
67 return simpleName;
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
68 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
69
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
70 public boolean isUnnamed() {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
71 return simpleName.toString().equals("");
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
72 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
73
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
74 @Override
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
75 public int hashCode() {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
76 return qualifiedName.hashCode();
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
77 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
78
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
79 @Override
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
80 public boolean equals(Object obj) {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
81 if (obj instanceof PackageElement) {
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
82 return qualifiedName.equals(((PackageElement) obj).getQualifiedName());
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
83 }
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
84 return super.equals(obj);
e6d15134ca86 Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents: 16759
diff changeset
85 }
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 16909
diff changeset
86 }