001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package test.dwarfclassview.kindresolver;
043:
044: import org.netbeans.modules.cnd.dwarfdump.dwarf.DwarfEntry;
045: import org.netbeans.modules.cnd.dwarfdump.dwarfconsts.TAG;
046: import test.dwarfclassview.consts.KIND;
047:
048: public class KindResolver {
049: public static KIND resolveKind(DwarfEntry entry) {
050: KIND result = null;
051:
052: if (entry == null) {
053: return null;
054: }
055:
056: TAG dwarfKind = entry.getKind();
057:
058: DwarfEntry specification = entry.getSpecification();
059:
060: if (specification != null) {
061: entry = specification;
062: }
063:
064: DwarfEntry parent = entry.getParent();
065:
066: if (parent != null) {
067: if (parent.getKind().equals(TAG.DW_TAG_structure_type)
068: || parent.getKind().equals(TAG.DW_TAG_class_type)) {
069: result = InClassKindResolver.resolveKind(dwarfKind,
070: entry.getName(), parent.getName());
071: }
072: } else {
073: result = GlobalScopeKindResolver.resolveKind(dwarfKind);
074: }
075:
076: if (result == null) {
077: result = resolveKind(dwarfKind);
078: }
079:
080: return result;
081: }
082:
083: private static KIND resolveKind(TAG dwarfKind) {
084: switch (dwarfKind) {
085: case DW_TAG_structure_type:
086: case DW_TAG_class_type:
087: case DW_TAG_SUN_struct_template:
088: case DW_TAG_SUN_class_template:
089: return KIND.CLASS;
090: case DW_TAG_namespace:
091: return KIND.NAMESPACE;
092: case DW_TAG_subprogram:
093: case DW_TAG_SUN_function_template:
094: return KIND.FUNCTION;
095: case DW_TAG_member:
096: return KIND.MEMBER;
097: case DW_TAG_variable:
098: return KIND.VARIABLE;
099: case DW_TAG_typedef:
100: return KIND.TYPEDEF;
101: case DW_TAG_enumeration_type:
102: return KIND.ENUM;
103: case DW_TAG_union_type:
104: return KIND.UNION;
105: case DW_TAG_enumerator:
106: return KIND.ENUMITEM;
107: default:
108: return KIND.UNHANDLED_KIND;
109: }
110: }
111:
112: public static boolean kindSupposeParams(KIND kind) {
113: if (kind == null) {
114: return true;
115: }
116:
117: switch (kind) {
118: case CONSTRUCTOR:
119: case DESTRUCTOR:
120: case FUNCTION:
121: case METHOD:
122: case OPERATOR:
123: return true;
124: default:
125: return false;
126: }
127: }
128:
129: }
|