cdt/cdt_6_0_x/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
author dadubrow
Thu, 20 Aug 2009 15:14:59 -0500
changeset 74 30678d98b200
parent 52 42077b7eab6e
child 95 fafaec74d446
permissions -rw-r--r--
Bug 9662 - return actual parents when not showing source roots at the top of projects
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     1
/*******************************************************************************
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     3
 * All rights reserved. This program and the accompanying materials
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     4
 * are made available under the terms of the Eclipse Public License v1.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     5
 * which accompanies this distribution, and is available at
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     6
 * http://www.eclipse.org/legal/epl-v10.html
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     7
 *
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     8
 * Contributors:
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     9
 *     IBM Corporation - initial API and implementation
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    10
 *     QNX Software System
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    11
 *******************************************************************************/
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    12
package org.eclipse.cdt.internal.ui;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    13
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    14
import java.util.ArrayList;
52
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
    15
import java.util.Collections;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    16
import java.util.HashMap;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    17
import java.util.List;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    18
import java.util.Map;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    19
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    20
import org.eclipse.core.resources.IContainer;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    21
import org.eclipse.core.resources.IFile;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    22
import org.eclipse.core.resources.IFolder;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    23
import org.eclipse.core.resources.IProject;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    24
import org.eclipse.core.resources.IResource;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    25
import org.eclipse.core.runtime.CoreException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    26
import org.eclipse.jface.viewers.ITreeContentProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    27
import org.eclipse.jface.viewers.Viewer;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    28
import org.eclipse.ui.model.IWorkbenchAdapter;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    29
52
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
    30
import org.eclipse.cdt.core.CCorePlugin;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    31
import org.eclipse.cdt.core.model.CModelException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    32
import org.eclipse.cdt.core.model.CoreModel;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    33
import org.eclipse.cdt.core.model.IArchive;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    34
import org.eclipse.cdt.core.model.IArchiveContainer;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    35
import org.eclipse.cdt.core.model.IBinary;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    36
import org.eclipse.cdt.core.model.IBinaryContainer;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    37
import org.eclipse.cdt.core.model.IBinaryModule;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    38
import org.eclipse.cdt.core.model.ICContainer;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    39
import org.eclipse.cdt.core.model.ICElement;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    40
import org.eclipse.cdt.core.model.ICModel;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    41
import org.eclipse.cdt.core.model.ICProject;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    42
import org.eclipse.cdt.core.model.IInclude;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    43
import org.eclipse.cdt.core.model.IMember;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    44
import org.eclipse.cdt.core.model.INamespace;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    45
import org.eclipse.cdt.core.model.IParent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    46
import org.eclipse.cdt.core.model.ISourceReference;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    47
import org.eclipse.cdt.core.model.ISourceRoot;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    48
import org.eclipse.cdt.core.model.ITranslationUnit;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    49
import org.eclipse.cdt.core.model.IWorkingCopy;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    50
import org.eclipse.cdt.ui.CElementGrouping;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    51
import org.eclipse.cdt.ui.CUIPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    52
import org.eclipse.cdt.ui.IncludesGrouping;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    53
import org.eclipse.cdt.ui.NamespacesGrouping;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    54
 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    55
/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    56
 * A base content provider for C elements. It provides access to the
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    57
 * C element hierarchy without listening to changes in the C model.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    58
 * Use this class when you want to present the C elements
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    59
 * in a modal dialog or wizard.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    60
 * <p>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    61
 * The following C element hierarchy is surfaced by this content provider:
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    62
 * <p>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    63
 * <pre>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    64
C model (<code>ICModel</code>)<br>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    65
   C project (<code>ICProject</code>)<br>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    66
      Source root (<code>ISourceRoot</code>)<br>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    67
      C Container(folders) (<code>ICContainer</code>)<br>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    68
      Translation unit (<code>ITranslationUnit</code>)<br>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    69
      Binary file (<code>IBinary</code>)<br>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    70
      Archive file (<code>IArchive</code>)<br>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    71
      Non C Resource file (<code>Object</code>)<br>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    72
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    73
 * </pre>
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    74
 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    75
public class BaseCElementContentProvider implements ITreeContentProvider {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    76
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    77
	protected static final Object[] NO_CHILDREN= new Object[0];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    78
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    79
	protected boolean fProvideMembers= false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    80
	protected boolean fProvideWorkingCopy= false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    81
	protected boolean fIncludesGrouping= false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    82
	protected boolean fNamespacesGrouping= false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    83
	protected boolean fMemberGrouping= false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    84
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    85
	public BaseCElementContentProvider() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    86
		this(false, false);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    87
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    88
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    89
	public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    90
	    fProvideMembers= provideMembers;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    91
		fProvideWorkingCopy= provideWorkingCopy;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    92
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    93
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    94
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    95
	 * Returns whether the members are provided when asking
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    96
	 * for a TU's children.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    97
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    98
	public boolean getProvideMembers() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    99
		return fProvideMembers;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   100
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   101
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   102
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   103
	 * Returns whether the members are provided when asking
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   104
	 * for a TU's children.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   105
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   106
	public void setProvideMembers(boolean b) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   107
		fProvideMembers= b;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   108
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   109
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   110
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   111
	 * Sets whether the members are provided from
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   112
	 * a working copy of a compilation unit
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   113
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   114
	public void setProvideWorkingCopy(boolean b) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   115
		fProvideWorkingCopy= b;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   116
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   117
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   118
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   119
	 * Returns whether the members are provided
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   120
	 * from a working copy a compilation unit.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   121
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   122
	public boolean getProvideWorkingCopy() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   123
		return fProvideWorkingCopy;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   124
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   125
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   126
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   127
	 * Can elements be group.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   128
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   129
	public boolean areIncludesGroup() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   130
	    return fIncludesGrouping;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   131
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   132
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   133
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   134
	 * Allow Elements to be group.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   135
	 * @param b
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   136
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   137
	public void setIncludesGrouping(boolean b) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   138
	    fIncludesGrouping = b;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   139
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   140
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   141
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   142
	 * Can elements be group.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   143
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   144
	public boolean areNamespacesGroup() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   145
	    return fNamespacesGrouping;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   146
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   147
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   148
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   149
	 * Allow Elements to be group.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   150
	 * @param b
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   151
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   152
	public void setNamespacesGrouping(boolean b) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   153
	    fNamespacesGrouping = b;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   154
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   155
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   156
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   157
	 * @return whether grouping of members is enabled
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   158
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   159
	public boolean isMemberGroupingEnabled() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   160
		return fMemberGrouping;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   161
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   162
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   163
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   164
	 * Enable/disable member grouping by common namespace.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   165
	 * @param enable
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   166
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   167
	public void setMemberGrouping(boolean enable) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   168
		fMemberGrouping = enable;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   169
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   170
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   171
	/* (non-Cdoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   172
	 * Method declared on IContentProvider.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   173
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   174
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   175
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   176
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   177
	/* (non-Cdoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   178
	 * Method declared on IContentProvider.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   179
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   180
	public void dispose() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   181
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   182
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   183
	/* (non-Cdoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   184
	 * Method declared on IStructuredContentProvider.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   185
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   186
	public Object[] getElements(Object parent) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   187
		return getChildren(parent);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   188
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   189
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   190
	/* (non-Cdoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   191
	 * Method declared on ITreeContentProvider.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   192
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   193
	public Object[] getChildren(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   194
		if (!exists(element))
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   195
			return NO_CHILDREN;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   196
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   197
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   198
			if (element instanceof ICModel) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   199
				return  getCProjects((ICModel)element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   200
			} else if  (element instanceof ICProject ) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   201
				return getSourceRoots((ICProject)element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   202
			} else if (element instanceof ICContainer) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   203
				return getCResources((ICContainer)element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   204
			} else if (element instanceof ITranslationUnit) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   205
				// if we want to get the children of a translation unit
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   206
				if (fProvideMembers) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   207
					// if we want to use the working copy of it
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   208
					ITranslationUnit tu = (ITranslationUnit)element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   209
					if (fProvideWorkingCopy){
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   210
						// if it is not already a working copy
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   211
						if (!(element instanceof IWorkingCopy)){
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   212
							// if it has a valid working copy
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   213
							IWorkingCopy copy = tu.findSharedWorkingCopy(CUIPlugin.getDefault().getBufferFactory());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   214
							if (copy != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   215
								tu = copy;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   216
							}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   217
						}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   218
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   219
					return getTranslationUnitChildren(tu);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   220
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   221
			} else if (element instanceof IBinary) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   222
				return ((IBinary)element).getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   223
			} else if (element instanceof IArchive) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   224
				return ((IArchive)element).getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   225
			} else if (element instanceof IBinaryModule) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   226
				return ((IBinaryModule)element).getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   227
			} else if (element instanceof INamespace) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   228
				return getNamespaceChildren((INamespace) element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   229
			} else if (element instanceof ISourceReference  && element instanceof IParent) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   230
				return ((IParent)element).getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   231
			} else if (element instanceof IProject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   232
				return getResources((IProject)element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   233
			} else if (element instanceof IFolder) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   234
				return getResources((IFolder)element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   235
			} else if (element instanceof CElementGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   236
				return ((CElementGrouping)element).getChildren(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   237
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   238
		} catch (CModelException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   239
			//CUIPlugin.log(e);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   240
			return NO_CHILDREN;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   241
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   242
		return NO_CHILDREN;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   243
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   244
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   245
	/* (non-Cdoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   246
	 *
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   247
	 * @see ITreeContentProvider
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   248
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   249
	public boolean hasChildren(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   250
		if (fProvideMembers) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   251
			// assume TUs and binary files are never empty
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   252
			if (element instanceof IBinary || element instanceof ITranslationUnit || element instanceof IArchive) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   253
				return true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   254
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   255
		} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   256
			// don't allow to drill down into a compilation unit or class file
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   257
			if (element instanceof ITranslationUnit || element instanceof IBinary || element instanceof IArchive
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   258
					|| element instanceof IFile) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   259
				return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   260
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   261
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   262
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   263
		if (element instanceof ICProject) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   264
			ICProject cp= (ICProject)element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   265
			if (!cp.getProject().isOpen()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   266
				return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   267
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   268
			return true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   269
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   270
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   271
		if (element instanceof ICContainer) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   272
			ICContainer container= (ICContainer)element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   273
			IResource resource= container.getResource();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   274
			if (resource instanceof IContainer) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   275
				try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   276
					return ((IContainer)resource).members().length > 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   277
				} catch (CoreException exc) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   278
					return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   279
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   280
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   281
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   282
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   283
		if (element instanceof IParent) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   284
			// when we have C children return true, else we fetch all the children
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   285
			if (((IParent)element).hasChildren()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   286
				return true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   287
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   288
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   289
		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   290
		if (element instanceof CElementGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   291
			return true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   292
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   293
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   294
		Object[] children= getChildren(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   295
		return (children != null) && children.length > 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   296
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   297
	 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   298
	/* (non-Cdoc)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   299
	 * Method declared on ITreeContentProvider.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   300
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   301
	public Object getParent(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   302
		if (!exists(element)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   303
			return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   304
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   305
		return internalGetParent(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   306
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   307
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   308
	public Object internalGetParent(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   309
		if (element instanceof IResource) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   310
			IResource parent= ((IResource)element).getParent();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   311
			if (parent != null && parent.isAccessible()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   312
				ICElement cParent= CoreModel.getDefault().create(parent);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   313
				if (cParent != null && cParent.exists()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   314
					return cParent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   315
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   316
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   317
			return parent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   318
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   319
		Object parent = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   320
		if (element instanceof ICElement) {
74
30678d98b200 Bug 9662 - return actual parents when not showing source roots at the top of projects
dadubrow
parents: 52
diff changeset
   321
			if (element instanceof ICContainer && !CCorePlugin.showSourceRootsAtTopOfProject()) {
30678d98b200 Bug 9662 - return actual parents when not showing source roots at the top of projects
dadubrow
parents: 52
diff changeset
   322
				parent = ((ICContainer) element).getResource().getParent();
30678d98b200 Bug 9662 - return actual parents when not showing source roots at the top of projects
dadubrow
parents: 52
diff changeset
   323
			}
30678d98b200 Bug 9662 - return actual parents when not showing source roots at the top of projects
dadubrow
parents: 52
diff changeset
   324
			else
30678d98b200 Bug 9662 - return actual parents when not showing source roots at the top of projects
dadubrow
parents: 52
diff changeset
   325
				parent = ((ICElement)element).getParent(); 
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   326
			// translate working copy parent to original TU,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   327
			// because working copies are never returned by getChildren
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   328
			// this is necessary for proper show-in-target support
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   329
			if (parent instanceof IWorkingCopy) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   330
				parent= ((IWorkingCopy)parent).getOriginalElement();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   331
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   332
		} else if (element instanceof IWorkbenchAdapter) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   333
			parent = ((IWorkbenchAdapter)element).getParent(element);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   334
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   335
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   336
		// if the parent is the default ISourceRoot == ICProject  return the project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   337
		if (parent instanceof ISourceRoot) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   338
			if (isProjectSourceRoot((ISourceRoot)parent)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   339
				parent = ((ISourceRoot)parent).getCProject();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   340
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   341
		} else if (parent instanceof IBinaryContainer || parent instanceof IArchiveContainer) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   342
			// If the virtual container is the parent we must find the legitimate parent.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   343
			if (element instanceof ICElement) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   344
				IResource res = ((ICElement)element).getResource();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   345
				if (res != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   346
					parent = internalGetParent(res);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   347
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   348
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   349
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   350
		if (parent instanceof INamespace && fNamespacesGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   351
			final INamespace namespace = (INamespace)parent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   352
			final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(), namespace, fMemberGrouping);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   353
			if (grouping.getNamespaces().length > 2) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   354
				parent = grouping;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   355
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   356
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   357
		if (parent instanceof IMember && fMemberGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   358
			final IMember member = (IMember)parent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   359
			final String ns = getElementNamespace(member);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   360
			if (ns != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   361
				Object parentParent = member.getParent();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   362
				if (parentParent instanceof INamespace && fNamespacesGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   363
					final INamespace namespace = (INamespace)parent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   364
					final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(), namespace);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   365
					if (grouping.getNamespaces().length > 2) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   366
						parentParent = grouping;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   367
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   368
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   369
				return new MembersGrouping(parentParent, ns);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   370
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   371
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   372
		// if we are doing grouping for the includes return the grouping container.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   373
		if (element instanceof IInclude && fIncludesGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   374
			parent = new IncludesGrouping(((IInclude)element).getTranslationUnit());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   375
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   376
		return parent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   377
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   378
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   379
	protected Object[] getCProjects(ICModel cModel) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   380
		Object[] objects = cModel.getCProjects();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   381
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   382
			Object[] nonC = cModel.getNonCResources();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   383
			if (nonC.length > 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   384
				objects = concatenate(objects, nonC);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   385
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   386
		} catch (CModelException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   387
			//
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   388
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   389
		return objects;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   390
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   391
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   392
	protected Object[] getSourceRoots(ICProject cproject) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   393
		if (!cproject.getProject().isOpen())
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   394
			return NO_CHILDREN;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   395
			
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   396
		List<ICElement> list= new ArrayList<ICElement>();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   397
		ICElement[] children = cproject.getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   398
		for (int i= 0; i < children.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   399
			ICElement child = children[i];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   400
			if (child instanceof ISourceRoot && child.getResource().getType() == IResource.PROJECT) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   401
				// Was a source root at the project, get the children of this element
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   402
				ICElement[] c2 = ((ISourceRoot)child).getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   403
				for (int k = 0; k < c2.length; ++k)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   404
					list.add(c2[k]);
52
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   405
			} else if (CCorePlugin.showSourceRootsAtTopOfProject()) {
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   406
				list.add(child);
52
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   407
			} else if (child instanceof ISourceRoot && 
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   408
						child.getResource().getParent().equals(cproject.getProject())) {	
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   409
				list.add(child);
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   410
			}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   411
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   412
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   413
		Object[] objects = list.toArray();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   414
		Object[] nonC = cproject.getNonCResources();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   415
		if (nonC != null && nonC.length > 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   416
			nonC = filterNonCResources(nonC, cproject);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   417
			objects = concatenate(objects, nonC);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   418
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   419
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   420
		return objects;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   421
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   422
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   423
	protected Object[] getTranslationUnitChildren(ITranslationUnit unit) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   424
		Object[] children = unit.getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   425
		if (fIncludesGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   426
			boolean hasInclude = false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   427
			ArrayList<Object> list = new ArrayList<Object>(children.length);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   428
			for (int i = 0; i < children.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   429
				if (!(children[i] instanceof IInclude)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   430
					list.add(children[i]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   431
				} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   432
					hasInclude = true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   433
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   434
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   435
			if (hasInclude) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   436
				list.add (0, new IncludesGrouping(unit));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   437
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   438
			children = list.toArray();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   439
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   440
		Map<String, NamespacesGrouping> nsmap = new HashMap<String, NamespacesGrouping>();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   441
		if (fNamespacesGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   442
			// check if there is another namespace with the same name for the same parent
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   443
			List<Object> list = new ArrayList<Object>(children.length);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   444
			for (int i = 0; i < children.length; ++i) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   445
				if (children[i] instanceof INamespace) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   446
					INamespace n1 = (INamespace)children[i];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   447
					NamespacesGrouping namespacesGrouping = nsmap.get(n1.getElementName());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   448
					if (namespacesGrouping == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   449
						namespacesGrouping = new NamespacesGrouping(unit, n1, fMemberGrouping);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   450
						if (namespacesGrouping.getNamespaces().length > 1) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   451
							nsmap.put(n1.getElementName(), namespacesGrouping);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   452
							list.add(namespacesGrouping);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   453
						} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   454
							list.add(children[i]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   455
						}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   456
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   457
				} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   458
					list.add(children[i]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   459
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   460
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   461
			children = list.toArray();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   462
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   463
		if (fMemberGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   464
			// check if there is another member with the same namespace for the same parent
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   465
			List<Object> list = new ArrayList<Object>(children.length);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   466
			Map<String, MembersGrouping> map = new HashMap<String, MembersGrouping>();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   467
			for (int i = 0; i < children.length; ++i) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   468
				if (children[i] instanceof IMember) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   469
					final ICElement member = (ICElement)children[i];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   470
					String namespace = getElementNamespace(member);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   471
					MembersGrouping memberGrouping = map.get(namespace);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   472
					if (memberGrouping == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   473
						memberGrouping = new MembersGrouping(unit, namespace);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   474
						map.put(namespace, memberGrouping);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   475
						list.add(memberGrouping);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   476
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   477
				} else if (fNamespacesGrouping && children[i] instanceof INamespace) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   478
					if (!nsmap.containsKey(((INamespace) children[i]).getElementName())) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   479
						list.add(children[i]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   480
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   481
				} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   482
					list.add(children[i]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   483
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   484
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   485
			children = list.toArray();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   486
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   487
		return children;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   488
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   489
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   490
	protected Object[] getNamespaceChildren(IParent element) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   491
		Object[] children = element.getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   492
		if (fMemberGrouping) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   493
			// check if there is another member with the same namespace for the same parent
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   494
			List<Object> list = new ArrayList<Object>(children.length);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   495
			Map<String, MembersGrouping> map = new HashMap<String, MembersGrouping>();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   496
			for (int i = 0; i < children.length; ++i) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   497
				if (children[i] instanceof IMember) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   498
					final ICElement member = (ICElement)children[i];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   499
					String namespace = getElementNamespace(member);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   500
					MembersGrouping memberGrouping = map.get(namespace);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   501
					if (memberGrouping == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   502
						memberGrouping = new MembersGrouping(element, namespace);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   503
						map.put(namespace, memberGrouping);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   504
						list.add(memberGrouping);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   505
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   506
				} else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   507
					list.add(children[i]);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   508
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   509
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   510
			children = list.toArray();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   511
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   512
		return children;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   513
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   514
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   515
	private static String getElementNamespace(ICElement member) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   516
		String name = member.getElementName();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   517
		int idx = name.lastIndexOf("::"); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   518
		if (idx < 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   519
			return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   520
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   521
		return name.substring(0, idx);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   522
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   523
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   524
	protected Object[] getCResources(ICContainer container) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   525
		Object[] objects = null;
52
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   526
		ICElement[] children = container.getChildren();
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   527
		List<ICElement> missingElements = Collections.emptyList();
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   528
		if (!CCorePlugin.showSourceRootsAtTopOfProject()) {
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   529
			missingElements = getMissingElements(container, children);
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   530
		}
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   531
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   532
			objects = container.getNonCResources();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   533
			if (objects.length > 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   534
				objects = filterNonCResources(objects, container.getCProject());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   535
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   536
		} catch (CModelException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   537
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   538
		if (objects == null || objects.length == 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   539
			return children;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   540
		}
52
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   541
		Object[] result = concatenate(children, objects);
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   542
		return concatenate(result, missingElements.toArray());
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   543
	}
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   544
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   545
	private List<ICElement> getMissingElements(ICContainer container, ICElement[] elements) {
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   546
		// nested source roots may be filtered out below the project root, 
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   547
		// we need to find them to add them back in
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   548
		List<ICElement> missingElements = new ArrayList<ICElement>();
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   549
		try {
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   550
			List<IResource> missingContainers = new ArrayList<IResource>();
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   551
			IResource[] allChildren = ((IContainer) container.getResource()).members();
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   552
			for (IResource child : allChildren) {
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   553
				if (!(child instanceof IContainer))
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   554
					continue;
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   555
				boolean found = false;
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   556
				for (ICElement element : elements) {
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   557
					if (element.getResource().equals(child)) {
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   558
						found = true;
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   559
						break;
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   560
					}
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   561
				}
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   562
				if (!found)
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   563
					missingContainers.add(child);
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   564
			}
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   565
			for (IResource resource : missingContainers) {
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   566
				ICElement element = container.getCProject().findElement(resource.getFullPath());
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   567
				if (element != null)
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   568
					missingElements.add(element);
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   569
			}
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   570
		} catch (CoreException e1) {
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   571
		}
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   572
		return missingElements;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   573
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   574
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   575
	protected Object[] getResources(IProject project) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   576
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   577
			return project.members();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   578
		} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   579
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   580
		return NO_CHILDREN;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   581
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   582
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   583
	protected Object[] getResources(IFolder folder) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   584
		ICProject cproject = CoreModel.getDefault().create(folder.getProject());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   585
		Object[] members = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   586
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   587
			members = folder.members();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   588
		} catch (CoreException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   589
			//
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   590
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   591
		if (members == null || members.length == 0) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   592
			return NO_CHILDREN;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   593
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   594
		return filterNonCResources(members, cproject);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   595
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   596
	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   597
	private Object[] filterNonCResources(Object[] objects, ICProject cproject) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   598
		ICElement[] binaries = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   599
		ICElement[] archives = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   600
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   601
			binaries = getBinaries(cproject);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   602
			archives = getArchives(cproject);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   603
		} catch (CModelException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   604
			archives = binaries = new ICElement[0];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   605
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   606
		ISourceRoot[] roots = null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   607
		try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   608
			roots = cproject.getSourceRoots();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   609
		} catch (CModelException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   610
			roots = new ISourceRoot[0];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   611
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   612
		List<Object> nonCResources = new ArrayList<Object>(objects.length);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   613
		for (int i= 0; i < objects.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   614
			Object o= objects[i];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   615
			// A folder can also be a source root in the following case
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   616
			// Project
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   617
			//  + src <- source folder
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   618
			//    + excluded <- excluded from class path
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   619
			//      + included  <- a new source folder.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   620
			// Included is a member of excluded, but since it is rendered as a source
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   621
			// folder we have to exclude it as a normal child.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   622
			if (o instanceof IFolder) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   623
				IFolder folder = (IFolder)o;
52
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   624
				ISourceRoot root = null;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   625
				for (int j = 0; j < roots.length; j++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   626
					if (roots[j].getPath().equals(folder.getFullPath())) {
52
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   627
						root = roots[j];
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   628
						break;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   629
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   630
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   631
				// it is a sourceRoot skip it.
52
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   632
				if (root != null) {
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   633
					if (CCorePlugin.showSourceRootsAtTopOfProject())
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   634
						continue;
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   635
					else
42077b7eab6e Second merge to proper cdt_6_0 branch for CDT bugs 181020, 279844, & Carbide bugs 6152 & 9031.
timkelly
parents: 51
diff changeset
   636
						o = root;
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   637
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   638
			} else if (o instanceof IFile){
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   639
				boolean found = false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   640
				for (int j = 0; j < binaries.length; j++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   641
					IResource res = binaries[j].getResource();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   642
					if (o.equals(res)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   643
						o = binaries[j];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   644
						found = true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   645
						break;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   646
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   647
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   648
				if (!found) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   649
					for (int j = 0; j < archives.length; j++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   650
						IResource res = archives[j].getResource();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   651
						if (o.equals(res)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   652
							o = archives[j];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   653
							break;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   654
						}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   655
					}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   656
				}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   657
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   658
			nonCResources.add(o);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   659
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   660
		return nonCResources.toArray();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   661
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   662
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   663
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   664
	 * Note: This method is for internal use only. Clients should not call this method.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   665
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   666
	protected boolean isProjectSourceRoot(ISourceRoot root) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   667
		IResource resource= root.getResource();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   668
		return (resource instanceof IProject);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   669
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   670
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   671
	protected boolean exists(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   672
		if (element == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   673
			return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   674
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   675
		if (element instanceof IResource) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   676
			return ((IResource)element).exists();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   677
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   678
		if (element instanceof ICElement) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   679
			return ((ICElement)element).exists();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   680
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   681
		return true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   682
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   683
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   684
	protected IBinary[] getBinaries(ICProject cproject) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   685
		IBinaryContainer container = cproject.getBinaryContainer();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   686
		return getBinaries(container);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   687
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   688
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   689
	protected IBinary[] getBinaries(IBinaryContainer container) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   690
		ICElement[] celements = container.getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   691
		ArrayList<IBinary> list = new ArrayList<IBinary>(celements.length);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   692
		for (int i = 0; i < celements.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   693
			if (celements[i] instanceof IBinary) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   694
				IBinary bin = (IBinary)celements[i];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   695
				list.add(bin);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   696
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   697
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   698
		IBinary[] bins = new IBinary[list.size()];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   699
		list.toArray(bins);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   700
		return bins;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   701
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   702
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   703
	protected IArchive[] getArchives(ICProject cproject) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   704
		IArchiveContainer container = cproject.getArchiveContainer();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   705
		return getArchives(container);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   706
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   707
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   708
	protected IArchive[] getArchives(IArchiveContainer container) throws CModelException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   709
		ICElement[] celements = container.getChildren();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   710
		ArrayList<IArchive> list = new ArrayList<IArchive>(celements.length);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   711
		for (int i = 0; i < celements.length; i++) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   712
			if (celements[i] instanceof IArchive) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   713
				IArchive ar = (IArchive)celements[i];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   714
				list.add(ar);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   715
			}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   716
		}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   717
		IArchive[] ars = new IArchive[list.size()];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   718
		list.toArray(ars);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   719
		return ars;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   720
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   721
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   722
	/**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   723
	 * Note: This method is for internal use only. Clients should not call this method.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   724
	 */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   725
	protected static Object[] concatenate(Object[] a1, Object[] a2) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   726
		int a1Len = a1.length;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   727
		int a2Len = a2.length;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   728
		Object[] res = new Object[a1Len + a2Len];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   729
		System.arraycopy(a1, 0, res, 0, a1Len);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   730
		System.arraycopy(a2, 0, res, a1Len, a2Len);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   731
		return res;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   732
	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   733
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   734
}