ifdirective.java

来自「配置文件」· Java 代码 · 共 84 行

JAVA
84
字号
/**
 * Copyright (c) 2003-2005 Craig Setera
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 */
package eclipseme.core.internal.preprocessor.directive;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.dom.Comment;

import eclipseme.core.internal.preprocessor.Directive;
import eclipseme.core.model.SymbolDefinitionSet;

/**
 * Defines an identifier, thus making its value "true" when it 
 * is referenced in further expressions.
 * <p />
 * Copyright (c) 2003-2005 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.4 $
 * <br>
 * $Date: 2006/11/12 01:11:01 $
 * <br>
 * @author Craig Setera
 */
public class IfDirective extends AbstractIfDirective {
	/**
	 * Construct a new instance.
	 * 
	 * @param resource
	 * @param comment
	 * @param commentText
	 */
	public IfDirective(
		IResource resource,
		Comment comment, 
		String commentText) 
	{
		super(resource, comment, commentText);
	}

	/**
	 * @see eclipseme.core.internal.preprocessor.Directive#getType()
	 */
	public int getType() {
		return TYPE_IF;
	}

	/**
	 * @see eclipseme.core.internal.preprocessor.Directive#isEnabled(eclipseme.core.model.SymbolDefinitionSet, IProgressMonitor)
	 */
	public boolean isEnabled(SymbolDefinitionSet identifiers, IProgressMonitor monitor) {
		return isEnabledByExpression(identifiers, monitor);
	}

	/**
	 * @see eclipseme.core.internal.preprocessor.directive.AbstractIfDirective#isValid()
	 */
	protected boolean isValid() throws CoreException {
		return validateChildren();
	}

	/**
	 * @see eclipseme.core.internal.preprocessor.directive.AbstractIfDirective#validateChild(eclipseme.core.internal.preprocessor.Directive)
	 */
	protected boolean validateChild(Directive directive) throws CoreException {
		boolean valid = 
			(directive.getType() == Directive.TYPE_ELIFDEF) ||
			(directive.getType() == Directive.TYPE_ELIFNDEF);
		
		if  (valid) {
			createProblemMarker(IMarker.SEVERITY_ERROR, "#elifdef and #elifndef cannot be associated with #if");
		}
		
		return valid;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?