/**
 *  Copyright (c) 2015-2016 Angelo ZERR.
 *  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:
 *  Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
 */
package ts.eclipse.ide.angular2.internal.cli;

import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;

/**
 * Angular CLI Property tester.
 *
 */
public class AngularCLIPropertyTester extends PropertyTester {

	private static final String IS_ANGULAR_CLI_PROJECT_PROPERTY = "isAngularCLIProject";

	public AngularCLIPropertyTester() {
		// Default constructor is required for property tester
	}

	/**
	 * Tests if the receiver object is a project is a Angular CLI project and
	 * false otherwise.
	 * 
	 * @return true if the receiver object is a project is a Angular CLI project
	 *         and false otherwise.
	 */
	@Override
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
		if (IS_ANGULAR_CLI_PROJECT_PROPERTY.equals(property)) {
			return testIsAngularCLIProject(receiver);
		}
		return false;
	}

	private boolean testIsAngularCLIProject(Object receiver) {
		if (receiver instanceof IAdaptable) {
			IProject project = (IProject) ((IAdaptable) receiver).getAdapter(IProject.class);
			if (project != null) {
				return AngularCLIProject.isAngularCLIProject(project);
			}
		}
		return false;
	}
}

@@ -533,23 +533,24 @@
 ources.I
-Project
+Resource
 ;%0D%0Aimpor
@@ -1474,35 +1474,38 @@
 %09%09%09I
-Project project = (IProject
+Resource resource = (IResource
 ) ((
@@ -1538,23 +1538,24 @@
 dapter(I
-Project
+Resource
 .class);
@@ -1563,23 +1563,24 @@
 %0A%09%09%09if (
-project
+resource
  != null
@@ -1633,23 +1633,37 @@
 Project(
-p
+resource.getP
 roject
+()
 );%0D%0A%09%09%09%7D

Return true if resource belong to angular CLI project.