Skip to main content
summaryrefslogtreecommitdiffstats
blob: e69e02759a882ee5a4618f2bdd3760c5e31d0b8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*******************************************************************************
 * Copyright (c) 2008 Nokia and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Nokia - Initial API and implementation
 *******************************************************************************/

package org.eclipse.cdt.debug.internal.ui.views.executables;

import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.debug.core.executables.Executable;
import org.eclipse.cdt.ui.CElementContentProvider;
import org.eclipse.core.runtime.IPath;

public class SourceFilesContentProvider extends CElementContentProvider {

	public SourceFilesContentProvider(SourceFilesViewer viewer) {
		super(true, true);
	}

	@Override
	public boolean hasChildren(Object element) {
		if (element instanceof ITranslationUnit) {
			IPath path = ((ITranslationUnit) element).getLocation();
			if (path != null && !path.toFile().exists())
				return false;
		}
		return super.hasChildren(element);
	}

	public Object[] getElements(Object inputElement) {
		if (inputElement instanceof Executable) {
			Executable executable = (Executable) inputElement;
			ITranslationUnit[] sourceFiles = executable.getSourceFiles();
			if (sourceFiles.length == 0)
				return new String[] { "No source files found in " + executable.getName() };
			else
				return sourceFiles;
		}
		return new Object[] {};
	}

}

Back to the top