blob: bbdfe70e8d5505f0ce0c540e63741a4adedf812c (
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
48
49
50
51
|
/*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation 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:
* IBM Corporation - initial implementation
*******************************************************************************/
package org.eclipse.cdt.launch.internal;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
/**
* A property tester that determines if a file is an executable.
*/
public class CPropertyTester extends PropertyTester {
/* (non-Javadoc)
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
*/
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if ("isExecutable".equals(property)) { //$NON-NLS-1$
return isExecutable(receiver);
}
return false;
}
/**
* Look for executable.
* @return true if the target resource has a <code>main</code> method,
* <code>false</code> otherwise.
*/
private boolean isExecutable(Object receiver) {
ICElement celement = null;
if (receiver instanceof IAdaptable) {
IResource res = (IResource) ((IAdaptable)receiver).getAdapter(IResource.class);
if (res != null) {
celement = CoreModel.getDefault().create(res);
}
}
return (celement != null && celement instanceof IBinary);
}
}
|