mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 13:25:45 +02:00
Bug 412247: Makefile Editor: F3 navigation does not work inside conditional directives
This commit is contained in:
parent
2e21d2516d
commit
e404208cac
3 changed files with 34 additions and 26 deletions
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.make.internal.core.makefile;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.make.core.makefile.IDirective;
|
||||
import org.eclipse.cdt.make.core.makefile.IParent;
|
||||
|
@ -29,6 +30,17 @@ public abstract class Parent extends Directive implements IParent {
|
|||
}
|
||||
|
||||
public IDirective[] getDirectives(boolean expand) {
|
||||
if (expand) {
|
||||
List<IDirective> directives = new ArrayList<IDirective>();
|
||||
getDirectives(); // populates children for class Include
|
||||
for (IDirective directive : children) {
|
||||
directives.add(directive);
|
||||
if (directive instanceof Parent) {
|
||||
directives.addAll(Arrays.asList(((Parent) directive).getDirectives(expand)));
|
||||
}
|
||||
}
|
||||
return directives.toArray(new IDirective[directives.size()]);
|
||||
}
|
||||
return getDirectives();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,12 @@ import java.io.InputStreamReader;
|
|||
import java.io.Reader;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||
import org.eclipse.cdt.make.core.makefile.IDirective;
|
||||
import org.eclipse.cdt.make.core.makefile.IMakefile;
|
||||
import org.eclipse.cdt.make.core.makefile.IMakefileReaderProvider;
|
||||
import org.eclipse.cdt.make.core.makefile.gnu.IGNUMakefile;
|
||||
import org.eclipse.cdt.make.internal.core.makefile.AbstractMakefile;
|
||||
|
@ -795,24 +793,6 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
return new InferenceRule(this, new Target(tgt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDirective[] getDirectives(boolean expand) {
|
||||
if (!expand) {
|
||||
return getDirectives();
|
||||
}
|
||||
IDirective[] dirs = getDirectives();
|
||||
ArrayList<IDirective> list = new ArrayList<IDirective>(Arrays.asList(dirs));
|
||||
for (IDirective dir : dirs) {
|
||||
if (dir instanceof Include) {
|
||||
IDirective[] includedMakefiles = ((Include)dir).getDirectives();
|
||||
for (IDirective includedMakefile : includedMakefiles) {
|
||||
list.addAll(Arrays.asList(((IMakefile)includedMakefile).getDirectives()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.toArray(new IDirective[list.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDirective[] getBuiltins() {
|
||||
return builtins;
|
||||
|
|
|
@ -79,9 +79,12 @@ public class Include extends Parent implements IInclude {
|
|||
includeFilePath = includeFilePath.setDevice(device);
|
||||
}
|
||||
try {
|
||||
GNUMakefile gnu = new GNUMakefile();
|
||||
gnu.parse(URIUtil.toURI(includeFilePath), makefileReaderProvider);
|
||||
addDirective(gnu);
|
||||
URI includeURI = URIUtil.toURI(includeFilePath);
|
||||
if (!isAlreadyIncluded(includeURI)) {
|
||||
GNUMakefile gnu = new GNUMakefile();
|
||||
gnu.parse(includeURI, makefileReaderProvider);
|
||||
addDirective(gnu);
|
||||
}
|
||||
continue;
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
@ -95,10 +98,12 @@ public class Include extends Parent implements IInclude {
|
|||
// special case: device prefix is seen as relative path by URI
|
||||
uriPath = '/' + uriPath;
|
||||
}
|
||||
GNUMakefile gnu = new GNUMakefile();
|
||||
URI includeURI = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uriPath, null, null);
|
||||
gnu.parse(includeURI, makefileReaderProvider);
|
||||
addDirective(gnu);
|
||||
if (!isAlreadyIncluded(includeURI)) {
|
||||
GNUMakefile gnu = new GNUMakefile();
|
||||
gnu.parse(includeURI, makefileReaderProvider);
|
||||
addDirective(gnu);
|
||||
}
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
} catch (URISyntaxException exc) {
|
||||
|
@ -108,4 +113,15 @@ public class Include extends Parent implements IInclude {
|
|||
}
|
||||
return super.getDirectives();
|
||||
}
|
||||
|
||||
private boolean isAlreadyIncluded(URI includeURI) {
|
||||
for (IDirective parent = getParent(); parent != null; parent = parent.getParent()) {
|
||||
if (parent instanceof IMakefile) {
|
||||
if (includeURI.equals(((IMakefile) parent).getFileURI())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue