1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

set the filename for include directives

This commit is contained in:
Alain Magloire 2004-09-10 19:24:30 +00:00
parent 51c39598f1
commit abf050d657
4 changed files with 32 additions and 4 deletions

View file

@ -45,7 +45,7 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
public abstract IDirective[] getBuiltins();
public IRule[] getRules() {
IDirective[] stmts = getDirectives();
IDirective[] stmts = getDirectives(true);
List array = new ArrayList(stmts.length);
for (int i = 0; i < stmts.length; i++) {
if (stmts[i] instanceof IRule) {
@ -111,7 +111,7 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
}
public IMacroDefinition[] getMacroDefinitions() {
IDirective[] stmts = getDirectives();
IDirective[] stmts = getDirectives(true);
List array = new ArrayList(stmts.length);
for (int i = 0; i < stmts.length; i++) {
if (stmts[i] instanceof IMacroDefinition) {

View file

@ -28,6 +28,10 @@ public abstract class Parent extends Directive implements IParent {
super(parent);
}
public IDirective[] getDirectives(boolean expand) {
return getDirectives();
}
public IDirective[] getDirectives() {
children.trimToSize();
return (IDirective[]) children.toArray(new IDirective[0]);

View file

@ -18,6 +18,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Stack;
import java.util.StringTokenizer;
@ -765,6 +766,21 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
return new InferenceRule(this, new Target(tgt));
}
public IDirective[] getDirectives(boolean expand) {
if (!expand) {
return getDirectives();
}
IDirective[] dirs = getDirectives();
ArrayList list = new ArrayList(Arrays.asList(dirs));
for (int i = 0; i < dirs.length; ++i) {
if (dirs[i] instanceof Include) {
Include include = (Include)dirs[i];
list.addAll(Arrays.asList(include.getDirectives()));
}
}
return (IDirective[]) list.toArray(new IDirective[list.size()]);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.makefile.AbstractMakefile#getBuiltins()
*/

View file

@ -47,7 +47,11 @@ public class Include extends Parent implements IInclude {
// Try the current directory.
try {
gnu.parse(filenames[i]);
addDirectives(gnu.getStatements());
Directive[] subdirs = gnu.getStatements();
addDirectives(subdirs);
for (int k = 0; k < subdirs.length; ++k) {
subdirs[k].setFilename(filenames[i]);
}
continue;
} catch (IOException e) {
}
@ -56,7 +60,11 @@ public class Include extends Parent implements IInclude {
try {
String filename = dirs[j] + GNUMakefile.FILE_SEPARATOR + filenames[i];
gnu.parse(filename);
addDirectives(gnu.getStatements());
Directive[] subdirs = gnu.getStatements();
addDirectives(subdirs);
for (int k = 0; k < subdirs.length; ++k) {
subdirs[k].setFilename(filename);
}
break;
} catch (IOException e) {
}