mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
Cosmetics
This commit is contained in:
parent
e35e32e8b0
commit
5c400704fb
5 changed files with 166 additions and 230 deletions
|
@ -38,7 +38,6 @@ import org.eclipse.cdt.make.core.makefile.ITargetRule;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class AbstractMakefile extends Parent implements IMakefile {
|
public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
|
|
||||||
private URI filename;
|
private URI filename;
|
||||||
|
|
||||||
public AbstractMakefile(Directive parent) {
|
public AbstractMakefile(Directive parent) {
|
||||||
|
@ -52,9 +51,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IRule[] getRules() {
|
public IRule[] getRules() {
|
||||||
IDirective[] stmts = getDirectives(true);
|
IDirective[] stmts = getDirectives(true);
|
||||||
List<IDirective> array = new ArrayList<IDirective>(stmts.length);
|
List<IDirective> array = new ArrayList<IDirective>(stmts.length);
|
||||||
for (int i = 0; i < stmts.length; i++) {
|
for (IDirective stmt : stmts) {
|
||||||
if (stmts[i] instanceof IRule) {
|
if (stmt instanceof IRule) {
|
||||||
array.add(stmts[i]);
|
array.add(stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IRule[0]);
|
return array.toArray(new IRule[0]);
|
||||||
|
@ -64,9 +63,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IRule[] getRules(String target) {
|
public IRule[] getRules(String target) {
|
||||||
IRule[] rules = getRules();
|
IRule[] rules = getRules();
|
||||||
List<IRule> array = new ArrayList<IRule>(rules.length);
|
List<IRule> array = new ArrayList<IRule>(rules.length);
|
||||||
for (int i = 0; i < rules.length; i++) {
|
for (IRule rule : rules) {
|
||||||
if (rules[i].getTarget().equals(target)) {
|
if (rule.getTarget().equals(target)) {
|
||||||
array.add(rules[i]);
|
array.add(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IRule[0]);
|
return array.toArray(new IRule[0]);
|
||||||
|
@ -76,9 +75,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IInferenceRule[] getInferenceRules() {
|
public IInferenceRule[] getInferenceRules() {
|
||||||
IRule[] rules = getRules();
|
IRule[] rules = getRules();
|
||||||
List<IRule> array = new ArrayList<IRule>(rules.length);
|
List<IRule> array = new ArrayList<IRule>(rules.length);
|
||||||
for (int i = 0; i < rules.length; i++) {
|
for (IRule rule : rules) {
|
||||||
if (rules[i] instanceof IInferenceRule) {
|
if (rule instanceof IInferenceRule) {
|
||||||
array.add(rules[i]);
|
array.add(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IInferenceRule[0]);
|
return array.toArray(new IInferenceRule[0]);
|
||||||
|
@ -88,9 +87,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IInferenceRule[] getInferenceRules(String target) {
|
public IInferenceRule[] getInferenceRules(String target) {
|
||||||
IInferenceRule[] irules = getInferenceRules();
|
IInferenceRule[] irules = getInferenceRules();
|
||||||
List<IInferenceRule> array = new ArrayList<IInferenceRule>(irules.length);
|
List<IInferenceRule> array = new ArrayList<IInferenceRule>(irules.length);
|
||||||
for (int i = 0; i < irules.length; i++) {
|
for (IInferenceRule irule : irules) {
|
||||||
if (irules[i].getTarget().equals(target)) {
|
if (irule.getTarget().equals(target)) {
|
||||||
array.add(irules[i]);
|
array.add(irule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IInferenceRule[0]);
|
return array.toArray(new IInferenceRule[0]);
|
||||||
|
@ -100,9 +99,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public ITargetRule[] getTargetRules() {
|
public ITargetRule[] getTargetRules() {
|
||||||
IRule[] trules = getRules();
|
IRule[] trules = getRules();
|
||||||
List<IRule> array = new ArrayList<IRule>(trules.length);
|
List<IRule> array = new ArrayList<IRule>(trules.length);
|
||||||
for (int i = 0; i < trules.length; i++) {
|
for (IRule trule : trules) {
|
||||||
if (trules[i] instanceof ITargetRule) {
|
if (trule instanceof ITargetRule) {
|
||||||
array.add(trules[i]);
|
array.add(trule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new ITargetRule[0]);
|
return array.toArray(new ITargetRule[0]);
|
||||||
|
@ -112,9 +111,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public ITargetRule[] getTargetRules(String target) {
|
public ITargetRule[] getTargetRules(String target) {
|
||||||
ITargetRule[] trules = getTargetRules();
|
ITargetRule[] trules = getTargetRules();
|
||||||
List<ITargetRule> array = new ArrayList<ITargetRule>(trules.length);
|
List<ITargetRule> array = new ArrayList<ITargetRule>(trules.length);
|
||||||
for (int i = 0; i < trules.length; i++) {
|
for (ITargetRule trule : trules) {
|
||||||
if (trules[i].getTarget().equals(target)) {
|
if (trule.getTarget().equals(target)) {
|
||||||
array.add(trules[i]);
|
array.add(trule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new ITargetRule[0]);
|
return array.toArray(new ITargetRule[0]);
|
||||||
|
@ -124,9 +123,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IMacroDefinition[] getMacroDefinitions() {
|
public IMacroDefinition[] getMacroDefinitions() {
|
||||||
IDirective[] stmts = getDirectives(true);
|
IDirective[] stmts = getDirectives(true);
|
||||||
List<IDirective> array = new ArrayList<IDirective>(stmts.length);
|
List<IDirective> array = new ArrayList<IDirective>(stmts.length);
|
||||||
for (int i = 0; i < stmts.length; i++) {
|
for (IDirective stmt : stmts) {
|
||||||
if (stmts[i] instanceof IMacroDefinition) {
|
if (stmt instanceof IMacroDefinition) {
|
||||||
array.add(stmts[i]);
|
array.add(stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IMacroDefinition[0]);
|
return array.toArray(new IMacroDefinition[0]);
|
||||||
|
@ -136,9 +135,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IMacroDefinition[] getMacroDefinitions(String name) {
|
public IMacroDefinition[] getMacroDefinitions(String name) {
|
||||||
IMacroDefinition[] variables = getMacroDefinitions();
|
IMacroDefinition[] variables = getMacroDefinitions();
|
||||||
List<IMacroDefinition> array = new ArrayList<IMacroDefinition>(variables.length);
|
List<IMacroDefinition> array = new ArrayList<IMacroDefinition>(variables.length);
|
||||||
for (int i = 0; i < variables.length; i++) {
|
for (IMacroDefinition variable : variables) {
|
||||||
if (variables[i].getName().equals(name)) {
|
if (variable.getName().equals(name)) {
|
||||||
array.add(variables[i]);
|
array.add(variable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IMacroDefinition[0]);
|
return array.toArray(new IMacroDefinition[0]);
|
||||||
|
@ -148,9 +147,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IMacroDefinition[] getBuiltinMacroDefinitions() {
|
public IMacroDefinition[] getBuiltinMacroDefinitions() {
|
||||||
IDirective[] stmts = getBuiltins();
|
IDirective[] stmts = getBuiltins();
|
||||||
List<IDirective> array = new ArrayList<IDirective>(stmts.length);
|
List<IDirective> array = new ArrayList<IDirective>(stmts.length);
|
||||||
for (int i = 0; i < stmts.length; i++) {
|
for (IDirective stmt : stmts) {
|
||||||
if (stmts[i] instanceof IMacroDefinition) {
|
if (stmt instanceof IMacroDefinition) {
|
||||||
array.add(stmts[i]);
|
array.add(stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IMacroDefinition[0]);
|
return array.toArray(new IMacroDefinition[0]);
|
||||||
|
@ -160,9 +159,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IMacroDefinition[] getBuiltinMacroDefinitions(String name) {
|
public IMacroDefinition[] getBuiltinMacroDefinitions(String name) {
|
||||||
IMacroDefinition[] variables = getBuiltinMacroDefinitions();
|
IMacroDefinition[] variables = getBuiltinMacroDefinitions();
|
||||||
List<IMacroDefinition> array = new ArrayList<IMacroDefinition>(variables.length);
|
List<IMacroDefinition> array = new ArrayList<IMacroDefinition>(variables.length);
|
||||||
for (int i = 0; i < variables.length; i++) {
|
for (IMacroDefinition variable : variables) {
|
||||||
if (variables[i].getName().equals(name)) {
|
if (variable.getName().equals(name)) {
|
||||||
array.add(variables[i]);
|
array.add(variable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IMacroDefinition[0]);
|
return array.toArray(new IMacroDefinition[0]);
|
||||||
|
@ -171,9 +170,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IInferenceRule[] getBuiltinInferenceRules() {
|
public IInferenceRule[] getBuiltinInferenceRules() {
|
||||||
IDirective[] stmts = getBuiltins();
|
IDirective[] stmts = getBuiltins();
|
||||||
List<IDirective> array = new ArrayList<IDirective>(stmts.length);
|
List<IDirective> array = new ArrayList<IDirective>(stmts.length);
|
||||||
for (int i = 0; i < stmts.length; i++) {
|
for (IDirective stmt : stmts) {
|
||||||
if (stmts[i] instanceof IInferenceRule) {
|
if (stmt instanceof IInferenceRule) {
|
||||||
array.add(stmts[i]);
|
array.add(stmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IInferenceRule[0]);
|
return array.toArray(new IInferenceRule[0]);
|
||||||
|
@ -182,9 +181,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile {
|
||||||
public IInferenceRule[] getBuiltinInferenceRules(String target) {
|
public IInferenceRule[] getBuiltinInferenceRules(String target) {
|
||||||
IInferenceRule[] irules = getBuiltinInferenceRules();
|
IInferenceRule[] irules = getBuiltinInferenceRules();
|
||||||
List<IInferenceRule> array = new ArrayList<IInferenceRule>(irules.length);
|
List<IInferenceRule> array = new ArrayList<IInferenceRule>(irules.length);
|
||||||
for (int i = 0; i < irules.length; i++) {
|
for (IInferenceRule irule : irules) {
|
||||||
if (irules[i].getTarget().equals(target)) {
|
if (irule.getTarget().equals(target)) {
|
||||||
array.add(irules[i]);
|
array.add(irule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.toArray(new IInferenceRule[0]);
|
return array.toArray(new IInferenceRule[0]);
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.cdt.make.core.makefile.IMakefileReaderProvider;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class NullMakefile extends AbstractMakefile {
|
public class NullMakefile extends AbstractMakefile {
|
||||||
|
|
||||||
public final static IDirective[] EMPTY_DIRECTIVES = new IDirective[0];
|
public final static IDirective[] EMPTY_DIRECTIVES = new IDirective[0];
|
||||||
|
|
||||||
public NullMakefile() {
|
public NullMakefile() {
|
||||||
|
@ -59,36 +58,22 @@ public class NullMakefile extends AbstractMakefile {
|
||||||
return new String();
|
return new String();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.core.makefile.IMakefile#parse(java.io.Reader)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void parse(String name, Reader makefile) throws IOException {
|
public void parse(String name, Reader makefile) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.core.makefile.IMakefile#getMakefileReaderProvider()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IMakefileReaderProvider getMakefileReaderProvider() {
|
public IMakefileReaderProvider getMakefileReaderProvider() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public void parse(String name, IMakefileReaderProvider makefileReaderProvider) throws IOException {
|
||||||
* @see org.eclipse.cdt.make.core.makefile.IMakefile#parse(java.lang.String, org.eclipse.cdt.make.core.makefile.IMakefileReaderProvider)
|
|
||||||
*/
|
|
||||||
public void parse(String name,
|
|
||||||
IMakefileReaderProvider makefileReaderProvider) throws IOException {
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void parse(URI fileURI, Reader makefile) throws IOException {
|
public void parse(URI fileURI, Reader makefile) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.core.makefile.IMakefile#parse(java.net.URI, org.eclipse.cdt.make.core.makefile.IMakefileReaderProvider)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void parse(URI fileURI,
|
public void parse(URI fileURI, IMakefileReaderProvider makefileReaderProvider) throws IOException {
|
||||||
IMakefileReaderProvider makefileReaderProvider) throws IOException {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,13 +72,12 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
||||||
|
|
||||||
public static String PATH_SEPARATOR = System.getProperty("path.separator", ":"); //$NON-NLS-1$ //$NON-NLS-2$
|
public static String PATH_SEPARATOR = System.getProperty("path.separator", ":"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
public static String FILE_SEPARATOR = System.getProperty("file.separator", "/"); //$NON-NLS-1$ //$NON-NLS-2$
|
public static String FILE_SEPARATOR = System.getProperty("file.separator", "/"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
String[] includeDirectories = new String[0];
|
private String[] includeDirectories = new String[0];
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
IDirective[] builtins = new IDirective[]{
|
private IDirective[] builtins = new IDirective[]{
|
||||||
new AutomaticVariable(this, "@", MakefileMessages.getString("GNUMakefile.automaticVariable.at")),
|
new AutomaticVariable(this, "@", MakefileMessages.getString("GNUMakefile.automaticVariable.at")),
|
||||||
new AutomaticVariable(this, "%", MakefileMessages.getString("GNUMakefile.automaticVariable.percent")),
|
new AutomaticVariable(this, "%", MakefileMessages.getString("GNUMakefile.automaticVariable.percent")),
|
||||||
new AutomaticVariable(this, "<", MakefileMessages.getString("GNUMakefile.automaticVariable.less")),
|
new AutomaticVariable(this, "<", MakefileMessages.getString("GNUMakefile.automaticVariable.less")),
|
||||||
|
@ -113,8 +112,9 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
||||||
try {
|
try {
|
||||||
final IFileStore store = EFS.getStore(fileURI);
|
final IFileStore store = EFS.getStore(fileURI);
|
||||||
final IFileInfo info = store.fetchInfo();
|
final IFileInfo info = store.fetchInfo();
|
||||||
if (!info.exists() || info.isDirectory())
|
if (!info.exists() || info.isDirectory()) {
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
|
}
|
||||||
|
|
||||||
reader = new MakefileReader(new InputStreamReader(
|
reader = new MakefileReader(new InputStreamReader(
|
||||||
store.openInputStream(EFS.NONE, null)));
|
store.openInputStream(EFS.NONE, null)));
|
||||||
|
@ -802,13 +802,11 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile {
|
||||||
}
|
}
|
||||||
IDirective[] dirs = getDirectives();
|
IDirective[] dirs = getDirectives();
|
||||||
ArrayList<IDirective> list = new ArrayList<IDirective>(Arrays.asList(dirs));
|
ArrayList<IDirective> list = new ArrayList<IDirective>(Arrays.asList(dirs));
|
||||||
for (int i = 0; i < dirs.length; ++i) {
|
for (IDirective dir : dirs) {
|
||||||
if (dirs[i] instanceof Include) {
|
if (dir instanceof Include) {
|
||||||
Include include = (Include)dirs[i];
|
IDirective[] includedMakefiles = ((Include)dir).getDirectives();
|
||||||
IDirective[] includedMakefiles = include.getDirectives();
|
for (IDirective includedMakefile : includedMakefiles) {
|
||||||
for (int j = 0; j < includedMakefiles.length; ++j) {
|
list.addAll(Arrays.asList(((IMakefile)includedMakefile).getDirectives()));
|
||||||
IMakefile includedMakefile = (IMakefile)includedMakefiles[j];
|
|
||||||
list.addAll(Arrays.asList(includedMakefile.getDirectives()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,17 +63,13 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PosixMakefile extends AbstractMakefile {
|
public class PosixMakefile extends AbstractMakefile {
|
||||||
|
private IDirective[] builtins = new IDirective[0];
|
||||||
IDirective[] builtins = new IDirective[0];
|
|
||||||
private IMakefileReaderProvider makefileReaderProvider;
|
private IMakefileReaderProvider makefileReaderProvider;
|
||||||
|
|
||||||
public PosixMakefile() {
|
public PosixMakefile() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.core.makefile.IMakefile#getMakefileReaderProvider()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IMakefileReaderProvider getMakefileReaderProvider() {
|
public IMakefileReaderProvider getMakefileReaderProvider() {
|
||||||
return makefileReaderProvider;
|
return makefileReaderProvider;
|
||||||
|
@ -84,9 +80,6 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
parse(URIUtil.toURI(name), new MakefileReader(reader));
|
parse(URIUtil.toURI(name), new MakefileReader(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.core.makefile.IMakefile#parse(java.net.URI, org.eclipse.cdt.make.core.makefile.IMakefileReaderProvider)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void parse(URI fileURI,
|
public void parse(URI fileURI,
|
||||||
IMakefileReaderProvider makefileReaderProvider) throws IOException {
|
IMakefileReaderProvider makefileReaderProvider) throws IOException {
|
||||||
|
@ -133,9 +126,9 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
cmd.setLines(startLine, endLine);
|
cmd.setLines(startLine, endLine);
|
||||||
// The command is added to the rules
|
// The command is added to the rules
|
||||||
if (rules != null) {
|
if (rules != null) {
|
||||||
for (int i = 0; i < rules.length; i++) {
|
for (Rule rule : rules) {
|
||||||
rules[i].addDirective(cmd);
|
rule.addDirective(cmd);
|
||||||
rules[i].setEndLine(endLine);
|
rule.setEndLine(endLine);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -149,9 +142,9 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
Comment cmt = new Comment(this, line.substring(pound + 1));
|
Comment cmt = new Comment(this, line.substring(pound + 1));
|
||||||
cmt.setLines(startLine, endLine);
|
cmt.setLines(startLine, endLine);
|
||||||
if (rules != null) {
|
if (rules != null) {
|
||||||
for (int i = 0; i < rules.length; i++) {
|
for (Rule rule : rules) {
|
||||||
rules[i].addDirective(cmt);
|
rule.addDirective(cmt);
|
||||||
rules[i].setEndLine(endLine);
|
rule.setEndLine(endLine);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addDirective(cmt);
|
addDirective(cmt);
|
||||||
|
@ -170,9 +163,9 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
Directive empty = new EmptyLine(this);
|
Directive empty = new EmptyLine(this);
|
||||||
empty.setLines(startLine, endLine);
|
empty.setLines(startLine, endLine);
|
||||||
if (rules != null) {
|
if (rules != null) {
|
||||||
for (int i = 0; i < rules.length; i++) {
|
for (Rule rule : rules) {
|
||||||
rules[i].addDirective(empty);
|
rule.addDirective(empty);
|
||||||
rules[i].setEndLine(endLine);
|
rule.setEndLine(endLine);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addDirective(empty);
|
addDirective(empty);
|
||||||
|
@ -214,9 +207,9 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
// 8- Target Rule ?
|
// 8- Target Rule ?
|
||||||
if (PosixMakefileUtil.isTargetRule(line)) {
|
if (PosixMakefileUtil.isTargetRule(line)) {
|
||||||
TargetRule[] trules = parseTargetRule(line);
|
TargetRule[] trules = parseTargetRule(line);
|
||||||
for (int i = 0; i < trules.length; i++) {
|
for (TargetRule trule : trules) {
|
||||||
trules[i].setLines(startLine, endLine);
|
trule.setLines(startLine, endLine);
|
||||||
addDirective(trules[i]);
|
addDirective(trule);
|
||||||
}
|
}
|
||||||
rules = trules;
|
rules = trules;
|
||||||
continue;
|
continue;
|
||||||
|
@ -233,9 +226,6 @@ public class PosixMakefile extends AbstractMakefile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.make.internal.core.makefile.AbstractMakefile#getBuiltins()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IDirective[] getBuiltins() {
|
public IDirective[] getBuiltins() {
|
||||||
return builtins;
|
return builtins;
|
||||||
|
|
|
@ -39,34 +39,20 @@ import org.eclipse.ui.IEditorPart;
|
||||||
* MakefileCompletionProcessor
|
* MakefileCompletionProcessor
|
||||||
*/
|
*/
|
||||||
public class MakefileCompletionProcessor implements IContentAssistProcessor {
|
public class MakefileCompletionProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple content assist tip closer. The tip is valid in a range
|
* Simple content assist tip closer. The tip is valid in a range
|
||||||
* of 5 characters around its popup location.
|
* of 5 characters around its pop-up location.
|
||||||
*/
|
*/
|
||||||
protected static class Validator implements IContextInformationValidator, IContextInformationPresenter {
|
protected static class Validator implements IContextInformationValidator, IContextInformationPresenter {
|
||||||
|
|
||||||
protected int fInstallOffset;
|
protected int fInstallOffset;
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IContextInformationValidator#isContextInformationValid(int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isContextInformationValid(int offset) {
|
public boolean isContextInformationValid(int offset) {
|
||||||
return Math.abs(fInstallOffset - offset) < 5;
|
return Math.abs(fInstallOffset - offset) < 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void install(IContextInformation info, ITextViewer viewer, int offset) {
|
public void install(IContextInformation info, ITextViewer viewer, int offset) {
|
||||||
fInstallOffset = offset;
|
fInstallOffset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int, TextPresentation)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updatePresentation(int documentPosition, TextPresentation presentation) {
|
public boolean updatePresentation(int documentPosition, TextPresentation presentation) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -74,10 +60,6 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DirectiveComparator implements Comparator<Object> {
|
public class DirectiveComparator implements Comparator<Object> {
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(Object o1, Object o2) {
|
public int compare(Object o1, Object o2) {
|
||||||
String name1;
|
String name1;
|
||||||
|
@ -117,9 +99,6 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor {
|
||||||
fManager = MakeUIPlugin.getDefault().getWorkingCopyManager();
|
fManager = MakeUIPlugin.getDefault().getWorkingCopyManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
|
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
|
||||||
WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset);
|
WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset);
|
||||||
|
@ -139,16 +118,16 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor {
|
||||||
ArrayList<ICompletionProposal> proposalList = new ArrayList<ICompletionProposal>(statements.length);
|
ArrayList<ICompletionProposal> proposalList = new ArrayList<ICompletionProposal>(statements.length);
|
||||||
|
|
||||||
// iterate over all the different categories
|
// iterate over all the different categories
|
||||||
for (int i = 0; i < statements.length; i++) {
|
for (IDirective statement : statements) {
|
||||||
String name = null;
|
String name = null;
|
||||||
Image image = null;
|
Image image = null;
|
||||||
String infoString = "";//getContentInfoString(name); //$NON-NLS-1$
|
String infoString = "";//getContentInfoString(name); //$NON-NLS-1$
|
||||||
if (statements[i] instanceof IMacroDefinition) {
|
if (statement instanceof IMacroDefinition) {
|
||||||
name = ((IMacroDefinition) statements[i]).getName();
|
name = ((IMacroDefinition) statement).getName();
|
||||||
image = imageMacro;
|
image = imageMacro;
|
||||||
infoString = ((IMacroDefinition)statements[i]).getValue().toString();
|
infoString = ((IMacroDefinition)statement).getValue().toString();
|
||||||
} else if (statements[i] instanceof IRule) {
|
} else if (statement instanceof IRule) {
|
||||||
name = ((IRule) statements[i]).getTarget().toString();
|
name = ((IRule) statement).getTarget().toString();
|
||||||
image = imageTarget;
|
image = imageTarget;
|
||||||
infoString = name;
|
infoString = name;
|
||||||
}
|
}
|
||||||
|
@ -173,9 +152,6 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor {
|
||||||
return proposals;
|
return proposals;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
|
public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
|
||||||
WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset);
|
WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset);
|
||||||
|
@ -184,11 +160,11 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor {
|
||||||
ArrayList<String> contextList = new ArrayList<String>();
|
ArrayList<String> contextList = new ArrayList<String>();
|
||||||
if (macro) {
|
if (macro) {
|
||||||
IDirective[] statements = makefile.getMacroDefinitions();
|
IDirective[] statements = makefile.getMacroDefinitions();
|
||||||
for (int i = 0; i < statements.length; i++) {
|
for (IDirective statement : statements) {
|
||||||
if (statements[i] instanceof IMacroDefinition) {
|
if (statement instanceof IMacroDefinition) {
|
||||||
String name = ((IMacroDefinition) statements[i]).getName();
|
String name = ((IMacroDefinition) statement).getName();
|
||||||
if (name != null && name.equals(wordPart.toString())) {
|
if (name != null && name.equals(wordPart.toString())) {
|
||||||
String value = ((IMacroDefinition) statements[i]).getValue().toString();
|
String value = ((IMacroDefinition) statement).getValue().toString();
|
||||||
if (value != null && value.length() > 0) {
|
if (value != null && value.length() > 0) {
|
||||||
contextList.add(value);
|
contextList.add(value);
|
||||||
}
|
}
|
||||||
|
@ -196,11 +172,11 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
statements = makefile.getBuiltinMacroDefinitions();
|
statements = makefile.getBuiltinMacroDefinitions();
|
||||||
for (int i = 0; i < statements.length; i++) {
|
for (IDirective statement : statements) {
|
||||||
if (statements[i] instanceof IMacroDefinition) {
|
if (statement instanceof IMacroDefinition) {
|
||||||
String name = ((IMacroDefinition) statements[i]).getName();
|
String name = ((IMacroDefinition) statement).getName();
|
||||||
if (name != null && name.equals(wordPart.toString())) {
|
if (name != null && name.equals(wordPart.toString())) {
|
||||||
String value = ((IMacroDefinition) statements[i]).getValue().toString();
|
String value = ((IMacroDefinition) statement).getValue().toString();
|
||||||
if (value != null && value.length() > 0) {
|
if (value != null && value.length() > 0) {
|
||||||
contextList.add(value);
|
contextList.add(value);
|
||||||
}
|
}
|
||||||
|
@ -218,33 +194,21 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getCompletionProposalAutoActivationCharacters() {
|
public char[] getCompletionProposalAutoActivationCharacters() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getContextInformationAutoActivationCharacters() {
|
public char[] getContextInformationAutoActivationCharacters() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getErrorMessage() {
|
public String getErrorMessage() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IContextInformationValidator getContextInformationValidator() {
|
public IContextInformationValidator getContextInformationValidator() {
|
||||||
return fValidator;
|
return fValidator;
|
||||||
|
|
Loading…
Add table
Reference in a new issue