From 5c400704fb7ebfacb8015022f8f4deed78135e4a Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sun, 5 May 2013 07:05:22 -0400 Subject: [PATCH] Cosmetics --- .../core/makefile/AbstractMakefile.java | 187 +++++++++--------- .../internal/core/makefile/NullMakefile.java | 21 +- .../core/makefile/gnu/GNUMakefile.java | 68 ++++--- .../core/makefile/posix/PosixMakefile.java | 36 ++-- .../makefile/MakefileCompletionProcessor.java | 84 +++----- 5 files changed, 166 insertions(+), 230 deletions(-) diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/AbstractMakefile.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/AbstractMakefile.java index 1f9b83a62c1..e93b5bc5f82 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/AbstractMakefile.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/AbstractMakefile.java @@ -38,7 +38,6 @@ import org.eclipse.cdt.make.core.makefile.ITargetRule; */ public abstract class AbstractMakefile extends Parent implements IMakefile { - private URI filename; public AbstractMakefile(Directive parent) { @@ -52,9 +51,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IRule[] getRules() { IDirective[] stmts = getDirectives(true); List array = new ArrayList(stmts.length); - for (int i = 0; i < stmts.length; i++) { - if (stmts[i] instanceof IRule) { - array.add(stmts[i]); + for (IDirective stmt : stmts) { + if (stmt instanceof IRule) { + array.add(stmt); } } return array.toArray(new IRule[0]); @@ -64,9 +63,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IRule[] getRules(String target) { IRule[] rules = getRules(); List array = new ArrayList(rules.length); - for (int i = 0; i < rules.length; i++) { - if (rules[i].getTarget().equals(target)) { - array.add(rules[i]); + for (IRule rule : rules) { + if (rule.getTarget().equals(target)) { + array.add(rule); } } return array.toArray(new IRule[0]); @@ -76,9 +75,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IInferenceRule[] getInferenceRules() { IRule[] rules = getRules(); List array = new ArrayList(rules.length); - for (int i = 0; i < rules.length; i++) { - if (rules[i] instanceof IInferenceRule) { - array.add(rules[i]); + for (IRule rule : rules) { + if (rule instanceof IInferenceRule) { + array.add(rule); } } return array.toArray(new IInferenceRule[0]); @@ -88,9 +87,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IInferenceRule[] getInferenceRules(String target) { IInferenceRule[] irules = getInferenceRules(); List array = new ArrayList(irules.length); - for (int i = 0; i < irules.length; i++) { - if (irules[i].getTarget().equals(target)) { - array.add(irules[i]); + for (IInferenceRule irule : irules) { + if (irule.getTarget().equals(target)) { + array.add(irule); } } return array.toArray(new IInferenceRule[0]); @@ -100,9 +99,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public ITargetRule[] getTargetRules() { IRule[] trules = getRules(); List array = new ArrayList(trules.length); - for (int i = 0; i < trules.length; i++) { - if (trules[i] instanceof ITargetRule) { - array.add(trules[i]); + for (IRule trule : trules) { + if (trule instanceof ITargetRule) { + array.add(trule); } } return array.toArray(new ITargetRule[0]); @@ -112,9 +111,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public ITargetRule[] getTargetRules(String target) { ITargetRule[] trules = getTargetRules(); List array = new ArrayList(trules.length); - for (int i = 0; i < trules.length; i++) { - if (trules[i].getTarget().equals(target)) { - array.add(trules[i]); + for (ITargetRule trule : trules) { + if (trule.getTarget().equals(target)) { + array.add(trule); } } return array.toArray(new ITargetRule[0]); @@ -124,9 +123,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IMacroDefinition[] getMacroDefinitions() { IDirective[] stmts = getDirectives(true); List array = new ArrayList(stmts.length); - for (int i = 0; i < stmts.length; i++) { - if (stmts[i] instanceof IMacroDefinition) { - array.add(stmts[i]); + for (IDirective stmt : stmts) { + if (stmt instanceof IMacroDefinition) { + array.add(stmt); } } return array.toArray(new IMacroDefinition[0]); @@ -136,9 +135,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IMacroDefinition[] getMacroDefinitions(String name) { IMacroDefinition[] variables = getMacroDefinitions(); List array = new ArrayList(variables.length); - for (int i = 0; i < variables.length; i++) { - if (variables[i].getName().equals(name)) { - array.add(variables[i]); + for (IMacroDefinition variable : variables) { + if (variable.getName().equals(name)) { + array.add(variable); } } return array.toArray(new IMacroDefinition[0]); @@ -148,9 +147,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IMacroDefinition[] getBuiltinMacroDefinitions() { IDirective[] stmts = getBuiltins(); List array = new ArrayList(stmts.length); - for (int i = 0; i < stmts.length; i++) { - if (stmts[i] instanceof IMacroDefinition) { - array.add(stmts[i]); + for (IDirective stmt : stmts) { + if (stmt instanceof IMacroDefinition) { + array.add(stmt); } } return array.toArray(new IMacroDefinition[0]); @@ -160,9 +159,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IMacroDefinition[] getBuiltinMacroDefinitions(String name) { IMacroDefinition[] variables = getBuiltinMacroDefinitions(); List array = new ArrayList(variables.length); - for (int i = 0; i < variables.length; i++) { - if (variables[i].getName().equals(name)) { - array.add(variables[i]); + for (IMacroDefinition variable : variables) { + if (variable.getName().equals(name)) { + array.add(variable); } } return array.toArray(new IMacroDefinition[0]); @@ -171,9 +170,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IInferenceRule[] getBuiltinInferenceRules() { IDirective[] stmts = getBuiltins(); List array = new ArrayList(stmts.length); - for (int i = 0; i < stmts.length; i++) { - if (stmts[i] instanceof IInferenceRule) { - array.add(stmts[i]); + for (IDirective stmt : stmts) { + if (stmt instanceof IInferenceRule) { + array.add(stmt); } } return array.toArray(new IInferenceRule[0]); @@ -182,9 +181,9 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { public IInferenceRule[] getBuiltinInferenceRules(String target) { IInferenceRule[] irules = getBuiltinInferenceRules(); List array = new ArrayList(irules.length); - for (int i = 0; i < irules.length; i++) { - if (irules[i].getTarget().equals(target)) { - array.add(irules[i]); + for (IInferenceRule irule : irules) { + if (irule.getTarget().equals(target)) { + array.add(irule); } } return array.toArray(new IInferenceRule[0]); @@ -205,53 +204,28 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { for (int i = 0; i < len; i++) { char c = line.charAt(i); switch(c) { - case '$': - // '$$' --> '$' - if (foundDollar) { - buffer.append(c); - foundDollar = false; - } else { - foundDollar = true; - } - break; - case '(': - case '{': - if (foundDollar) { - inMacro = true; - } else { - buffer.append(c); - } - break; - case ')': - case '}': - if (inMacro) { - String name = macroName.toString(); - if (name.length() > 0) { - IMacroDefinition[] defs = getMacroDefinitions(name); - if (defs.length == 0) { - defs = getBuiltinMacroDefinitions(name); - } - if (defs.length > 0) { - String result = defs[0].getValue().toString(); - if (result.indexOf('$') != -1 && recursive) { - result = expandString(result, recursive); - } - buffer.append(result); - } else { // Do not expand - buffer.append('$').append('(').append(name).append(')'); - } - } - macroName.setLength(0); - inMacro = false; - } else { - buffer.append(c); - } - break; - default: - if (inMacro) { - macroName.append(c); - } else if (foundDollar) { - String name = String.valueOf(c); + case '$': + // '$$' --> '$' + if (foundDollar) { + buffer.append(c); + foundDollar = false; + } else { + foundDollar = true; + } + break; + case '(': + case '{': + if (foundDollar) { + inMacro = true; + } else { + buffer.append(c); + } + break; + case ')': + case '}': + if (inMacro) { + String name = macroName.toString(); + if (name.length() > 0) { IMacroDefinition[] defs = getMacroDefinitions(name); if (defs.length == 0) { defs = getBuiltinMacroDefinitions(name); @@ -262,16 +236,41 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { result = expandString(result, recursive); } buffer.append(result); - } else { - // nothing found - buffer.append('$').append(c); + } else { // Do not expand + buffer.append('$').append('(').append(name).append(')'); } - inMacro = false; - } else { - buffer.append(c); } - foundDollar = false; - break; + macroName.setLength(0); + inMacro = false; + } else { + buffer.append(c); + } + break; + default: + if (inMacro) { + macroName.append(c); + } else if (foundDollar) { + String name = String.valueOf(c); + IMacroDefinition[] defs = getMacroDefinitions(name); + if (defs.length == 0) { + defs = getBuiltinMacroDefinitions(name); + } + if (defs.length > 0) { + String result = defs[0].getValue().toString(); + if (result.indexOf('$') != -1 && recursive) { + result = expandString(result, recursive); + } + buffer.append(result); + } else { + // nothing found + buffer.append('$').append(c); + } + inMacro = false; + } else { + buffer.append(c); + } + foundDollar = false; + break; } } return buffer.toString(); @@ -283,8 +282,8 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { } public void setFileURI(URI filename) { - this.filename = filename; - } + this.filename = filename; + } @Override public IMakefile getMakefile() { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/NullMakefile.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/NullMakefile.java index cdec17a21b2..17924fb2d13 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/NullMakefile.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/NullMakefile.java @@ -34,7 +34,6 @@ import org.eclipse.cdt.make.core.makefile.IMakefileReaderProvider; */ public class NullMakefile extends AbstractMakefile { - public final static IDirective[] EMPTY_DIRECTIVES = new IDirective[0]; public NullMakefile() { @@ -59,36 +58,22 @@ public class NullMakefile extends AbstractMakefile { return new String(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.makefile.IMakefile#parse(java.io.Reader) - */ @Override public void parse(String name, Reader makefile) throws IOException { } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.makefile.IMakefile#getMakefileReaderProvider() - */ @Override public IMakefileReaderProvider getMakefileReaderProvider() { return null; } - /* (non-Javadoc) - * @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 { + public void parse(String name, IMakefileReaderProvider makefileReaderProvider) throws IOException { } @Override 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 - public void parse(URI fileURI, - IMakefileReaderProvider makefileReaderProvider) throws IOException { + public void parse(URI fileURI, IMakefileReaderProvider makefileReaderProvider) throws IOException { } } 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 24fca08a106..3298957ad16 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 @@ -72,21 +72,20 @@ import org.eclipse.core.runtime.CoreException; */ 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 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") - IDirective[] builtins = new IDirective[]{ - new AutomaticVariable(this, "@", MakefileMessages.getString("GNUMakefile.automaticVariable.at")), - new AutomaticVariable(this, "%", MakefileMessages.getString("GNUMakefile.automaticVariable.percent")), - new AutomaticVariable(this, "<", MakefileMessages.getString("GNUMakefile.automaticVariable.less")), - new AutomaticVariable(this, "?", MakefileMessages.getString("GNUMakefile.automaticVariable.question")), - new AutomaticVariable(this, "^", MakefileMessages.getString("GNUMakefile.automaticVariable.carrot")), - new AutomaticVariable(this, "+", MakefileMessages.getString("GNUMakefile.automaticVariable.plus")), - new AutomaticVariable(this, "|", MakefileMessages.getString("GNUMakefile.automaticVariable.pipe")), - new AutomaticVariable(this, "*", MakefileMessages.getString("GNUMakefile.automaticVariable.star")), + private IDirective[] builtins = new IDirective[]{ + new AutomaticVariable(this, "@", MakefileMessages.getString("GNUMakefile.automaticVariable.at")), + new AutomaticVariable(this, "%", MakefileMessages.getString("GNUMakefile.automaticVariable.percent")), + new AutomaticVariable(this, "<", MakefileMessages.getString("GNUMakefile.automaticVariable.less")), + new AutomaticVariable(this, "?", MakefileMessages.getString("GNUMakefile.automaticVariable.question")), + new AutomaticVariable(this, "^", MakefileMessages.getString("GNUMakefile.automaticVariable.carrot")), + new AutomaticVariable(this, "+", MakefileMessages.getString("GNUMakefile.automaticVariable.plus")), + new AutomaticVariable(this, "|", MakefileMessages.getString("GNUMakefile.automaticVariable.pipe")), + new AutomaticVariable(this, "*", MakefileMessages.getString("GNUMakefile.automaticVariable.star")), }; private IMakefileReaderProvider makefileReaderProvider; @@ -113,8 +112,9 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { try { final IFileStore store = EFS.getStore(fileURI); final IFileInfo info = store.fetchInfo(); - if (!info.exists() || info.isDirectory()) + if (!info.exists() || info.isDirectory()) { throw new IOException(); + } reader = new MakefileReader(new InputStreamReader( store.openInputStream(EFS.NONE, null))); @@ -534,20 +534,20 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { } /** - * There are three forms of the "vpath" directive: - * "vpath PATTERN DIRECTORIES" - * Specify the search path DIRECTORIES for file names that match PATTERN. - * - * The search path, DIRECTORIES, is a list of directories to be - * searched, separated by colons (semi-colons on MS-DOS and - * MS-Windows) or blanks, just like the search path used in the `VPATH' variable. - * - * "vpath PATTERN" - * Clear out the search path associated with PATTERN. - * - * "vpath" - * Clear all search paths previously specified with `vpath' directives. - */ + * There are three forms of the "vpath" directive: + * "vpath PATTERN DIRECTORIES" + * Specify the search path DIRECTORIES for file names that match PATTERN. + * + * The search path, DIRECTORIES, is a list of directories to be + * searched, separated by colons (semi-colons on MS-DOS and + * MS-Windows) or blanks, just like the search path used in the `VPATH' variable. + * + * "vpath PATTERN" + * Clear out the search path associated with PATTERN. + * + * "vpath" + * Clear all search paths previously specified with `vpath' directives. + */ protected VPath parseVPath(String line) { String pattern = null; String[] directories; @@ -717,8 +717,8 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { if (index > 0) { type = line.charAt(index - 1); if (type == VariableDefinition.TYPE_SIMPLE_EXPAND - || type == VariableDefinition.TYPE_APPEND - || type == VariableDefinition.TYPE_CONDITIONAL) { + || type == VariableDefinition.TYPE_APPEND + || type == VariableDefinition.TYPE_CONDITIONAL) { separator = index - 1; } else { type = VariableDefinition.TYPE_RECURSIVE_EXPAND; @@ -802,13 +802,11 @@ public class GNUMakefile extends AbstractMakefile implements IGNUMakefile { } 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]; - IDirective[] includedMakefiles = include.getDirectives(); - for (int j = 0; j < includedMakefiles.length; ++j) { - IMakefile includedMakefile = (IMakefile)includedMakefiles[j]; - list.addAll(Arrays.asList(includedMakefile.getDirectives())); + for (IDirective dir : dirs) { + if (dir instanceof Include) { + IDirective[] includedMakefiles = ((Include)dir).getDirectives(); + for (IDirective includedMakefile : includedMakefiles) { + list.addAll(Arrays.asList(((IMakefile)includedMakefile).getDirectives())); } } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/posix/PosixMakefile.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/posix/PosixMakefile.java index 4166b2d4f83..73aef26a65c 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/posix/PosixMakefile.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/makefile/posix/PosixMakefile.java @@ -63,17 +63,13 @@ import org.eclipse.core.runtime.CoreException; */ public class PosixMakefile extends AbstractMakefile { - - IDirective[] builtins = new IDirective[0]; + private IDirective[] builtins = new IDirective[0]; private IMakefileReaderProvider makefileReaderProvider; public PosixMakefile() { super(null); } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.makefile.IMakefile#getMakefileReaderProvider() - */ @Override public IMakefileReaderProvider getMakefileReaderProvider() { return makefileReaderProvider; @@ -84,9 +80,6 @@ public class PosixMakefile extends AbstractMakefile { 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 public void parse(URI fileURI, IMakefileReaderProvider makefileReaderProvider) throws IOException { @@ -133,9 +126,9 @@ public class PosixMakefile extends AbstractMakefile { cmd.setLines(startLine, endLine); // The command is added to the rules if (rules != null) { - 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; } @@ -149,9 +142,9 @@ public class PosixMakefile extends AbstractMakefile { Comment cmt = new Comment(this, line.substring(pound + 1)); cmt.setLines(startLine, endLine); if (rules != null) { - 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(cmt); @@ -170,9 +163,9 @@ public class PosixMakefile extends AbstractMakefile { Directive empty = new EmptyLine(this); empty.setLines(startLine, endLine); if (rules != null) { - 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(empty); @@ -214,9 +207,9 @@ public class PosixMakefile extends AbstractMakefile { // 8- Target Rule ? if (PosixMakefileUtil.isTargetRule(line)) { TargetRule[] trules = parseTargetRule(line); - for (int i = 0; i < trules.length; i++) { - trules[i].setLines(startLine, endLine); - addDirective(trules[i]); + for (TargetRule trule : trules) { + trule.setLines(startLine, endLine); + addDirective(trule); } rules = trules; continue; @@ -233,9 +226,6 @@ public class PosixMakefile extends AbstractMakefile { } } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.internal.core.makefile.AbstractMakefile#getBuiltins() - */ @Override public IDirective[] getBuiltins() { return builtins; diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefileCompletionProcessor.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefileCompletionProcessor.java index 17348d65c9a..96bad03f938 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefileCompletionProcessor.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/text/makefile/MakefileCompletionProcessor.java @@ -39,34 +39,20 @@ import org.eclipse.ui.IEditorPart; * MakefileCompletionProcessor */ public class MakefileCompletionProcessor implements IContentAssistProcessor { - /** * 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 int fInstallOffset; - - /* - * @see IContextInformationValidator#isContextInformationValid(int) - */ @Override public boolean isContextInformationValid(int offset) { return Math.abs(fInstallOffset - offset) < 5; } - - /* - * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int) - */ @Override public void install(IContextInformation info, ITextViewer viewer, int offset) { fInstallOffset = offset; } - - /* - * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int, TextPresentation) - */ @Override public boolean updatePresentation(int documentPosition, TextPresentation presentation) { return false; @@ -74,10 +60,6 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { } public class DirectiveComparator implements Comparator { - - /* (non-Javadoc) - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ @Override public int compare(Object o1, Object o2) { String name1; @@ -117,9 +99,6 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { fManager = MakeUIPlugin.getDefault().getWorkingCopyManager(); } - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int) - */ @Override public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset); @@ -139,16 +118,16 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { ArrayList proposalList = new ArrayList(statements.length); // iterate over all the different categories - for (int i = 0; i < statements.length; i++) { + for (IDirective statement : statements) { String name = null; Image image = null; String infoString = "";//getContentInfoString(name); //$NON-NLS-1$ - if (statements[i] instanceof IMacroDefinition) { - name = ((IMacroDefinition) statements[i]).getName(); + if (statement instanceof IMacroDefinition) { + name = ((IMacroDefinition) statement).getName(); image = imageMacro; - infoString = ((IMacroDefinition)statements[i]).getValue().toString(); - } else if (statements[i] instanceof IRule) { - name = ((IRule) statements[i]).getTarget().toString(); + infoString = ((IMacroDefinition)statement).getValue().toString(); + } else if (statement instanceof IRule) { + name = ((IRule) statement).getTarget().toString(); image = imageTarget; infoString = name; } @@ -156,15 +135,15 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { IContextInformation info = new ContextInformation(name, infoString); String displayString = (name.equals(infoString) ? name : name + " - " + infoString); //$NON-NLS-1$ ICompletionProposal result = - new CompletionProposal( - name, - wordPart.getOffset(), - wordPart.toString().length(), - name.length(), - image, - displayString, - info, - infoString); + new CompletionProposal( + name, + wordPart.getOffset(), + wordPart.toString().length(), + name.length(), + image, + displayString, + info, + infoString); proposalList.add(result); } } @@ -173,9 +152,6 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { return proposals; } - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int) - */ @Override public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset); @@ -184,11 +160,11 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { ArrayList contextList = new ArrayList(); if (macro) { IDirective[] statements = makefile.getMacroDefinitions(); - for (int i = 0; i < statements.length; i++) { - if (statements[i] instanceof IMacroDefinition) { - String name = ((IMacroDefinition) statements[i]).getName(); + for (IDirective statement : statements) { + if (statement instanceof IMacroDefinition) { + String name = ((IMacroDefinition) statement).getName(); 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) { contextList.add(value); } @@ -196,11 +172,11 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { } } statements = makefile.getBuiltinMacroDefinitions(); - for (int i = 0; i < statements.length; i++) { - if (statements[i] instanceof IMacroDefinition) { - String name = ((IMacroDefinition) statements[i]).getName(); + for (IDirective statement : statements) { + if (statement instanceof IMacroDefinition) { + String name = ((IMacroDefinition) statement).getName(); 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) { contextList.add(value); } @@ -218,33 +194,21 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { } - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() - */ @Override public char[] getCompletionProposalAutoActivationCharacters() { return null; } - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() - */ @Override public char[] getContextInformationAutoActivationCharacters() { return null; } - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() - */ @Override public String getErrorMessage() { return null; } - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator() - */ @Override public IContextInformationValidator getContextInformationValidator() { return fValidator;