From b2448e8582ff540ad3d83da2db30a9b0e7c6cd5a Mon Sep 17 00:00:00 2001 From: Sebastian Bauer Date: Fri, 1 Mar 2013 21:14:01 +0100 Subject: [PATCH] Introduce automatic variables in the Makefile editor. Added a special class for automatic variables. Use some instances for built-in variables of a makefile allowing to choose from them in the content assist. Change-Id: I653a5fa536afc5f9e3112314720928a4f22692c7 Reviewed-on: https://git.eclipse.org/r/10786 IP-Clean: Andrew Gvozdev Tested-by: Andrew Gvozdev Reviewed-by: Andrew Gvozdev --- .../makefile/MakeFileResources.properties | 6 ++++ .../core/makefile/gnu/AutomaticVariable.java | 33 +++++++++++++++++++ .../core/makefile/gnu/GNUMakefile.java | 10 +++++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/AutomaticVariable.java diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakeFileResources.properties b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakeFileResources.properties index 2a8f7604e86..cda473dc708 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakeFileResources.properties +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/MakeFileResources.properties @@ -22,3 +22,9 @@ MakefileValidator.error.endefMissingOverrideDefine=endef missing [override] defi MakefileValidator.error.unknownDirective=unknow directive MakefileValidator.error.noMatchingEndifForCondition=No matching endif for condition MakefileValidator.error.noMatchingEndefForOverrideDefine=No matching endef for [override] define +GNUMakefile.automatic.at=Target of the rule +GNUMakefile.automatic.lt=First prerequisite of the rule +GNUMakefile.automatic.star=Stem with which an implicit rule matches +GNUMakefile.automatic.qm=All prerequisites that are newer than the target +GNUMakefile.automatic.percent=Target member name, when the target is an archive member +GNUMakefile.automatic.up=All prerequisites diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/AutomaticVariable.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/AutomaticVariable.java new file mode 100644 index 00000000000..df6862b510f --- /dev/null +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/AutomaticVariable.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2013 Sebastian Bauer 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: + * Sebastian Bauer - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.make.internal.core.makefile.gnu; + +import org.eclipse.cdt.make.internal.core.makefile.Directive; + + +/** + * Represents an automatic variable. Automatic variables are implicit and + * computed for each rule that is applied. + * + * @author Sebastian Bauer + * @see "http://www.gnu.org/software/make/manual/make.html#Automatic-Variables" + */ +public class AutomaticVariable extends VariableDefinition { + + public AutomaticVariable(Directive parent, String name, String description) { + super(parent, name, new StringBuffer(description)); + } + + @Override + public boolean isAutomatic() { + return true; + } +} diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefile.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefile.java index 295144cdbff..4d2b4842f95 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefile.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/gnu/GNUMakefile.java @@ -36,6 +36,7 @@ import org.eclipse.cdt.make.internal.core.makefile.EmptyLine; import org.eclipse.cdt.make.internal.core.makefile.IgnoreRule; import org.eclipse.cdt.make.internal.core.makefile.InferenceRule; import org.eclipse.cdt.make.internal.core.makefile.MakeFileConstants; +import org.eclipse.cdt.make.internal.core.makefile.MakefileMessages; import org.eclipse.cdt.make.internal.core.makefile.MakefileReader; import org.eclipse.cdt.make.internal.core.makefile.PosixRule; import org.eclipse.cdt.make.internal.core.makefile.PreciousRule; @@ -76,7 +77,14 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { public static String FILE_SEPARATOR = System.getProperty("file.separator", "/"); //$NON-NLS-1$ //$NON-NLS-2$ String[] includeDirectories = new String[0]; - IDirective[] builtins = new IDirective[0]; + IDirective[] builtins = new IDirective[]{ + new AutomaticVariable(this, "<", MakefileMessages.getString("GNUMakefile.automatic.lt")),//$NON-NLS-1$//$NON-NLS-2$ + new AutomaticVariable(this, "*", MakefileMessages.getString("GNUMakefile.automatic.star")),//$NON-NLS-1$//$NON-NLS-2$ + new AutomaticVariable(this, "@", MakefileMessages.getString("GNUMakefile.automatic.at")),//$NON-NLS-1$//$NON-NLS-2$ + new AutomaticVariable(this, "?", MakefileMessages.getString("GNUMakefile.automatic.qm")),//$NON-NLS-1$//$NON-NLS-2$ + new AutomaticVariable(this, "%", MakefileMessages.getString("GNUMakefile.automatic.percent")),//$NON-NLS-1$//$NON-NLS-2$ + new AutomaticVariable(this, "^", MakefileMessages.getString("GNUMakefile.automatic.up")),//$NON-NLS-1$//$NON-NLS-2$ + }; private IMakefileReaderProvider makefileReaderProvider; public GNUMakefile() {