mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 298758: Errors when hovering includes in makefile.
This commit is contained in:
parent
852f5e9d31
commit
a799c0c964
1 changed files with 35 additions and 26 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2010 QNX Software Systems 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
|
||||
|
@ -48,6 +48,8 @@ import org.eclipse.cdt.make.internal.core.makefile.TargetRule;
|
|||
import org.eclipse.cdt.make.internal.core.makefile.Util;
|
||||
import org.eclipse.cdt.make.internal.core.makefile.posix.PosixMakefileUtil;
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileInfo;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.filesystem.URIUtil;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -100,8 +102,13 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
MakefileReader reader;
|
||||
if (makefileReaderProvider == null) {
|
||||
try {
|
||||
final IFileStore store = EFS.getStore(fileURI);
|
||||
final IFileInfo info = store.fetchInfo();
|
||||
if (!info.exists() || info.isDirectory())
|
||||
throw new IOException();
|
||||
|
||||
reader = new MakefileReader(new InputStreamReader(
|
||||
EFS.getStore(fileURI).openInputStream(EFS.NONE, null)));
|
||||
store.openInputStream(EFS.NONE, null)));
|
||||
} catch (CoreException e) {
|
||||
MakeCorePlugin.log(e);
|
||||
throw new IOException(e.getMessage());
|
||||
|
@ -120,8 +127,8 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
protected void parse(URI fileURI, MakefileReader reader) throws IOException {
|
||||
String line;
|
||||
Rule[] rules = null;
|
||||
Stack conditions = new Stack();
|
||||
Stack defines = new Stack();
|
||||
Stack<Directive> conditions = new Stack<Directive>();
|
||||
Stack<VariableDefinition> defines = new Stack<VariableDefinition>();
|
||||
int startLine = 0;
|
||||
int endLine = 0;
|
||||
|
||||
|
@ -138,7 +145,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
if (GNUMakefileUtil.isEndef(line)) {
|
||||
// We should have a "define" for a "endef".
|
||||
if (!defines.empty()) {
|
||||
VariableDefinition def = (VariableDefinition) defines.pop();
|
||||
VariableDefinition def = defines.pop();
|
||||
def.setEndLine(endLine);
|
||||
}
|
||||
Endef endef = new Endef(this);
|
||||
|
@ -161,7 +168,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
|
||||
// We still in a define.
|
||||
if (!defines.empty()) {
|
||||
VariableDefinition def = (VariableDefinition) defines.peek();
|
||||
VariableDefinition def = defines.peek();
|
||||
StringBuffer sb = def.getValue();
|
||||
if (sb.length() > 0) {
|
||||
sb.append('\n');
|
||||
|
@ -179,9 +186,9 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
continue;
|
||||
} else if (rules != null) {
|
||||
// The command is added to the rules
|
||||
for (int i = 0; i < rules.length; i++) {
|
||||
rules[i].addDirective(cmd);
|
||||
rules[i].setEndLine(endLine);
|
||||
for (Rule rule : rules) {
|
||||
rule.addDirective(cmd);
|
||||
rule.setEndLine(endLine);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -196,9 +203,9 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
cmt.setLines(startLine, endLine);
|
||||
if (rules != null) {
|
||||
// The comment is added to the rules.
|
||||
for (int i = 0; i < rules.length; i++) {
|
||||
rules[i].addDirective(cmt);
|
||||
rules[i].setEndLine(endLine);
|
||||
for (Rule rule : rules) {
|
||||
rule.addDirective(cmt);
|
||||
rule.setEndLine(endLine);
|
||||
}
|
||||
} else {
|
||||
addDirective(conditions, cmt);
|
||||
|
@ -218,9 +225,9 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
empty.setLines(startLine, endLine);
|
||||
if (rules != null) {
|
||||
// The EmptyLine is added to the rules.
|
||||
for (int i = 0; i < rules.length; i++) {
|
||||
rules[i].addDirective(empty);
|
||||
rules[i].setEndLine(endLine);
|
||||
for (Rule rule : rules) {
|
||||
rule.addDirective(empty);
|
||||
rule.setEndLine(endLine);
|
||||
}
|
||||
} else {
|
||||
addDirective(conditions, empty);
|
||||
|
@ -304,9 +311,9 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
// - GNU Static Target rule ?
|
||||
if (GNUMakefileUtil.isStaticTargetRule(line)) {
|
||||
StaticTargetRule[] srules = parseStaticTargetRule(line);
|
||||
for (int i = 0; i < srules.length; i++) {
|
||||
srules[i].setLines(startLine, endLine);
|
||||
addDirective(conditions, srules[i]);
|
||||
for (StaticTargetRule srule : srules) {
|
||||
srule.setLines(startLine, endLine);
|
||||
addDirective(conditions, srule);
|
||||
}
|
||||
rules = srules;
|
||||
continue;
|
||||
|
@ -315,9 +322,9 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
// - Target Rule ?
|
||||
if (GNUMakefileUtil.isGNUTargetRule(line)) {
|
||||
TargetRule[] trules = parseGNUTargetRules(line);
|
||||
for (int i = 0; i < trules.length; i++) {
|
||||
trules[i].setLines(startLine, endLine);
|
||||
addDirective(conditions, trules[i]);
|
||||
for (TargetRule trule : trules) {
|
||||
trule.setLines(startLine, endLine);
|
||||
addDirective(conditions, trule);
|
||||
}
|
||||
rules = trules;
|
||||
continue;
|
||||
|
@ -335,7 +342,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
//validator.validateDirectives(null, getDirectives());
|
||||
}
|
||||
|
||||
private void addDirective(Stack conditions, Directive directive) {
|
||||
private void addDirective(Stack<Directive> conditions, Directive directive) {
|
||||
if (conditions.empty()) {
|
||||
addDirective(directive);
|
||||
} else {
|
||||
|
@ -538,7 +545,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
String[] directories;
|
||||
StringTokenizer st = new StringTokenizer(line);
|
||||
int count = st.countTokens();
|
||||
List dirs = new ArrayList(count);
|
||||
List<String> dirs = new ArrayList<String>(count);
|
||||
if (count > 0) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (count == 0) {
|
||||
|
@ -554,7 +561,7 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
}
|
||||
}
|
||||
}
|
||||
directories = (String[]) dirs.toArray(new String[0]);
|
||||
directories = dirs.toArray(new String[0]);
|
||||
if (pattern == null) {
|
||||
pattern = new String();
|
||||
}
|
||||
|
@ -788,12 +795,13 @@ 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 list = new ArrayList(Arrays.asList(dirs));
|
||||
ArrayList<IDirective> list = new ArrayList<IDirective>(Arrays.asList(dirs));
|
||||
for (int i = 0; i < dirs.length; ++i) {
|
||||
if (dirs[i] instanceof Include) {
|
||||
Include include = (Include)dirs[i];
|
||||
|
@ -804,12 +812,13 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
|||
}
|
||||
}
|
||||
}
|
||||
return (IDirective[]) list.toArray(new IDirective[list.size()]);
|
||||
return list.toArray(new IDirective[list.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.make.internal.core.makefile.AbstractMakefile#getBuiltins()
|
||||
*/
|
||||
@Override
|
||||
public IDirective[] getBuiltins() {
|
||||
return builtins;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue