diff options
author | Jonah Graham | 2018-11-20 16:20:42 +0000 |
---|---|---|
committer | Jonah Graham | 2018-11-22 21:47:02 +0000 |
commit | 170e654b4796bad1453ae85a427b97317d67a69a (patch) | |
tree | 6ca9b8a8fedd5fd25f97eb79c408312e256ff981 /build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal | |
parent | 35996a5c5ca5c254959ba48241eaada6dbf8628d (diff) | |
download | org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.gz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.xz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.zip |
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then
Source -> Clean Up... -> choosing:
- Format source code
- Remove trailing white spaces on all lines
and completing the wizard
Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
Diffstat (limited to 'build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal')
168 files changed, 3976 insertions, 3937 deletions
diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AbstractAutotoolsCPropertyTab.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AbstractAutotoolsCPropertyTab.java index c238f1ff893..26abd638a68 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AbstractAutotoolsCPropertyTab.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AbstractAutotoolsCPropertyTab.java @@ -15,12 +15,11 @@ package org.eclipse.cdt.internal.autotools.ui; import org.eclipse.cdt.managedbuilder.ui.properties.AbstractCBuildPropertyTab; -public abstract class AbstractAutotoolsCPropertyTab extends - AbstractCBuildPropertyTab { +public abstract class AbstractAutotoolsCPropertyTab extends AbstractCBuildPropertyTab { @Override public boolean isIndexerAffected() { return false; } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AutotoolsConsole.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AutotoolsConsole.java index 37d46335760..382c4920027 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AutotoolsConsole.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AutotoolsConsole.java @@ -17,7 +17,7 @@ package org.eclipse.cdt.internal.autotools.ui; public class AutotoolsConsole extends Console { private static final String CONTEXT_MENU_ID = "CAutotoolsConsole"; //$NON-NLS-1$ private static final String CONSOLE_NAME = ConsoleMessages.getString("AutotoolsConsole.name"); //$NON-NLS-1$ - + public AutotoolsConsole() { super(CONSOLE_NAME, CONTEXT_MENU_ID); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AutotoolsUIPluginImages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AutotoolsUIPluginImages.java index de1b58732f8..ebdde999fa7 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AutotoolsUIPluginImages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/AutotoolsUIPluginImages.java @@ -25,12 +25,11 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; - /** * Bundle of all images used by the C plugin. */ public class AutotoolsUIPluginImages { - + // The plugin registry private static ImageRegistry imageRegistry = new ImageRegistry(CUIPlugin.getStandardDisplay()); @@ -39,41 +38,41 @@ public class AutotoolsUIPluginImages { static { try { - fgIconBaseURL= new URL(AutotoolsUIPlugin.getDefault().getBundle().getEntry("/"), "icons/" ); //$NON-NLS-1$ //$NON-NLS-2$ + fgIconBaseURL = new URL(AutotoolsUIPlugin.getDefault().getBundle().getEntry("/"), "icons/"); //$NON-NLS-1$ //$NON-NLS-2$ } catch (MalformedURLException e) { CUIPlugin.log(e); } - } - private static final String NAME_PREFIX= AutotoolsUIPlugin.PLUGIN_ID + '.'; - private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length(); - - public static final String T_OBJ= "ac16/"; //$NON-NLS-1$ - public static final String T_BUILD= "elcl16/"; //$NON-NLS-1$ - - public static final String IMG_OBJS_IF= NAME_PREFIX + "if_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_ELSE= NAME_PREFIX + "else_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_ELIF= NAME_PREFIX + "elif_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CASE= NAME_PREFIX + "case_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_CONDITION= NAME_PREFIX + "condition_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_FOR= NAME_PREFIX + "for_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_WHILE= NAME_PREFIX + "while_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_ACMACRO= NAME_PREFIX + "acmacro_obj.gif"; //$NON-NLS-1$ - public static final String IMG_OBJS_AMMACRO= NAME_PREFIX + "ammacro_obj.gif"; //$NON-NLS-1$ + } + private static final String NAME_PREFIX = AutotoolsUIPlugin.PLUGIN_ID + '.'; + private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length(); + + public static final String T_OBJ = "ac16/"; //$NON-NLS-1$ + public static final String T_BUILD = "elcl16/"; //$NON-NLS-1$ + + public static final String IMG_OBJS_IF = NAME_PREFIX + "if_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_ELSE = NAME_PREFIX + "else_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_ELIF = NAME_PREFIX + "elif_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_CASE = NAME_PREFIX + "case_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_CONDITION = NAME_PREFIX + "condition_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_FOR = NAME_PREFIX + "for_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_WHILE = NAME_PREFIX + "while_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_ACMACRO = NAME_PREFIX + "acmacro_obj.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_AMMACRO = NAME_PREFIX + "ammacro_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_ACMACRO_ARG = NAME_PREFIX + "acmacro_arg_obj.gif"; //$NON-NLS-1$ public static final String IMG_BUILD_CONFIG = NAME_PREFIX + "build_configs.gif"; //$NON-NLS-1$ public static final String IMG_CFG_CATEGORY = NAME_PREFIX + "config_category.gif"; //$NON-NLS-1$ public static final String IMG_CFG_TOOL = NAME_PREFIX + "config_tool.gif"; //$NON-NLS-1$ - public static final ImageDescriptor DESC_OBJS_IF= createManaged(T_OBJ, IMG_OBJS_IF); - public static final ImageDescriptor DESC_OBJS_ELSE= createManaged(T_OBJ, IMG_OBJS_ELSE); - public static final ImageDescriptor DESC_OBJS_ELIF= createManaged(T_OBJ, IMG_OBJS_ELIF); - public static final ImageDescriptor DESC_OBJS_CASE= createManaged(T_OBJ, IMG_OBJS_CASE); + public static final ImageDescriptor DESC_OBJS_IF = createManaged(T_OBJ, IMG_OBJS_IF); + public static final ImageDescriptor DESC_OBJS_ELSE = createManaged(T_OBJ, IMG_OBJS_ELSE); + public static final ImageDescriptor DESC_OBJS_ELIF = createManaged(T_OBJ, IMG_OBJS_ELIF); + public static final ImageDescriptor DESC_OBJS_CASE = createManaged(T_OBJ, IMG_OBJS_CASE); public static final ImageDescriptor DESC_OBJS_CONDITION = createManaged(T_OBJ, IMG_OBJS_CONDITION); - public static final ImageDescriptor DESC_OBJS_FOR= createManaged(T_OBJ, IMG_OBJS_FOR); - public static final ImageDescriptor DESC_OBJS_WHILE= createManaged(T_OBJ, IMG_OBJS_WHILE); - public static final ImageDescriptor DESC_OBJS_ACMACRO= createManaged(T_OBJ, IMG_OBJS_ACMACRO); - public static final ImageDescriptor DESC_OBJS_AMMACRO= createManaged(T_OBJ, IMG_OBJS_AMMACRO); - public static final ImageDescriptor DESC_OBJS_ACMACRO_ARG= createManaged(T_OBJ, IMG_OBJS_ACMACRO_ARG); + public static final ImageDescriptor DESC_OBJS_FOR = createManaged(T_OBJ, IMG_OBJS_FOR); + public static final ImageDescriptor DESC_OBJS_WHILE = createManaged(T_OBJ, IMG_OBJS_WHILE); + public static final ImageDescriptor DESC_OBJS_ACMACRO = createManaged(T_OBJ, IMG_OBJS_ACMACRO); + public static final ImageDescriptor DESC_OBJS_AMMACRO = createManaged(T_OBJ, IMG_OBJS_AMMACRO); + public static final ImageDescriptor DESC_OBJS_ACMACRO_ARG = createManaged(T_OBJ, IMG_OBJS_ACMACRO_ARG); public static final ImageDescriptor DESC_BUILD_CONFIG = createManaged(T_BUILD, IMG_BUILD_CONFIG); public static final ImageDescriptor DESC_CFG_CATEGORY = createManaged(T_BUILD, IMG_CFG_CATEGORY); public static final ImageDescriptor DESC_CFG_TOOL = createManaged(T_BUILD, IMG_CFG_TOOL); @@ -81,23 +80,24 @@ public class AutotoolsUIPluginImages { private static ImageDescriptor createManaged(String prefix, String name) { return createManaged(imageRegistry, prefix, name); } - + private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) { - ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); + ImageDescriptor result = ImageDescriptor + .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); registry.put(name, result); return result; } - + public static Image get(String key) { return imageRegistry.get(key); } - + private static ImageDescriptor create(String prefix, String name) { return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); } - + private static URL makeIconFileURL(String prefix, String name) { - StringBuilder buffer= new StringBuilder(prefix); + StringBuilder buffer = new StringBuilder(prefix); buffer.append(name); try { return new URL(fgIconBaseURL, buffer.toString()); @@ -106,15 +106,15 @@ public class AutotoolsUIPluginImages { return null; } } - + /** * Sets all available image descriptors for the given action. - */ + */ public static void setImageDescriptors(IAction action, String type, String relPath) { - if (relPath.startsWith(NAME_PREFIX)) - relPath= relPath.substring(NAME_PREFIX_LENGTH); + if (relPath.startsWith(NAME_PREFIX)) + relPath = relPath.substring(NAME_PREFIX_LENGTH); action.setDisabledImageDescriptor(create("d" + type, relPath)); //$NON-NLS-1$ -// action.setHoverImageDescriptor(create("c" + type, relPath)); //$NON-NLS-1$ + // action.setHoverImageDescriptor(create("c" + type, relPath)); //$NON-NLS-1$ action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$ // We are still not sure about this, let see TF results first. @@ -123,10 +123,10 @@ public class AutotoolsUIPluginImages { //ImageDescriptor desc = getImageRegistry().getDescriptor(relPath); //if(desc == null) { // desc = createManaged(T + "c" + type, relPath); - //} + //} //action.setImageDescriptor(desc); } - + /** * Helper method to access the image registry from the CUIPlugin class. */ diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CBuildStepsConsole.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CBuildStepsConsole.java index 9887ceb4240..e58ae573c5f 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CBuildStepsConsole.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CBuildStepsConsole.java @@ -14,11 +14,10 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui; - public class CBuildStepsConsole extends Console { private static final String CONTEXT_MENU_ID = "CAutotoolsBuildStepsConsole"; //$NON-NLS-1$ private static final String CONSOLE_NAME = ConsoleMessages.getString("BuildStepsConsole.name"); //$NON-NLS-1$ - + public CBuildStepsConsole() { super(CONSOLE_NAME, CONTEXT_MENU_ID); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CConfigureConsole.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CConfigureConsole.java index 2a0ddd738e9..8817ae5415a 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CConfigureConsole.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CConfigureConsole.java @@ -13,11 +13,10 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui; - public class CConfigureConsole extends Console { private static final String CONTEXT_MENU_ID = "CAutotoolsConfigureConsole"; //$NON-NLS-1$ private static final String CONSOLE_NAME = ConsoleMessages.getString("ConfigureConsole.name"); //$NON-NLS-1$ - + public CConfigureConsole() { super(CONSOLE_NAME, CONTEXT_MENU_ID); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CWordFinder.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CWordFinder.java index 598e98b35cf..e26396d81cb 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CWordFinder.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/CWordFinder.java @@ -18,18 +18,17 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Region; - /** * This is a helper class for the text editor to be able to determine, given a * particular offset in a document, various candidates segments for things like * context help, proposals and hovering. */ public class CWordFinder { - + private static final char CBRACE_L = '{'; private static final char CBRACE_R = '}'; - private static final char BRACE_R = ')'; - + private static final char BRACE_R = ')'; + /** * This method determines for a given offset into a given document what the * region is which defines the current word. A word is defined as the set of @@ -38,7 +37,7 @@ public class CWordFinder { * int b) --> word = afunction afunction!(int a, int b) --> word = afunction * afunction(!int a, int b) --> word = length 0 afunction(int a,! int b) --> * word = length 0 afunction(!) --> word = length 0 - * + * * @param document * The document to be examined * @param offset @@ -93,7 +92,7 @@ public class CWordFinder { /** * This method will determine the region for the name of the function within * which the current offset is contained. - * + * * @param document * The document to be examined * @param offset @@ -206,16 +205,16 @@ public class CWordFinder { } /** - * This method will determine whether current offset is contained - * in any function's body or it's outside it. - * + * This method will determine whether current offset is contained + * in any function's body or it's outside it. + * * @param document * The document to be examined * @param offset * The offset into the document - * @return - * <code>true</code> if there is no function body around offset - * <code>false</code> otherwise + * @return + * <code>true</code> if there is no function body around offset + * <code>false</code> otherwise */ public static boolean isGlobal(IDocument document, int offset) { try { @@ -233,54 +232,58 @@ public class CWordFinder { if (bracketcount-- == 0) { do { c = document.getChar(pos--); - if (c == BRACE_R) return false; + if (c == BRACE_R) + return false; } while (Character.isWhitespace(c)); // container block seems to be not a function or statement body - pos++; // step back one symbol - bracketcount = 0; // let's search for upper block + pos++; // step back one symbol + bracketcount = 0; // let's search for upper block } } } - - } catch (BadLocationException x) { /* Ignore */ } - // return true in case of unknown result or exception + + } catch (BadLocationException x) { + /* Ignore */ } + // return true in case of unknown result or exception return true; } - + /** * Searches for line feed symbols in string. * First met '\r' or '\n' is treated as LF symbol - * + * * @param s * string to search in. * @return number of LFs met. */ - public static int countLFs (String s) { + public static int countLFs(String s) { int counter = 0; char lf = 0; char c; - for (int i=0; i<s.length(); i++) { + for (int i = 0; i < s.length(); i++) { c = s.charAt(i); if (lf == 0) { if (c == '\n' || c == '\r') { lf = c; counter++; } - } else if (lf == c) counter++; + } else if (lf == c) + counter++; } return counter; } /** - * Checks whether the string contains any C-block delimiters ( { } ) - * - * @param s + * Checks whether the string contains any C-block delimiters ( { } ) + * + * @param s * text to check * @return true if curled brace found. */ - public static boolean hasCBraces (String s) { - if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1) return true; - else return false; + public static boolean hasCBraces(String s) { + if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1) + return true; + else + return false; } } - diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/Console.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/Console.java index 621ce903ebf..3c2ecf8523f 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/Console.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/Console.java @@ -23,18 +23,17 @@ import org.eclipse.core.runtime.CoreException; public class Console implements IConsole { IProject project; IBuildConsoleManager fConsoleManager; - + public Console(String consoleName, String contextId) { - fConsoleManager = CUIPlugin.getDefault().getConsoleManager(consoleName, - contextId); + fConsoleManager = CUIPlugin.getDefault().getConsoleManager(consoleName, contextId); } - + @Override - public void start(IProject project ) { + public void start(IProject project) { this.project = project; fConsoleManager.getConsole(project).start(project); } - + /** * @throws CoreException * @see org.eclipse.cdt.core.resources.IConsole#getOutputStream() diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ConsoleMessages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ConsoleMessages.java index 07927521d85..c0f0c003686 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ConsoleMessages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ConsoleMessages.java @@ -25,6 +25,7 @@ public class ConsoleMessages { private ConsoleMessages() { } + public static String getString(String key) { try { return RESOURCE_BUNDLE.getString(key); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ErrorParserBlock.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ErrorParserBlock.java index 6ac746ed74b..4b01e367c1b 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ErrorParserBlock.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ErrorParserBlock.java @@ -31,7 +31,7 @@ public class ErrorParserBlock extends AbstractErrorParserBlock { IMakeBuilderInfo fBuildInfo; boolean useBuildInfo = false; Preferences fPrefs; - + public ErrorParserBlock(Preferences preferences) { super(); fPrefs = preferences; @@ -44,7 +44,8 @@ public class ErrorParserBlock extends AbstractErrorParserBlock { Composite composite = ControlFactory.createComposite(parent, 1); setControl(composite); ControlFactory.createEmptySpace(composite); - ControlFactory.createLabel(composite, MakeUIMessages.getResourceString("ErrorParserBlock.label.missingBuilderInformation")); //$NON-NLS-1$ + ControlFactory.createLabel(composite, + MakeUIMessages.getResourceString("ErrorParserBlock.label.missingBuilderInformation")); //$NON-NLS-1$ return; } super.createControl(parent); @@ -77,19 +78,18 @@ public class ErrorParserBlock extends AbstractErrorParserBlock { } } - @Override protected void saveErrorParsers(String[] parserIDs) throws CoreException { fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, MakeBuilder.BUILDER_ID, false); fBuildInfo.setErrorParsers(parserIDs); } - + @Override protected String[] getErrorParserIDs(boolean defaults) { fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, MakeBuilder.BUILDER_ID, defaults); return fBuildInfo.getErrorParsers(); } - + @Override public void setContainer(ICOptionContainer container) { super.setContainer(container); @@ -98,7 +98,7 @@ public class ErrorParserBlock extends AbstractErrorParserBlock { fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), MakeBuilder.BUILDER_ID); } catch (CoreException e) { } - useBuildInfo = true; + useBuildInfo = true; } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/FileRelevance.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/FileRelevance.java index d7a4cb61867..87ca1fab560 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/FileRelevance.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/FileRelevance.java @@ -25,13 +25,13 @@ import org.eclipse.core.resources.ResourceAttributes; * from multiple files for the same file-system location. */ public class FileRelevance { - private static final int PREFERRED_PROJECT = 0x40; - private static final int CDT_PROJECT = 0x20; - private static final int ON_SOURCE_ROOT = 0x10; + private static final int PREFERRED_PROJECT = 0x40; + private static final int CDT_PROJECT = 0x20; + private static final int ON_SOURCE_ROOT = 0x10; // Penalty for undesirable attributes - private static final int LINK_PENALTY = 1; - private static final int INACCESSIBLE_SHIFT = 4; + private static final int LINK_PENALTY = 1; + private static final int INACCESSIBLE_SHIFT = 4; /** * Compute a relevance for the given file. The higher the score the more relevant the @@ -45,16 +45,16 @@ public class FileRelevance { * @return integer representing file relevance. Larger numbers are more relevant */ public static int getRelevance(IFile f, IProject preferredProject) { - int result= 0; - IProject p= f.getProject(); + int result = 0; + IProject p = f.getProject(); if (p.equals(preferredProject)) - result+= PREFERRED_PROJECT; + result += PREFERRED_PROJECT; if (CoreModel.hasCNature(p)) { - result+= CDT_PROJECT; - ICProject cproject= CoreModel.getDefault().create(p); + result += CDT_PROJECT; + ICProject cproject = CoreModel.getDefault().create(p); if (cproject.isOnSourceRoot(f)) - result+= ON_SOURCE_ROOT; + result += ON_SOURCE_ROOT; } if (!f.isAccessible()) diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTML2TextReader.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTML2TextReader.java index c0ebbbcbe3a..bbc32258d31 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTML2TextReader.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTML2TextReader.java @@ -14,7 +14,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui; - import java.io.IOException; import java.io.PushbackReader; import java.io.Reader; @@ -27,21 +26,19 @@ import org.eclipse.jface.text.TextPresentation; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; - /** - * Reads the text contents from a reader of HTML contents and translates + * Reads the text contents from a reader of HTML contents and translates * the tags or cut them out. */ public class HTML2TextReader extends SubstitutionTextReader { - - - private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + + private static final String LINE_DELIM = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ private static final Map<String, String> fgEntityLookup; private static final Set<String> fgTags; - + static { - - fgTags= new HashSet<>(); + + fgTags = new HashSet<>(); fgTags.add("b"); //$NON-NLS-1$ fgTags.add("br"); //$NON-NLS-1$ fgTags.add("h5"); //$NON-NLS-1$ @@ -51,73 +48,74 @@ public class HTML2TextReader extends SubstitutionTextReader { fgTags.add("dd"); //$NON-NLS-1$ fgTags.add("li"); //$NON-NLS-1$ fgTags.add("ul"); //$NON-NLS-1$ - - fgEntityLookup= new HashMap<>(7); + + fgEntityLookup = new HashMap<>(7); fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("circ", "^"); //$NON-NLS-1$ //$NON-NLS-2$ fgEntityLookup.put("tilde", "~"); //$NON-NLS-2$ //$NON-NLS-1$ - fgEntityLookup.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$ + fgEntityLookup.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$ } - - private int fCounter= 0; + + private int fCounter = 0; private TextPresentation fTextPresentation; - private int fBold= 0; - private int fStartOffset= -1; - private boolean fInParagraph= false; + private int fBold = 0; + private int fStartOffset = -1; + private boolean fInParagraph = false; /** * Transforms the html text from the reader to formatted text. - * @param presentation If not <code>null</code>, formattings will be applied to + * @param presentation If not <code>null</code>, formattings will be applied to * the presentation. */ public HTML2TextReader(Reader reader, TextPresentation presentation) { super(new PushbackReader(reader)); - fTextPresentation= presentation; + fTextPresentation = presentation; } - + @Override public int read() throws IOException { - int c= super.read(); + int c = super.read(); if (c != -1) - ++ fCounter; + ++fCounter; return c; } - + protected void startBold() { if (fBold == 0) - fStartOffset= fCounter; - ++ fBold; + fStartOffset = fCounter; + ++fBold; } - + protected void stopBold() { - -- fBold; + --fBold; if (fBold == 0) { if (fTextPresentation != null) { - fTextPresentation.addStyleRange(new StyleRange(fStartOffset, fCounter - fStartOffset, null, null, SWT.BOLD)); + fTextPresentation + .addStyleRange(new StyleRange(fStartOffset, fCounter - fStartOffset, null, null, SWT.BOLD)); } - fStartOffset= -1; + fStartOffset = -1; } } - + @Override protected String computeSubstitution(int c) throws IOException { if (c == '<') - return processHTMLTag(); + return processHTMLTag(); else if (c == '&') return processEntity(); - + return null; } private String html2Text(String html) { - - String tag= html; + + String tag = html; if ('/' == tag.charAt(0)) - tag= tag.substring(1); - + tag = tag.substring(1); + if (!fgTags.contains(tag)) return ""; //$NON-NLS-1$ @@ -125,135 +123,135 @@ public class HTML2TextReader extends SubstitutionTextReader { startBold(); return ""; //$NON-NLS-1$ } - + if ("h5".equals(html) || "dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$ startBold(); return ""; //$NON-NLS-1$ } - + if ("dl".equals(html)) //$NON-NLS-1$ return LINE_DELIM; - + if ("dd".equals(html)) //$NON-NLS-1$ return "\t"; //$NON-NLS-1$ - + if ("li".equals(html)) //$NON-NLS-1$ return LINE_DELIM + "\t" + "-"; //$NON-NLS-1$ //$NON-NLS-2$ - + if ("/b".equals(html)) { //$NON-NLS-1$ stopBold(); return ""; //$NON-NLS-1$ } - if ("p".equals(html)) { //$NON-NLS-1$ - fInParagraph= true; + if ("p".equals(html)) { //$NON-NLS-1$ + fInParagraph = true; return LINE_DELIM; } if ("br".equals(html)) //$NON-NLS-1$ return LINE_DELIM; - - if ("/p".equals(html)) { //$NON-NLS-1$ - boolean inParagraph= fInParagraph; - fInParagraph= false; + + if ("/p".equals(html)) { //$NON-NLS-1$ + boolean inParagraph = fInParagraph; + fInParagraph = false; return inParagraph ? "" : LINE_DELIM; //$NON-NLS-1$ } - + if ("/h5".equals(html) || "/dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$ stopBold(); return LINE_DELIM; } - + if ("/dd".equals(html)) //$NON-NLS-1$ return LINE_DELIM; - + return ""; //$NON-NLS-1$ } - + /* * A '<' has been read. Process a html tag - */ + */ private String processHTMLTag() throws IOException { - - StringBuilder buf= new StringBuilder(); + + StringBuilder buf = new StringBuilder(); int ch; - do { - - ch= nextChar(); - + do { + + ch = nextChar(); + while (ch != -1 && ch != '>') { buf.append(Character.toLowerCase((char) ch)); - ch= nextChar(); - if (ch == '"'){ + ch = nextChar(); + if (ch == '"') { buf.append(Character.toLowerCase((char) ch)); - ch= nextChar(); - while (ch != -1 && ch != '"'){ + ch = nextChar(); + while (ch != -1 && ch != '"') { buf.append(Character.toLowerCase((char) ch)); - ch= nextChar(); - } + ch = nextChar(); + } } - if (ch == '<'){ + if (ch == '<') { unread(ch); return '<' + buf.toString(); - } + } } - + if (ch == -1) return null; - - int tagLen= buf.length(); - // needs special treatment for comments + + int tagLen = buf.length(); + // needs special treatment for comments if ((tagLen >= 3 && "!--".equals(buf.substring(0, 3))) //$NON-NLS-1$ - && !(tagLen >= 5 && "--!".equals(buf.substring(tagLen - 3)))) { //$NON-NLS-1$ + && !(tagLen >= 5 && "--!".equals(buf.substring(tagLen - 3)))) { //$NON-NLS-1$ // unfinished comment buf.append(ch); } else { break; } } while (true); - + return html2Text(buf.toString()); } - + private void unread(int ch) throws IOException { ((PushbackReader) getReader()).unread(ch); } - + protected String entity2Text(String symbol) { if (symbol.length() > 1 && symbol.charAt(0) == '#') { int ch; try { if (symbol.charAt(1) == 'x') { - ch= Integer.parseInt(symbol.substring(2), 16); + ch = Integer.parseInt(symbol.substring(2), 16); } else { - ch= Integer.parseInt(symbol.substring(1), 10); + ch = Integer.parseInt(symbol.substring(1), 10); } - return "" + (char)ch; //$NON-NLS-1$ + return "" + (char) ch; //$NON-NLS-1$ } catch (NumberFormatException e) { } } else { - String str= fgEntityLookup.get(symbol); + String str = fgEntityLookup.get(symbol); if (str != null) { return str; } } return "&" + symbol; // not found //$NON-NLS-1$ } - + /* * A '&' has been read. Process a entity - */ + */ private String processEntity() throws IOException { - StringBuilder buf= new StringBuilder(); - int ch= nextChar(); - while (Character.isLetterOrDigit((char)ch) || ch == '#') { + StringBuilder buf = new StringBuilder(); + int ch = nextChar(); + while (Character.isLetterOrDigit((char) ch) || ch == '#') { buf.append((char) ch); - ch= nextChar(); + ch = nextChar(); } - - if (ch == ';') + + if (ch == ';') return entity2Text(buf.toString()); - + buf.insert(0, '&'); if (ch != -1) buf.append((char) ch); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTMLPrinter.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTMLPrinter.java index 3b261ef496b..068a5973443 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTMLPrinter.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTMLPrinter.java @@ -17,78 +17,77 @@ package org.eclipse.cdt.internal.autotools.ui; import java.io.IOException; import java.io.Reader; - /** * Provides a set of convenience methods for creating HTML pages. */ public class HTMLPrinter { - + private HTMLPrinter() { } - + private static String replace(String text, char c, String s) { - - int previous= 0; - int current= text.indexOf(c, previous); - + + int previous = 0; + int current = text.indexOf(c, previous); + if (current == -1) return text; - + StringBuilder buffer = new StringBuilder(); while (current > -1) { buffer.append(text.substring(previous, current)); buffer.append(s); - previous= current + 1; - current= text.indexOf(c, previous); + previous = current + 1; + current = text.indexOf(c, previous); } buffer.append(text.substring(previous)); - + return buffer.toString(); } - + public static String convertToHTMLContent(String content) { - content= replace(content, '<', "<"); //$NON-NLS-1$ + content = replace(content, '<', "<"); //$NON-NLS-1$ return replace(content, '>', ">"); //$NON-NLS-1$ } - + public static String read(Reader rd) { - + StringBuilder buffer = new StringBuilder(); - char[] readBuffer= new char[2048]; - + char[] readBuffer = new char[2048]; + try { - int n= rd.read(readBuffer); + int n = rd.read(readBuffer); while (n > 0) { buffer.append(readBuffer, 0, n); - n= rd.read(readBuffer); + n = rd.read(readBuffer); } return buffer.toString(); } catch (IOException x) { } - + return null; } public static void insertPageProlog(StringBuilder buffer, int position) { buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$ } - + public static void addPageProlog(StringBuilder buffer) { insertPageProlog(buffer, buffer.length()); } - + public static void addPageEpilog(StringBuilder buffer) { buffer.append("</font></body></html>"); //$NON-NLS-1$ } - + public static void startBulletList(StringBuilder buffer) { buffer.append("<ul>"); //$NON-NLS-1$ } - + public static void endBulletList(StringBuilder buffer) { buffer.append("</ul>"); //$NON-NLS-1$ } - + public static void addBullet(StringBuilder buffer, String bullet) { if (bullet != null) { buffer.append("<li>"); //$NON-NLS-1$ @@ -96,7 +95,7 @@ public class HTMLPrinter { buffer.append("</li>"); //$NON-NLS-1$ } } - + public static void addSmallHeader(StringBuilder buffer, String header) { if (header != null) { buffer.append("<h5>"); //$NON-NLS-1$ @@ -104,16 +103,15 @@ public class HTMLPrinter { buffer.append("</h5>"); //$NON-NLS-1$ } } - + public static void addParagraph(StringBuilder buffer, String paragraph) { if (paragraph != null) { buffer.append("<p>"); //$NON-NLS-1$ buffer.append(paragraph); } } - - public static void addParagraph(StringBuilder buffer, - Reader paragraphReader) { + + public static void addParagraph(StringBuilder buffer, Reader paragraphReader) { if (paragraphReader != null) addParagraph(buffer, read(paragraphReader)); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTMLTextPresenter.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTMLTextPresenter.java index 9e6dcd6cad9..eb69f51324d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTMLTextPresenter.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/HTMLTextPresenter.java @@ -27,97 +27,98 @@ import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.widgets.Display; - public class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter { - - private static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - + + private static final String LINE_DELIM = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + private int fCounter; private boolean fEnforceUpperLineLimit; - + public HTMLTextPresenter(boolean enforceUpperLineLimit) { super(); - fEnforceUpperLineLimit= enforceUpperLineLimit; + fEnforceUpperLineLimit = enforceUpperLineLimit; } - + public HTMLTextPresenter() { this(true); } - + protected Reader createReader(String hoverInfo, TextPresentation presentation) { return new HTML2TextReader(new StringReader(hoverInfo), presentation); } - + protected void adaptTextPresentation(TextPresentation presentation, int offset, int insertLength) { - - int yoursStart= offset; - + + int yoursStart = offset; + Iterator<StyleRange> e = presentation.getAllStyleRangeIterator(); while (e.hasNext()) { - - StyleRange range= e.next(); - - int myStart= range.start; - int myEnd= range.start + range.length -1; - myEnd= Math.max(myStart, myEnd); - + + StyleRange range = e.next(); + + int myStart = range.start; + int myEnd = range.start + range.length - 1; + myEnd = Math.max(myStart, myEnd); + if (myEnd < yoursStart) continue; - + if (myStart < yoursStart) range.length += insertLength; else range.start += insertLength; } } - + private void append(StringBuilder buffer, String string, TextPresentation presentation) { - - int length= string.length(); + + int length = string.length(); buffer.append(string); - + if (presentation != null) adaptTextPresentation(presentation, fCounter, length); - + fCounter += length; } - + private String getIndent(String line) { - int length= line.length(); - - int i= 0; - while (i < length && Character.isWhitespace(line.charAt(i))) ++i; - + int length = line.length(); + + int i = 0; + while (i < length && Character.isWhitespace(line.charAt(i))) + ++i; + return (i == length ? line : line.substring(0, i)) + " "; //$NON-NLS-1$ } - + @Override - public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) { - + public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, + int maxHeight) { + if (hoverInfo == null) return null; - - GC gc= new GC(display); + + GC gc = new GC(display); try { - - StringBuilder buffer= new StringBuilder(); - int maxNumberOfLines= Math.round((float)maxHeight / gc.getFontMetrics().getHeight()); - - fCounter= 0; - LineBreakingReader reader= new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth); - - boolean lastLineFormatted= false; - String lastLineIndent= null; - - String line=reader.readLine(); - boolean lineFormatted= reader.isFormattedLine(); - boolean firstLineProcessed= false; - + + StringBuilder buffer = new StringBuilder(); + int maxNumberOfLines = Math.round((float) maxHeight / gc.getFontMetrics().getHeight()); + + fCounter = 0; + LineBreakingReader reader = new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth); + + boolean lastLineFormatted = false; + String lastLineIndent = null; + + String line = reader.readLine(); + boolean lineFormatted = reader.isFormattedLine(); + boolean firstLineProcessed = false; + while (line != null) { - + if (fEnforceUpperLineLimit && maxNumberOfLines <= 0) break; - + if (firstLineProcessed) { if (!lastLineFormatted) append(buffer, LINE_DELIM, null); @@ -127,62 +128,61 @@ public class HTMLTextPresenter implements DefaultInformationControl.IInformation append(buffer, lastLineIndent, presentation); } } - + append(buffer, line, null); - firstLineProcessed= true; - - lastLineFormatted= lineFormatted; + firstLineProcessed = true; + + lastLineFormatted = lineFormatted; if (!lineFormatted) - lastLineIndent= null; + lastLineIndent = null; else if (lastLineIndent == null) - lastLineIndent= getIndent(line); - - line= reader.readLine(); - lineFormatted= reader.isFormattedLine(); - + lastLineIndent = getIndent(line); + + line = reader.readLine(); + lineFormatted = reader.isFormattedLine(); + maxNumberOfLines--; } - + if (line != null) { append(buffer, LINE_DELIM, lineFormatted ? presentation : null); append(buffer, (""), presentation); //$NON-NLS-1$ } - + return trim(buffer, presentation); - + } catch (IOException e) { - + AutotoolsUIPlugin.log(e); return null; - + } finally { gc.dispose(); } } - + private String trim(StringBuilder buffer, TextPresentation presentation) { - - int length= buffer.length(); - - int end= length -1; + + int length = buffer.length(); + + int end = length - 1; while (end >= 0 && Character.isWhitespace(buffer.charAt(end))) - -- end; - + --end; + if (end == -1) return ""; //$NON-NLS-1$ - - if (end < length -1) + + if (end < length - 1) buffer.delete(end + 1, length); else - end= length; - - int start= 0; + end = length; + + int start = 0; while (start < end && Character.isWhitespace(buffer.charAt(start))) - ++ start; - + ++start; + buffer.delete(0, start); presentation.setResultWindow(new Region(start, buffer.length())); return buffer.toString(); } } - diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LineBreakingReader.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LineBreakingReader.java index e6bcbe06c12..54e0a1dc31c 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LineBreakingReader.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LineBreakingReader.java @@ -25,89 +25,92 @@ import org.eclipse.swt.graphics.GC; * Not a real reader. Could change if requested */ public class LineBreakingReader { - + private BufferedReader fReader; private GC fGC; private int fMaxWidth; - + private String fLine; private int fOffset; - + private BreakIterator fLineBreakIterator; + private int findNextBreakOffset(int currOffset) { - int currWidth= 0; - int nextOffset= fLineBreakIterator.following(currOffset); + int currWidth = 0; + int nextOffset = fLineBreakIterator.following(currOffset); while (nextOffset != BreakIterator.DONE) { - String word= fLine.substring(currOffset, nextOffset); - int wordWidth= fGC.textExtent(word).x; - int nextWidth= wordWidth + currWidth; + String word = fLine.substring(currOffset, nextOffset); + int wordWidth = fGC.textExtent(word).x; + int nextWidth = wordWidth + currWidth; if (nextWidth > fMaxWidth) { if (currWidth > 0) { return currOffset; } return nextOffset; } - currWidth= nextWidth; - currOffset= nextOffset; - nextOffset= fLineBreakIterator.next(); + currWidth = nextWidth; + currOffset = nextOffset; + nextOffset = fLineBreakIterator.next(); } return nextOffset; } + private int findWordBegin(int idx) { while (idx < fLine.length() && Character.isWhitespace(fLine.charAt(idx))) { idx++; } return idx; } + /** * Creates a reader that breaks an input text to fit in a given width. * @param reader Reader of the input text * @param gc The graphic context that defines the currently used font sizes - * @param maxLineWidth The max width (pixes) where the text has to fit in + * @param maxLineWidth The max width (pixes) where the text has to fit in */ public LineBreakingReader(Reader reader, GC gc, int maxLineWidth) { - fReader= new BufferedReader(reader); - fGC= gc; - fMaxWidth= maxLineWidth; - fOffset= 0; - fLine= null; - fLineBreakIterator= BreakIterator.getLineInstance(); + fReader = new BufferedReader(reader); + fGC = gc; + fMaxWidth = maxLineWidth; + fOffset = 0; + fLine = null; + fLineBreakIterator = BreakIterator.getLineInstance(); } - + public boolean isFormattedLine() { return fLine != null; } - + /** * Reads the next line. The lengths of the line will not exceed the gived maximum * width. */ public String readLine() throws IOException { if (fLine == null) { - String line= fReader.readLine(); + String line = fReader.readLine(); if (line == null) { return null; } - - int lineLen= fGC.textExtent(line).x; + + int lineLen = fGC.textExtent(line).x; if (lineLen < fMaxWidth) { return line; } - fLine= line; + fLine = line; fLineBreakIterator.setText(line); - fOffset= 0; + fOffset = 0; } - int breakOffset= findNextBreakOffset(fOffset); + int breakOffset = findNextBreakOffset(fOffset); String res; if (breakOffset != BreakIterator.DONE) { - res= fLine.substring(fOffset, breakOffset); - fOffset= findWordBegin(breakOffset); + res = fLine.substring(fOffset, breakOffset); + fOffset = findWordBegin(breakOffset); if (fOffset == fLine.length()) { - fLine= null; + fLine = null; } } else { - res= fLine.substring(fOffset); - fLine= null; + res = fLine.substring(fOffset); + fLine = null; } return res; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LocationAdapter.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LocationAdapter.java index 0260281dd8e..bb9e174631e 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LocationAdapter.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/LocationAdapter.java @@ -10,7 +10,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui; import java.io.File; @@ -27,10 +27,13 @@ import org.eclipse.core.runtime.IPath; * Provides common functionality for URI and IPath */ abstract class LocationAdapter<T> { - + public abstract String extractName(T location); + public abstract IFile[] platformsFindFilesForLocation(T location); + public abstract String getCanonicalPath(T location); + public abstract T getLocation(IFile file); public static final LocationAdapter<IPath> PATH = new LocationAdapter<IPath>() { @@ -50,7 +53,7 @@ abstract class LocationAdapter<T> { @Override public String getCanonicalPath(IPath location) { - final File file= location.toFile(); + final File file = location.toFile(); try { return file.getCanonicalPath(); } catch (IOException e) { @@ -68,9 +71,9 @@ abstract class LocationAdapter<T> { public static final LocationAdapter<URI> URI = new LocationAdapter<URI>() { @Override public String extractName(URI location) { - String path= location.getPath(); - int idx= path.lastIndexOf('/'); - return path.substring(idx+1); + String path = location.getPath(); + int idx = path.lastIndexOf('/'); + return path.substring(idx + 1); } @Override @@ -80,10 +83,10 @@ abstract class LocationAdapter<T> { @Override public String getCanonicalPath(URI location) { - if (!"file".equals(location.getScheme())) //$NON-NLS-1$ + if (!"file".equals(location.getScheme())) //$NON-NLS-1$ return null; - String path= location.getPath(); + String path = location.getPath(); try { return new File(path).getCanonicalPath(); } catch (IOException e) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MakeUIImages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MakeUIImages.java index 29281d9e479..24e70d4430a 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MakeUIImages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MakeUIImages.java @@ -22,8 +22,6 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; - - public class MakeUIImages { /** @@ -45,7 +43,7 @@ public class MakeUIImages { private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length(); public static final String OBJ = "obj16/"; //$NON-NLS-1$ - public static final String T_TOOL= "tool16/"; //$NON-NLS-1$ + public static final String T_TOOL = "tool16/"; //$NON-NLS-1$ public static final String T_LCL = "lcl16/"; //$NON-NLS-1$ // For the build image @@ -73,7 +71,8 @@ public class MakeUIImages { public static final ImageDescriptor DESC_MAKEFILE_TARGET_RULE = createManaged(OBJ, IMG_OBJS_MAKEFILE_TARGET_RULE); public static final String IMG_OBJS_MAKEFILE_INFERENCE_RULE = NAME_PREFIX + "irule_obj.gif"; //$NON-NLS-1$ - public static final ImageDescriptor DESC_MAKEFILE_INFERENCE_RULE = createManaged(OBJ, IMG_OBJS_MAKEFILE_INFERENCE_RULE); + public static final ImageDescriptor DESC_MAKEFILE_INFERENCE_RULE = createManaged(OBJ, + IMG_OBJS_MAKEFILE_INFERENCE_RULE); public static final String IMG_OBJS_MAKEFILE_RELATION = NAME_PREFIX + "relation_obj.gif"; //$NON-NLS-1$ public static final ImageDescriptor DESC_MAKEFILE_RELATION = createManaged(OBJ, IMG_OBJS_MAKEFILE_RELATION); @@ -90,17 +89,18 @@ public class MakeUIImages { public static final String IMG_OBJS_ENV_VAR = NAME_PREFIX + "envvar_obj.gif"; //$NON-NLS-1$ public static final ImageDescriptor DESC_ENV_VAR = createManaged(OBJ, IMG_OBJS_ENV_VAR); - public static final String IMG_TOOLS_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif"; //$NON-NLS-1$ - public static final String IMG_TOOLS_MAKEFILE_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$ + public static final String IMG_TOOLS_ALPHA_SORTING = NAME_PREFIX + "alphab_sort_co.gif"; //$NON-NLS-1$ + public static final String IMG_TOOLS_MAKEFILE_SEGMENT_EDIT = NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$ - public static final String IMG_MENU_OPEN_INCLUDE= NAME_PREFIX + "open_include.gif"; //$NON-NLS-1$ + public static final String IMG_MENU_OPEN_INCLUDE = NAME_PREFIX + "open_include.gif"; //$NON-NLS-1$ private static ImageDescriptor createManaged(String prefix, String name) { return createManaged(imageRegistry, prefix, name); } private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) { - ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); + ImageDescriptor result = ImageDescriptor + .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); registry.put(name, result); return result; } @@ -130,7 +130,7 @@ public class MakeUIImages { public static void setImageDescriptors(IAction action, String type, String relPath) { relPath = relPath.substring(NAME_PREFIX_LENGTH); action.setDisabledImageDescriptor(create("d" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$ -// action.setHoverImageDescriptor(create("e" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$ + // action.setHoverImageDescriptor(create("e" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$ action.setImageDescriptor(create("e" + type + "/", relPath)); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MakeUIMessages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MakeUIMessages.java index 0ca08b98250..2e27b5e0b5b 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MakeUIMessages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MakeUIMessages.java @@ -25,6 +25,7 @@ public class MakeUIMessages { private MakeUIMessages() { } + public static String getResourceString(String key) { try { return RESOURCE_BUNDLE.getString(key); @@ -32,7 +33,7 @@ public class MakeUIMessages { return '!' + key + '!'; } } - + /** * Returns the plugin's resource bundle, */ diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MessageLine.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MessageLine.java index 2fd2a76b673..becc1a1ba5f 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MessageLine.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/MessageLine.java @@ -19,10 +19,9 @@ import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Composite; - /** - * A message line. It distinguishes between "normal" messages and errors. - * Setting an error message hides a currently displayed message until + * A message line. It distinguishes between "normal" messages and errors. + * Setting an error message hides a currently displayed message until * <code>clearErrorMessage</code> is called. */ public class MessageLine { @@ -32,7 +31,7 @@ public class MessageLine { private Color fNormalMsgAreaBackground; private boolean hasErrorMessage; - + private CLabel clabel; /** @@ -47,14 +46,13 @@ public class MessageLine { */ public MessageLine(Composite parent, int style) { clabel = new CLabel(parent, style); - fNormalMsgAreaBackground= clabel.getBackground(); + fNormalMsgAreaBackground = clabel.getBackground(); } - /** - * Display the given error message. A currently displayed message - * is saved and will be redisplayed when the error message is cleared. - */ + * Display the given error message. A currently displayed message + * is saved and will be redisplayed when the error message is cleared. + */ public void setErrorMessage(String message) { if (message != null && message.length() > 0) { hasErrorMessage = true; @@ -64,16 +62,16 @@ public class MessageLine { return; } hasErrorMessage = false; - clabel.setText(fMessage); + clabel.setText(fMessage); clabel.setImage(null); - clabel.setBackground(fNormalMsgAreaBackground); + clabel.setBackground(fNormalMsgAreaBackground); } public void setMessage(String message) { fMessage = message; clabel.setText(message); } - + public boolean hasErrorMessage() { return hasErrorMessage; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/OptionalMessageDialog.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/OptionalMessageDialog.java index 1906c6f97bf..29b0b9ec240 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/OptionalMessageDialog.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/OptionalMessageDialog.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation * Anton Leherbauer (Wind River Systems) @@ -32,18 +32,18 @@ import org.eclipse.swt.widgets.Shell; /** * This is a <code>MessageDialog</code> which allows the user * to choose that the dialog isn't shown again the next time. - */ + */ public class OptionalMessageDialog extends MessageDialog { // String constants for widgets - private static final String CHECKBOX_TEXT= MakeUIMessages.getResourceString("OptionalMessageDialog_dontShowAgain"); //$NON-NLS-1$ + private static final String CHECKBOX_TEXT = MakeUIMessages.getResourceString("OptionalMessageDialog_dontShowAgain"); //$NON-NLS-1$ // Dialog store id constants - private static final String STORE_ID= "OptionalMessageDialog.hide."; //$NON-NLS-1$ + private static final String STORE_ID = "OptionalMessageDialog.hide."; //$NON-NLS-1$ private static final String KEY_DETAIL = ".detail"; //$NON-NLS-1$ - public static final int NOT_SHOWN= IDialogConstants.CLIENT_ID + 1; - public static final int NO_DETAIL= -1; - + public static final int NOT_SHOWN = IDialogConstants.CLIENT_ID + 1; + public static final int NO_DETAIL = -1; + private Button fHideDialogCheckBox; private String fId; @@ -51,89 +51,92 @@ public class OptionalMessageDialog extends MessageDialog { * Opens the dialog but only if the user hasn't choosen to hide it. * Returns <code>NOT_SHOWN</code> if the dialog was not shown. */ - public static int open(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) { + public static int open(String id, Shell parent, String title, Image titleImage, String message, int dialogType, + String[] buttonLabels, int defaultButtonIndex) { if (!isDialogEnabled(id)) return OptionalMessageDialog.NOT_SHOWN; - - MessageDialog dialog= new OptionalMessageDialog(id, parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex); + + MessageDialog dialog = new OptionalMessageDialog(id, parent, title, titleImage, message, dialogType, + buttonLabels, defaultButtonIndex); return dialog.open(); } - protected OptionalMessageDialog(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) { + protected OptionalMessageDialog(String id, Shell parent, String title, Image titleImage, String message, + int dialogType, String[] buttonLabels, int defaultButtonIndex) { super(parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex); - fId= id; + fId = id; } @Override protected Control createCustomArea(Composite parent) { - Composite composite= new Composite(parent, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); + Composite composite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); + layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); + layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - fHideDialogCheckBox= new Button(composite, SWT.CHECK | SWT.LEFT); + + fHideDialogCheckBox = new Button(composite, SWT.CHECK | SWT.LEFT); fHideDialogCheckBox.setText(CHECKBOX_TEXT); fHideDialogCheckBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - setDialogEnabled(fId, !((Button)e.widget).getSelection()); + setDialogEnabled(fId, !((Button) e.widget).getSelection()); } }); applyDialogFont(fHideDialogCheckBox); return fHideDialogCheckBox; } - + //--------------- Configuration handling -------------- - + /** * Returns this dialog - * + * * @return the settings to be used */ private static IDialogSettings getDialogSettings() { - IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings(); - settings= settings.getSection(STORE_ID); + IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings(); + settings = settings.getSection(STORE_ID); if (settings == null) - settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID); + settings = CUIPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID); return settings; } - + /** * Answers whether the optional dialog is enabled and should be shown. */ public static boolean isDialogEnabled(String key) { - IDialogSettings settings= getDialogSettings(); + IDialogSettings settings = getDialogSettings(); return !settings.getBoolean(key); } - + /** * Sets a detail for the dialog. */ public static void setDialogDetail(String key, int detail) { - IDialogSettings settings= getDialogSettings(); - settings.put(key+KEY_DETAIL, detail); + IDialogSettings settings = getDialogSettings(); + settings.put(key + KEY_DETAIL, detail); } /** * Returns the detail for this dialog, or NO_DETAIL, if none. */ public static int getDialogDetail(String key) { - IDialogSettings settings= getDialogSettings(); + IDialogSettings settings = getDialogSettings(); try { - return settings.getInt(key+KEY_DETAIL); + return settings.getInt(key + KEY_DETAIL); } catch (NumberFormatException e) { return NO_DETAIL; } } - + /** * Sets whether the optional dialog is enabled and should be shown. */ public static void setDialogEnabled(String key, boolean isEnabled) { - IDialogSettings settings= getDialogSettings(); + IDialogSettings settings = getDialogSettings(); settings.put(key, !isEnabled); } @@ -141,7 +144,7 @@ public class OptionalMessageDialog extends MessageDialog { * Clears all remembered information about hidden dialogs */ public static void clearAllRememberedStates() { - IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings(); + IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings(); settings.addNewSection(STORE_ID); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ResourceLookup.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ResourceLookup.java index 8dd51ee18f2..93c1e3387d6 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ResourceLookup.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ResourceLookup.java @@ -10,7 +10,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui; import java.net.URI; @@ -25,23 +25,23 @@ import org.eclipse.core.runtime.IPath; * Allows for looking up resources by location or name. */ public class ResourceLookup { - private static ResourceLookupTree lookupTree= new ResourceLookupTree(); + private static ResourceLookupTree lookupTree = new ResourceLookupTree(); public static void startup() { lookupTree.startup(); } - + public static void shutdown() { lookupTree.shutdown(); } - + /** - * Searches for files with the given location suffix. - * - * At this point the method works for sources and headers (no other content types), only. - * This is done to use less memory and can be changed if necessary. + * Searches for files with the given location suffix. + * + * At this point the method works for sources and headers (no other content types), only. + * This is done to use less memory and can be changed if necessary. * For linked resource files, the name of the link target is relevant. - * + * * @param locationSuffix the suffix to match, always used as relative path. * @param projects the projects to search * @param ignoreCase whether or not to ignore case when comparing the suffix. @@ -49,10 +49,10 @@ public class ResourceLookup { public static IFile[] findFilesByName(IPath locationSuffix, IProject[] projects, boolean ignoreCase) { return lookupTree.findFilesByName(locationSuffix, projects, ignoreCase); } - + /** * Uses a lookup-tree that finds resources for locations using the canonical representation - * of the path. + * of the path. */ public static IFile[] findFilesForLocationURI(URI location) { return lookupTree.findFilesForLocationURI(location); @@ -60,7 +60,7 @@ public class ResourceLookup { /** * Uses a lookup-tree that finds resources for locations using the canonical representation - * of the path. The method does not work for files where the name (last segment) of the + * of the path. The method does not work for files where the name (last segment) of the * resources differs from the name of the location. */ public static IFile[] findFilesForLocation(IPath location) { @@ -70,7 +70,7 @@ public class ResourceLookup { /** * Uses {@link #findFilesForLocationURI(URI)} and selects the most relevant file * from the result. Files form the first project, from cdt-projects and those on source - * roots are preferred, see {@link FileRelevance}. + * roots are preferred, see {@link FileRelevance}. * @param location an URI for the location of the files to search for. * @param preferredProject a project to be preferred over others, or <code>null</code>. * @return a file for the location in one of the given projects, or <code>null</code>. @@ -83,7 +83,7 @@ public class ResourceLookup { /** * Uses {@link #findFilesForLocation(IPath)} and selects the most relevant file * from the result. Files form the preferred project, from cdt-projects and those on source - * roots are preferred, see {@link FileRelevance}. + * roots are preferred, see {@link FileRelevance}. * @param location a path for the location of the files to search for. * @param preferredProject a project to be preferred over others, or <code>null</code>. * @return a file for the location or <code>null</code>. @@ -100,17 +100,16 @@ public class ResourceLookup { if (files.length == 1) return files[0]; - IFile best= null; - int bestRelevance= -1; + IFile best = null; + int bestRelevance = -1; for (int i = 0; i < files.length; i++) { IFile file = files[i]; - int relevance= FileRelevance.getRelevance(file, preferredProject); - if (best == null || relevance > bestRelevance || - (relevance == bestRelevance && - best.getFullPath().toString().compareTo(file.getFullPath().toString()) > 0)) { - bestRelevance= relevance; - best= file; + int relevance = FileRelevance.getRelevance(file, preferredProject); + if (best == null || relevance > bestRelevance || (relevance == bestRelevance + && best.getFullPath().toString().compareTo(file.getFullPath().toString()) > 0)) { + bestRelevance = relevance; + best = file; } } return best; @@ -138,19 +137,21 @@ public class ResourceLookup { }); } - /** + /** * For testing, only. */ public static void dump() { lookupTree.dump(); } - /** + + /** * For testing, only. */ public static void unrefNodeMap() { lookupTree.unrefNodeMap(); } - /** + + /** * For testing, only. */ public static void simulateNodeMapCollection() { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ResourceLookupTree.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ResourceLookupTree.java index 81e159c8348..6afc3d967f7 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ResourceLookupTree.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/ResourceLookupTree.java @@ -10,7 +10,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui; import java.lang.ref.SoftReference; @@ -52,66 +52,67 @@ import org.eclipse.core.runtime.jobs.Job; /** * Allows for looking up resources by location or name. When using this class 100 bytes per resource - * are needed. Therefore the support is limited to header-files int non-cdt projects and all files + * are needed. Therefore the support is limited to header-files int non-cdt projects and all files * except non-cdt-files in CDT projects. * * The information for a project is initialized when first requested and then it is kept up to date * using a resource change listener. No memory is used, as long as the class is not used. * When information is not used for more than 10 minutes, the data-structures will be held via a weak * reference, only and are subject to garbage collection. - * + * * The node map stores a map from hash-code of file-names to nodes. * A node contains the name of a file plus a link to the parent resource. From that we can compute * the resource path and obtain further information via the resource. */ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisitor, IResourceProxyVisitor { private static final int UNREF_DELAY = 10 * 60000; // 10 min - + private static final boolean VISIT_CHILDREN = true; private static final boolean SKIP_CHILDREN = false; private static final IFile[] NO_FILES = new IFile[0]; - private static final int TRIGGER_RECALC= - IResourceDelta.TYPE | IResourceDelta.REPLACED | - IResourceDelta.LOCAL_CHANGED | IResourceDelta.OPEN; - + private static final int TRIGGER_RECALC = IResourceDelta.TYPE | IResourceDelta.REPLACED + | IResourceDelta.LOCAL_CHANGED | IResourceDelta.OPEN; + private static class Extensions { private final boolean fInvert; private final Set<String> fExtensions; + Extensions(Set<String> extensions, boolean invert) { - fInvert= invert; - fExtensions= extensions; + fInvert = invert; + fExtensions = extensions; } + boolean isRelevant(String filename) { // accept all files without extension - final int idx= filename.lastIndexOf('.'); + final int idx = filename.lastIndexOf('.'); if (idx < 0) return true; - - return fExtensions.contains(filename.substring(idx+1).toUpperCase()) != fInvert; + + return fExtensions.contains(filename.substring(idx + 1).toUpperCase()) != fInvert; } } - + private static class Node { final Node fParent; final char[] fResourceName; final boolean fHasFileLocationName; final boolean fIsFileLinkTarget; - + boolean fDeleted; boolean fHasChildren; int fCanonicHash; - + Node(Node parent, char[] name, boolean hasFileLocationName, boolean isFileLinkTarget) { - fParent= parent; - fResourceName= name; - fHasFileLocationName= hasFileLocationName; - fIsFileLinkTarget= isFileLinkTarget; + fParent = parent; + fResourceName = name; + fHasFileLocationName = hasFileLocationName; + fIsFileLinkTarget = isFileLinkTarget; if (parent != null) - parent.fHasChildren= true; + parent.fHasChildren = true; } } - - private final Object fLock= new Object(); + + private final Object fLock = new Object(); private final Job fUnrefJob; private SoftReference<Map<Integer, Object>> fNodeMapRef; private Map<Integer, Object> fNodeMap; @@ -122,10 +123,11 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit private Node fRootNode; private boolean fNeedCleanup; private Node fLastFolderNode; - + public ResourceLookupTree() { - fRootNode= new Node(null, CharArrayUtils.EMPTY, false, false) {}; - fFileExtensions= new HashMap<>(); + fRootNode = new Node(null, CharArrayUtils.EMPTY, false, false) { + }; + fFileExtensions = new HashMap<>(); fUnrefJob = Job.create("Timer", monitor -> { unrefNodeMap(); return Status.OK_STATUS; @@ -141,8 +143,8 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit public void shutdown() { ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); synchronized (fLock) { - fNodeMap= null; - fNodeMapRef= null; + fNodeMap = null; + fNodeMapRef = null; fFileExtensions.clear(); } } @@ -152,16 +154,16 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit */ @Override public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta= event.getDelta(); + IResourceDelta delta = event.getDelta(); synchronized (fLock) { if (fNodeMapRef == null) return; - boolean unsetMap= false; + boolean unsetMap = false; if (fNodeMap == null) { - fNodeMap= fNodeMapRef.get(); + fNodeMap = fNodeMapRef.get(); if (fNodeMap == null) return; - unsetMap= true; + unsetMap = true; } try { delta.accept(this); @@ -170,39 +172,39 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } finally { if (fNeedCleanup) cleanup(); - fCurrentExtensions= null; - fNeedCleanup= false; + fCurrentExtensions = null; + fNeedCleanup = false; if (unsetMap) - fNodeMap= null; + fNodeMap = null; } } } - + /** * Handles resource change notifications by visiting the delta. */ @Override public boolean visit(IResourceDelta delta) { assert Thread.holdsLock(fLock); - - final IResource res= delta.getResource(); + + final IResource res = delta.getResource(); if (res instanceof IWorkspaceRoot) return VISIT_CHILDREN; - + if (res instanceof IProject) { // project not yet handled final String name = res.getName(); - final Extensions exts= fFileExtensions.get(name); + final Extensions exts = fFileExtensions.get(name); if (exts == null) return SKIP_CHILDREN; - + switch (delta.getKind()) { - case IResourceDelta.ADDED: // new projects should not yet be part of the tree + case IResourceDelta.ADDED: // new projects should not yet be part of the tree case IResourceDelta.REMOVED: fFileExtensions.remove(name); remove(res); return SKIP_CHILDREN; - + case IResourceDelta.CHANGED: if ((delta.getFlags() & (TRIGGER_RECALC | IResourceDelta.DESCRIPTION)) != 0) { fFileExtensions.remove(name); @@ -211,16 +213,16 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } break; } - fCurrentExtensions= exts; + fCurrentExtensions = exts; return VISIT_CHILDREN; } - + // file or folder switch (delta.getKind()) { case IResourceDelta.ADDED: add(res); return SKIP_CHILDREN; - + case IResourceDelta.CHANGED: if ((delta.getFlags() & TRIGGER_RECALC) != 0) { remove(res); @@ -228,36 +230,35 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit return SKIP_CHILDREN; } return VISIT_CHILDREN; - + case IResourceDelta.REMOVED: - + remove(res); return SKIP_CHILDREN; } return VISIT_CHILDREN; } - /** * Add a resource to the tree. */ private void add(IResource res) { assert Thread.holdsLock(fLock); - + if (res instanceof IFile) { final String resName = res.getName(); - String linkedName= null; + String linkedName = null; if (res.isLinked()) { - URI uri= res.getLocationURI(); + URI uri = res.getLocationURI(); if (uri != null) { - linkedName= LocationAdapter.URI.extractName(uri); + linkedName = LocationAdapter.URI.extractName(uri); if (linkedName.length() > 0 && fCurrentExtensions.isRelevant(linkedName)) { if (linkedName.equals(resName)) { createFileNode(res.getFullPath(), null); } else { createFileNode(res.getFullPath(), linkedName); } - } + } } } else if (fCurrentExtensions.isRelevant(resName)) { createFileNode(res.getFullPath(), null); @@ -270,7 +271,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } } } - + /** * Add a resource tree by using a resource proxy visitor. */ @@ -279,8 +280,8 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit if (proxy.getType() == IResource.FILE) { if (fCurrentExtensions.isRelevant(proxy.getName())) { if (proxy.isLinked()) { - IResource res= proxy.requestResource(); - if (res instanceof IFile) { + IResource res = proxy.requestResource(); + if (res instanceof IFile) { add(res); } return true; @@ -291,17 +292,16 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit return true; } - public void unrefNodeMap() { synchronized (fLock) { - fNodeMap= null; + fNodeMap = null; } } public void simulateNodeMapCollection() { synchronized (fLock) { - fNodeMap= null; - fNodeMapRef= new SoftReference<>(null); + fNodeMap = null; + fNodeMapRef = new SoftReference<>(null); } } @@ -310,36 +310,36 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit */ private void initializeProjects(IProject[] projects) { assert Thread.holdsLock(fLock); - + if (fNodeMap == null) { if (fNodeMapRef != null) { - fNodeMap= fNodeMapRef.get(); + fNodeMap = fNodeMapRef.get(); } if (fNodeMap == null) { fFileExtensions.clear(); - fNodeMap= new HashMap<>(); - fNodeMapRef= new SoftReference<>(fNodeMap); + fNodeMap = new HashMap<>(); + fNodeMapRef = new SoftReference<>(fNodeMap); } } fUnrefJob.cancel(); - fUnrefJob.schedule(UNREF_DELAY); + fUnrefJob.schedule(UNREF_DELAY); for (IProject project : projects) { if (project.isOpen() && !fFileExtensions.containsKey(project.getName())) { - Extensions ext= fDefaultExtensions; + Extensions ext = fDefaultExtensions; try { if (project.hasNature(CProjectNature.C_NATURE_ID)) { - ext= fCDTProjectExtensions; + ext = fCDTProjectExtensions; } } catch (CoreException e) { AutotoolsUIPlugin.log(e); // treat as non-cdt project } - fCurrentExtensions= ext; + fCurrentExtensions = ext; add(project); fFileExtensions.put(project.getName(), ext); - fCurrentExtensions= null; + fCurrentExtensions = null; } } } @@ -348,44 +348,44 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit * Initializes file-extensions and node map */ private void initFileExtensions() { - + if (fDefaultExtensions == null) { - HashSet<String> cdtContentTypes= new HashSet<>(); - String[] registeredContentTypes= CoreModel.getRegistedContentTypeIds(); + HashSet<String> cdtContentTypes = new HashSet<>(); + String[] registeredContentTypes = CoreModel.getRegistedContentTypeIds(); cdtContentTypes.addAll(Arrays.asList(registeredContentTypes)); - final IContentTypeManager ctm= Platform.getContentTypeManager(); - final IContentType[] ctts= ctm.getAllContentTypes(); - Set<String> result= new HashSet<>(); + final IContentTypeManager ctm = Platform.getContentTypeManager(); + final IContentType[] ctts = ctm.getAllContentTypes(); + Set<String> result = new HashSet<>(); outer: for (IContentType ctt : ctts) { - IContentType basedOn= ctt; + IContentType basedOn = ctt; while (basedOn != null) { - if (cdtContentTypes.contains(basedOn.getId())) + if (cdtContentTypes.contains(basedOn.getId())) continue outer; - basedOn= basedOn.getBaseType(); + basedOn = basedOn.getBaseType(); } // this is a non-cdt content type addFileSpecs(ctt, result); } - fCDTProjectExtensions= new Extensions(result, true); + fCDTProjectExtensions = new Extensions(result, true); - result= new HashSet<>(); + result = new HashSet<>(); for (IContentType ctt : ctts) { - IContentType basedOn= ctt; + IContentType basedOn = ctt; while (basedOn != null) { if (cdtContentTypes.contains(basedOn.getId())) { addFileSpecs(ctt, result); break; } - basedOn= basedOn.getBaseType(); + basedOn = basedOn.getBaseType(); } } - fDefaultExtensions= new Extensions(result, false); + fDefaultExtensions = new Extensions(result, false); } } private void addFileSpecs(IContentType ctt, Set<String> result) { - String[] fspecs= ctt.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); + String[] fspecs = ctt.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); for (String fspec : fspecs) { result.add(fspec.toUpperCase()); } @@ -395,8 +395,8 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit * Inserts a node for the given path. */ private void createFileNode(IPath fullPath, String fileLink) { - final String[] segments= fullPath.segments(); - final boolean isFileLinkTarget= fileLink != null; + final String[] segments = fullPath.segments(); + final boolean isFileLinkTarget = fileLink != null; final char[][] charArraySegments = toCharArrayArray(segments, fileLink); createNode(charArraySegments, charArraySegments.length, true, isFileLinkTarget); } @@ -405,13 +405,13 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit final int segmentLen = segments.length; char[][] chsegs; if (fileLink != null) { - chsegs= new char[segmentLen+1][]; - chsegs[segmentLen]= fileLink.toCharArray(); + chsegs = new char[segmentLen + 1][]; + chsegs[segmentLen] = fileLink.toCharArray(); } else { - chsegs= new char[segmentLen][]; + chsegs = new char[segmentLen][]; } for (int i = 0; i < segmentLen; i++) { - chsegs[i]= segments[i].toCharArray(); + chsegs[i] = segments[i].toCharArray(); } return chsegs; } @@ -419,9 +419,10 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit /** * Inserts a node for the given path. */ - private Node createNode(char[][] segments, int segmentCount, boolean hasFileLocationName, boolean isFileLinkTarget) { + private Node createNode(char[][] segments, int segmentCount, boolean hasFileLocationName, + boolean isFileLinkTarget) { assert Thread.holdsLock(fLock); - + if (segmentCount == 0) return fRootNode; @@ -429,56 +430,56 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit if (isNodeForSegments(fLastFolderNode, segments, segmentCount, isFileLinkTarget)) return fLastFolderNode; } - - final char[] name= segments[segmentCount-1]; - final int hash= hashCode(name); - + + final char[] name = segments[segmentCount - 1]; + final int hash = hashCode(name); + // search for existing node - Object obj= fNodeMap.get(hash); + Object obj = fNodeMap.get(hash); - Node[] nodes= null; - int len= 0; + Node[] nodes = null; + int len = 0; if (obj != null) { if (obj instanceof Node) { - Node node= (Node) obj; + Node node = (Node) obj; if (isNodeForSegments(node, segments, segmentCount, isFileLinkTarget)) { if (!hasFileLocationName) - fLastFolderNode= node; + fLastFolderNode = node; return node; } - nodes= new Node[]{node, null}; + nodes = new Node[] { node, null }; fNodeMap.put(hash, nodes); - len= 1; + len = 1; } else { - nodes= (Node[]) obj; - for (len=0; len < nodes.length; len++) { + nodes = (Node[]) obj; + for (len = 0; len < nodes.length; len++) { Node node = nodes[len]; - if (node == null) + if (node == null) break; if (isNodeForSegments(node, segments, segmentCount, isFileLinkTarget)) { if (!hasFileLocationName) - fLastFolderNode= node; + fLastFolderNode = node; return node; } } } - } - final Node parent= createNode(segments, segmentCount-1, false, false); - Node node= new Node(parent, name, hasFileLocationName, isFileLinkTarget); + } + final Node parent = createNode(segments, segmentCount - 1, false, false); + Node node = new Node(parent, name, hasFileLocationName, isFileLinkTarget); if (nodes == null) { fNodeMap.put(hash, node); - } else { + } else { if (len == nodes.length) { - Node[] newNodes= new Node[len+2]; + Node[] newNodes = new Node[len + 2]; System.arraycopy(nodes, 0, newNodes, 0, len); - nodes= newNodes; + nodes = newNodes; fNodeMap.put(hash, nodes); } - nodes[len]= node; + nodes[len] = node; } - + if (!hasFileLocationName) - fLastFolderNode= node; + fLastFolderNode = node; return node; } @@ -487,60 +488,60 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit */ private boolean isNodeForSegments(Node node, char[][] segments, int segmentLength, boolean isFileLinkTarget) { assert Thread.holdsLock(fLock); - + if (node.fIsFileLinkTarget != isFileLinkTarget) return false; - - while(segmentLength > 0 && node != null) { + + while (segmentLength > 0 && node != null) { if (!CharArrayUtils.equals(segments[--segmentLength], node.fResourceName)) return false; - node= node.fParent; + node = node.fParent; } return node == fRootNode; } - + /** * Remove a resource from the tree */ private void remove(IResource res) { assert Thread.holdsLock(fLock); - - final char[] name= res.getName().toCharArray(); - final int hash= hashCode(name); - - Object obj= fNodeMap.get(hash); + + final char[] name = res.getName().toCharArray(); + final int hash = hashCode(name); + + Object obj = fNodeMap.get(hash); if (obj == null) return; - - final IPath fullPath= res.getFullPath(); - final int segmentCount= fullPath.segmentCount(); + + final IPath fullPath = res.getFullPath(); + final int segmentCount = fullPath.segmentCount(); if (segmentCount == 0) return; - - final char[][]segments= toCharArrayArray(fullPath.segments(), null); + + final char[][] segments = toCharArrayArray(fullPath.segments(), null); if (obj instanceof Node) { - final Node node= (Node) obj; + final Node node = (Node) obj; if (!node.fDeleted && isNodeForSegments(node, segments, segmentCount, false)) { - node.fDeleted= true; + node.fDeleted = true; if (node.fHasChildren) - fNeedCleanup= true; + fNeedCleanup = true; fNodeMap.remove(hash); } } else { - final Node[] nodes= (Node[]) obj; - for (int i= 0; i < nodes.length; i++) { + final Node[] nodes = (Node[]) obj; + for (int i = 0; i < nodes.length; i++) { Node node = nodes[i]; if (node == null) return; if (!node.fDeleted && isNodeForSegments(node, segments, segmentCount, false)) { remove(nodes, i); - if (nodes[0] == null) + if (nodes[0] == null) fNodeMap.remove(hash); - node.fDeleted= true; + node.fDeleted = true; if (node.fHasChildren) - fNeedCleanup= true; + fNeedCleanup = true; return; } @@ -549,65 +550,65 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } private void remove(Node[] nodes, int i) { - int idx= lastValid(nodes, i); - if (idx > 0) { - nodes[i]= nodes[idx]; - nodes[idx]= null; - } + int idx = lastValid(nodes, i); + if (idx > 0) { + nodes[i] = nodes[idx]; + nodes[idx] = null; + } } private int lastValid(Node[] nodes, int left) { - int right= nodes.length-1; - while (left < right) { - int mid= (left+right+1)/2; // ==> mid > left - if (nodes[mid] == null) - right= mid-1; - else - left= mid; - } + int right = nodes.length - 1; + while (left < right) { + int mid = (left + right + 1) / 2; // ==> mid > left + if (nodes[mid] == null) + right = mid - 1; + else + left = mid; + } return right; } private void cleanup() { assert Thread.holdsLock(fLock); - fLastFolderNode= null; - + fLastFolderNode = null; + for (Iterator<Object> iterator = fNodeMap.values().iterator(); iterator.hasNext();) { - Object obj= iterator.next(); + Object obj = iterator.next(); if (obj instanceof Node) { if (isDeleted((Node) obj)) { iterator.remove(); } } else { - Node[] nodes= (Node[]) obj; - int j= 0; + Node[] nodes = (Node[]) obj; + int j = 0; for (int i = 0; i < nodes.length; i++) { final Node node = nodes[i]; if (node == null) { - if (j==0) { + if (j == 0) { iterator.remove(); - } + } break; } if (!isDeleted(node)) { if (i != j) { - nodes[j]= node; - nodes[i]= null; + nodes[j] = node; + nodes[i] = null; } j++; } else { - nodes[i]= null; + nodes[i] = null; } } } } } - + private boolean isDeleted(Node node) { - while(node != null) { + while (node != null) { if (node.fDeleted) return true; - node= node.fParent; + node = node.fParent; } return false; } @@ -616,10 +617,10 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit * Computes a case insensitive hash-code for file names. */ private int hashCode(char[] name) { - int h= 0; + int h = 0; final int len = name.length; for (int i = 0; i < len; i++) { - h = 31*h + Character.toUpperCase(name[i]); + h = 31 * h + Character.toUpperCase(name[i]); } return h; } @@ -649,30 +650,30 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit */ public <T> IFile[] findFilesForLocation(T location, LocationAdapter<T> adapter) { initFileExtensions(); - String name= adapter.extractName(location); - Node[] candidates= null; + String name = adapter.extractName(location); + Node[] candidates = null; synchronized (fLock) { initializeProjects(ResourcesPlugin.getWorkspace().getRoot().getProjects()); - Object obj= fNodeMap.get(hashCode(name.toCharArray())); + Object obj = fNodeMap.get(hashCode(name.toCharArray())); if (obj != null) { - candidates= convert(obj); - IFile[] result= extractMatchesForLocation(candidates, location, adapter); + candidates = convert(obj); + IFile[] result = extractMatchesForLocation(candidates, location, adapter); if (result.length > 0) return result; } - } - + } + // fall back to platform functionality return adapter.platformsFindFilesForLocation(location); } private Node[] convert(Object obj) { if (obj instanceof Node) - return new Node[] {(Node) obj}; + return new Node[] { (Node) obj }; - final Node[] nodes= (Node[]) obj; - final int len= lastValid(nodes, -1)+1; - final Node[] result= new Node[len]; + final Node[] nodes = (Node[]) obj; + final int len = lastValid(nodes, -1) + 1; + final Node[] result = new Node[len]; System.arraycopy(nodes, 0, result, 0, len); return result; } @@ -681,79 +682,79 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit * Returns an array of files for the given name. Search is limited to the supplied projects. */ public IFile[] findFilesByName(IPath relativeLocation, IProject[] projects, boolean ignoreCase) { - final int segCount= relativeLocation.segmentCount(); + final int segCount = relativeLocation.segmentCount(); if (segCount < 1) return NO_FILES; - - final String name= relativeLocation.lastSegment(); + + final String name = relativeLocation.lastSegment(); Node[] candidates; initFileExtensions(); synchronized (fLock) { initializeProjects(projects); - Object obj= fNodeMap.get(hashCode(name.toCharArray())); + Object obj = fNodeMap.get(hashCode(name.toCharArray())); if (obj == null) { return NO_FILES; } - candidates= convert(obj); - } - String suffix= relativeLocation.toString(); - while(suffix.startsWith("../")) { //$NON-NLS-1$ - suffix= suffix.substring(3); + candidates = convert(obj); + } + String suffix = relativeLocation.toString(); + while (suffix.startsWith("../")) { //$NON-NLS-1$ + suffix = suffix.substring(3); } - Set<String> prjset= new HashSet<>(); + Set<String> prjset = new HashSet<>(); for (IProject prj : projects) { prjset.add(prj.getName()); } return extractMatchesForName(candidates, name, suffix, ignoreCase, prjset); } - + /** * Selects the actual matches for the list of candidate nodes. */ - private IFile[] extractMatchesForName(Node[] candidates, String name, String suffix, boolean ignoreCase, Set<String> prjSet) { - final char[] n1= name.toCharArray(); + private IFile[] extractMatchesForName(Node[] candidates, String name, String suffix, boolean ignoreCase, + Set<String> prjSet) { + final char[] n1 = name.toCharArray(); final int namelen = n1.length; - int resultIdx= 0; - + int resultIdx = 0; + if (ignoreCase) { for (int j = 0; j < namelen; j++) { - n1[j]= Character.toUpperCase(n1[j]); + n1[j] = Character.toUpperCase(n1[j]); } } - final int suffixLen= suffix.length(); - final IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); - IFile[] result= null; + final int suffixLen = suffix.length(); + final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IFile[] result = null; outer: for (int i = 0; i < candidates.length; i++) { final Node node = candidates[i]; if (node.fHasFileLocationName && checkProject(node, prjSet)) { - final char[] n2= node.fResourceName; + final char[] n2 = node.fResourceName; if (namelen == n2.length) { for (int j = 0; j < n2.length; j++) { - final char c= ignoreCase ? Character.toUpperCase(n2[j]) : n2[j]; - if (c != n1[j]) + final char c = ignoreCase ? Character.toUpperCase(n2[j]) : n2[j]; + if (c != n1[j]) continue outer; } - final IFile file= root.getFile(createPath(node)); - final URI loc= file.getLocationURI(); + final IFile file = root.getFile(createPath(node)); + final URI loc = file.getLocationURI(); if (loc != null) { - String path= loc.getPath(); - final int len= path.length(); - if (len >= suffixLen && - suffix.regionMatches(ignoreCase, 0, path, len-suffixLen, suffixLen)) { - if (result == null) - result= new IFile[candidates.length-i]; - result[resultIdx++]= root.getFile(createPath(node)); - } + String path = loc.getPath(); + final int len = path.length(); + if (len >= suffixLen && suffix.regionMatches(ignoreCase, 0, path, len - suffixLen, suffixLen)) { + if (result == null) + result = new IFile[candidates.length - i]; + result[resultIdx++] = root.getFile(createPath(node)); + } } } } } - if (result==null) + if (result == null) return NO_FILES; - + if (resultIdx < result.length) { - IFile[] copy= new IFile[resultIdx]; + IFile[] copy = new IFile[resultIdx]; System.arraycopy(result, 0, copy, 0, resultIdx); return copy; } @@ -761,13 +762,13 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit } private boolean checkProject(Node node, Set<String> prjSet) { - while(true) { - final Node n= node.fParent; + while (true) { + final Node n = node.fParent; if (n == fRootNode) break; if (n == null) return false; - node= n; + node = n; } return prjSet.contains(new String(node.fResourceName)); } @@ -781,47 +782,47 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit return createPath(node.fParent).append(new String(node.fResourceName)); } - + /** * Selects the actual matches from the list of candidates */ private <T> IFile[] extractMatchesForLocation(Node[] candidates, T location, LocationAdapter<T> adapter) { - final IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); - final String searchPath= adapter.getCanonicalPath(location); - IFile[] result= null; - int resultIdx= 0; + final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + final String searchPath = adapter.getCanonicalPath(location); + IFile[] result = null; + int resultIdx = 0; for (int i = 0; i < candidates.length; i++) { final Node node = candidates[i]; if (node.fHasFileLocationName) { - final IFile file= root.getFile(createPath(node)); - final T loc= adapter.getLocation(file); + final IFile file = root.getFile(createPath(node)); + final T loc = adapter.getLocation(file); if (loc != null) { if (!loc.equals(location)) { - if (searchPath == null) + if (searchPath == null) continue; - + if (node.fCanonicHash != 0 && node.fCanonicHash != searchPath.hashCode()) continue; - - final String candPath= adapter.getCanonicalPath(loc); + + final String candPath = adapter.getCanonicalPath(loc); if (candPath == null) continue; - - node.fCanonicHash= candPath.hashCode(); + + node.fCanonicHash = candPath.hashCode(); if (!candPath.equals(searchPath)) continue; } - if (result == null) - result= new IFile[candidates.length-i]; - result[resultIdx++]= root.getFile(createPath(node)); + if (result == null) + result = new IFile[candidates.length - i]; + result[resultIdx++] = root.getFile(createPath(node)); } } } - if (result==null) + if (result == null) return NO_FILES; - + if (resultIdx < result.length) { - IFile[] copy= new IFile[resultIdx]; + IFile[] copy = new IFile[resultIdx]; System.arraycopy(result, 0, copy, 0, resultIdx); return copy; } @@ -830,10 +831,10 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit @SuppressWarnings("nls") public void dump() { - List<String> lines= new ArrayList<>(); + List<String> lines = new ArrayList<>(); synchronized (fLock) { for (Iterator<Object> iterator = fNodeMap.values().iterator(); iterator.hasNext();) { - Node[] nodes= convert(iterator.next()); + Node[] nodes = convert(iterator.next()); for (int i = 0; i < nodes.length; i++) { final Node node = nodes[i]; if (node == null) { @@ -856,7 +857,7 @@ class ResourceLookupTree implements IResourceChangeListener, IResourceDeltaVisit private String toString(Node node) { if (node == fRootNode) return ""; - + return toString(node.fParent) + "/" + new String(node.fResourceName); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/SingleCharReader.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/SingleCharReader.java index 98c87c08884..225294de002 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/SingleCharReader.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/SingleCharReader.java @@ -17,51 +17,49 @@ package org.eclipse.cdt.internal.autotools.ui; import java.io.IOException; import java.io.Reader; - public abstract class SingleCharReader extends Reader { - + /** * @see Reader#read(char) */ @Override public abstract int read() throws IOException; - /** * @see Reader#read(char[],int,int) */ @Override public int read(char cbuf[], int off, int len) throws IOException { - int end= off + len; - for (int i= off; i < end; i++) { - int ch= read(); + int end = off + len; + for (int i = off; i < end; i++) { + int ch = read(); if (ch == -1) { if (i == off) { return -1; } return i - off; } - cbuf[i]= (char)ch; + cbuf[i] = (char) ch; } return len; - } - + } + /** * @see Reader#ready() - */ - @Override + */ + @Override public boolean ready() throws IOException { return true; } - + /** * Gets the content as a String */ public String getString() throws IOException { - StringBuilder buf= new StringBuilder(); + StringBuilder buf = new StringBuilder(); int ch; - while ((ch= read()) != -1) { - buf.append((char)ch); + while ((ch = read()) != -1) { + buf.append((char) ch); } return buf.toString(); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/SubstitutionTextReader.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/SubstitutionTextReader.java index e14ef2e72e9..7a42f82937e 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/SubstitutionTextReader.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/SubstitutionTextReader.java @@ -14,120 +14,117 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui; - import java.io.IOException; import java.io.Reader; - /** * Reads the text contents from a reader and computes for each character - * a potential substitution. The substitution may eat more characters than + * a potential substitution. The substitution may eat more characters than * only the one passed into the computation routine. */ public abstract class SubstitutionTextReader extends SingleCharReader { - - protected static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - + + protected static final String LINE_DELIM = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + private Reader fReader; private boolean fWasWhiteSpace; private int fCharAfterWhiteSpace; - + private boolean fReadFromBuffer; private StringBuilder fBuffer; private int fIndex; - protected SubstitutionTextReader(Reader reader) { - fReader= reader; - fBuffer= new StringBuilder(); - fIndex= 0; - fReadFromBuffer= false; - fCharAfterWhiteSpace= -1; - fWasWhiteSpace= true; + fReader = reader; + fBuffer = new StringBuilder(); + fIndex = 0; + fReadFromBuffer = false; + fCharAfterWhiteSpace = -1; + fWasWhiteSpace = true; } - + /** - * Implement to compute the substitution for the given character and + * Implement to compute the substitution for the given character and * if necessary subsequent characters. Use <code>nextChar</code> * to read subsequent characters. */ protected abstract String computeSubstitution(int c) throws IOException; - + /** * Returns the internal reader. */ protected Reader getReader() { return fReader; } - + /** * Returns the next character. */ protected int nextChar() throws IOException { - fReadFromBuffer= (fBuffer.length() > 0); + fReadFromBuffer = (fBuffer.length() > 0); if (fReadFromBuffer) { - char ch= fBuffer.charAt(fIndex++); + char ch = fBuffer.charAt(fIndex++); if (fIndex >= fBuffer.length()) { fBuffer.setLength(0); - fIndex= 0; + fIndex = 0; } return ch; } - int ch= fCharAfterWhiteSpace; + int ch = fCharAfterWhiteSpace; if (ch == -1) { - ch= fReader.read(); + ch = fReader.read(); } - if (Character.isWhitespace((char)ch)) { + if (Character.isWhitespace((char) ch)) { do { - ch= fReader.read(); - } while (Character.isWhitespace((char)ch)); + ch = fReader.read(); + } while (Character.isWhitespace((char) ch)); if (ch != -1) { - fCharAfterWhiteSpace= ch; + fCharAfterWhiteSpace = ch; return ' '; } } else { - fCharAfterWhiteSpace= -1; + fCharAfterWhiteSpace = -1; } return ch; } - + @Override public int read() throws IOException { int c; do { - - c= nextChar(); + + c = nextChar(); while (!fReadFromBuffer) { - String s= computeSubstitution(c); + String s = computeSubstitution(c); if (s == null) break; if (s.length() > 0) fBuffer.insert(0, s); - c= nextChar(); + c = nextChar(); } - + } while (fWasWhiteSpace && (c == ' ')); - - fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n'); + + fWasWhiteSpace = (c == ' ' || c == '\r' || c == '\n'); return c; } - - @Override + + @Override public boolean ready() throws IOException { return fReader.ready(); } - + @Override public void close() throws IOException { fReader.close(); } - + @Override public void reset() throws IOException { fReader.reset(); - fWasWhiteSpace= true; - fCharAfterWhiteSpace= -1; + fWasWhiteSpace = true; + fCharAfterWhiteSpace = -1; fBuffer.setLength(0); - fIndex= 0; + fIndex = 0; } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AbstractAutotoolsHandler.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AbstractAutotoolsHandler.java index 52ad6b5294a..6cdec5f7c93 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AbstractAutotoolsHandler.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AbstractAutotoolsHandler.java @@ -61,7 +61,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.handlers.HandlerUtil; public abstract class AbstractAutotoolsHandler extends AbstractHandler { - + private IContainer fContainer; protected abstract void run(Shell activeShell); @@ -69,7 +69,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler { protected Object execute1(ExecutionEvent event) { ISelection k = HandlerUtil.getCurrentSelection(event); if (!k.isEmpty() && k instanceof IStructuredSelection) { - Object obj = ((IStructuredSelection)k).getFirstElement(); + Object obj = ((IStructuredSelection) k).getFirstElement(); IContainer container = getContainer(obj); if (container != null) { setSelectedContainer(container); @@ -84,32 +84,32 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler { IContainer fContainer = null; if (obj instanceof Collection) { - Collection<Object> c = (Collection<Object>)obj; + Collection<Object> c = (Collection<Object>) obj; Object[] objArray = c.toArray(); if (objArray.length > 0) obj = objArray[0]; } if (obj instanceof ICElement) { - if ( obj instanceof ICContainer || obj instanceof ICProject) { + if (obj instanceof ICContainer || obj instanceof ICProject) { fContainer = (IContainer) ((ICElement) obj).getUnderlyingResource(); } else { - obj = ((ICElement)obj).getResource(); - if ( obj != null) { - fContainer = ((IResource)obj).getParent(); + obj = ((ICElement) obj).getResource(); + if (obj != null) { + fContainer = ((IResource) obj).getParent(); } } } else if (obj instanceof IResource) { if (obj instanceof IContainer) { fContainer = (IContainer) obj; } else { - fContainer = ((IResource)obj).getParent(); + fContainer = ((IResource) obj).getParent(); } } else { fContainer = null; } return fContainer; } - + public final String SHELL_COMMAND = "sh"; //$NON-NLS-1$ protected void showError(String title, String content) { @@ -118,7 +118,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler { /** * Separate targets to array from a string. - * + * * @param rawArgList * @return targets in string[] array. if targets are not formatted properly, * returns null @@ -261,7 +261,7 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler { } return cwd; } - + protected void executeConsoleCommand(final String actionName, final String command, final List<String> argumentList, final IPath execDir) { // We need to use a workspace root scheduling rule because adding diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AutomakeHandler.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AutomakeHandler.java index 98353e63921..c9a38cfd3cd 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AutomakeHandler.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AutomakeHandler.java @@ -47,8 +47,7 @@ public class AutomakeHandler extends AbstractAutotoolsHandler { TwoInputDialog optionDialog = new TwoInputDialog(activeShell, cwd, InvokeMessages.getString("InvokeAutomakeAction.windowTitle.options"), //$NON-NLS-1$ InvokeMessages.getString("InvokeAutomakeAction.message.options.otherOptions"), //$NON-NLS-1$ - InvokeMessages - .getString("InvokeAutomakeAction.message.options.makeTargets"), //$NON-NLS-1$ + InvokeMessages.getString("InvokeAutomakeAction.message.options.makeTargets"), //$NON-NLS-1$ DEFAULT_OPTION, null); optionDialog.open(); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeMessages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeMessages.java index ebe4b2e7056..f1e8cd49e04 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeMessages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeMessages.java @@ -20,8 +20,7 @@ import java.util.ResourceBundle; public class InvokeMessages { private static final String BUNDLE_NAME = InvokeMessages.class.getName(); - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private InvokeMessages() { } @@ -29,7 +28,7 @@ public class InvokeMessages { /** * Returns the string from the resource bundle, * or 'key' if not found. - * + * * @param key the message key * @return the resource bundle message */ @@ -40,17 +39,17 @@ public class InvokeMessages { return '!' + key + '!'; } } - + /** * Returns the formatted string from the resource bundle, * or 'key' if not found. - * + * * @param key the message key * @param args an array of substituition strings * @return the resource bundle message */ public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getString(key), (Object[])args); + return MessageFormat.format(getString(key), (Object[]) args); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/SingleInputDialog.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/SingleInputDialog.java index d7fedbb7ab0..edc47b4f791 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/SingleInputDialog.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/SingleInputDialog.java @@ -24,12 +24,11 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; public class SingleInputDialog extends InputDialog { - + private String firstMessage; - public SingleInputDialog(Shell parentShell, String firstMessage, String dialogTitle, - String dialogMessage, String initialValue, - IInputValidator validator) { + public SingleInputDialog(Shell parentShell, String firstMessage, String dialogTitle, String dialogMessage, + String initialValue, IInputValidator validator) { super(parentShell, dialogTitle, dialogMessage, initialValue, validator); this.firstMessage = firstMessage; @@ -43,8 +42,7 @@ public class SingleInputDialog extends InputDialog { CLabel label0 = new CLabel(composite, SWT.WRAP); label0.setText(firstMessage); - GridData data = new GridData(GridData.GRAB_HORIZONTAL - | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL + GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); label0.setLayoutData(data); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/TwoInputDialog.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/TwoInputDialog.java index 00a216bdf21..659f5d90fa6 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/TwoInputDialog.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/TwoInputDialog.java @@ -32,12 +32,11 @@ public class TwoInputDialog extends InputDialog { private String secondValue; private String secondMessage; - + private String firstMessage; - public TwoInputDialog(Shell parentShell, String firstMessage, String dialogTitle, - String dialogMessage, String secondMessage, String initialValue, - IInputValidator validator) { + public TwoInputDialog(Shell parentShell, String firstMessage, String dialogTitle, String dialogMessage, + String secondMessage, String initialValue, IInputValidator validator) { super(parentShell, dialogTitle, dialogMessage, initialValue, validator); this.firstMessage = firstMessage; @@ -64,19 +63,16 @@ public class TwoInputDialog extends InputDialog { label0.setText(firstMessage); Label label = new Label(composite, SWT.WRAP); label.setText(secondMessage); - GridData data = new GridData(GridData.GRAB_HORIZONTAL - | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL + GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); label0.setLayoutData(data); label0.setFont(parent.getFont()); label.setLayoutData(data); label.setFont(parent.getFont()); - secondText = new Text(composite, SWT.SINGLE | SWT.BORDER); - secondText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL - | GridData.HORIZONTAL_ALIGN_FILL)); + secondText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); secondText.addModifyListener(e -> validateInput()); // remove error message dialog from focusing. @@ -88,7 +84,7 @@ public class TwoInputDialog extends InputDialog { /** * Returns the text area. - * + * * @return the text area */ protected Text getSecondText() { @@ -97,7 +93,7 @@ public class TwoInputDialog extends InputDialog { /** * Returns the string typed into this input dialog. - * + * * @return the input string */ public String getSecondValue() { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/ContainsFilter.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/ContainsFilter.java index fe7bc5ba156..9d2d57d4932 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/ContainsFilter.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/ContainsFilter.java @@ -25,37 +25,35 @@ import org.eclipse.jface.viewers.ViewerFilter; */ public class ContainsFilter extends ViewerFilter { - private String lookFor; + private String lookFor; - public void setLookFor(String lookFor) { - this.lookFor = lookFor; - } + public void setLookFor(String lookFor) { + this.lookFor = lookFor; + } - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (!(viewer instanceof TreeViewer)) { - return true; - } - TreeViewer treeViewer = (TreeViewer) viewer; - String currentLabel = ((ILabelProvider) treeViewer.getLabelProvider()) - .getText(element); - if (lookFor == null) { - return true; - } + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) { + if (!(viewer instanceof TreeViewer)) { + return true; + } + TreeViewer treeViewer = (TreeViewer) viewer; + String currentLabel = ((ILabelProvider) treeViewer.getLabelProvider()).getText(element); + if (lookFor == null) { + return true; + } if (currentLabel != null && currentLabel.toLowerCase().contains(lookFor)) { - return true; - } - return hasUnfilteredChild(treeViewer, element); - } + return true; + } + return hasUnfilteredChild(treeViewer, element); + } - private boolean hasUnfilteredChild(TreeViewer viewer, Object element) { - Object[] children = ((ITreeContentProvider) viewer.getContentProvider()) - .getChildren(element); - for (Object child :children) { - if (select(viewer, element, child)) { - return true; - } - } - return false; - } + private boolean hasUnfilteredChild(TreeViewer viewer, Object element) { + Object[] children = ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element); + for (Object child : children) { + if (select(viewer, element, child)) { + return true; + } + } + return false; + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/LexicalSortingAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/LexicalSortingAction.java index cd340ff3b64..0ee2c64f9ad 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/LexicalSortingAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/LexicalSortingAction.java @@ -22,27 +22,25 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.ViewerComparator; +public class LexicalSortingAction extends Action { + private static final String ACTION_NAME = "LexicalSortingAction"; //$NON-NLS-1$ + private static final String DIALOG_STORE_KEY = ACTION_NAME + ".sort"; //$NON-NLS-1$ -public class LexicalSortingAction extends Action { - - private static final String ACTION_NAME= "LexicalSortingAction"; //$NON-NLS-1$ - private static final String DIALOG_STORE_KEY= ACTION_NAME + ".sort"; //$NON-NLS-1$ - private LexicalCSorter fSorter; private TreeViewer fTreeViewer; - + public LexicalSortingAction() { super(CUIPlugin.getResourceString(ACTION_NAME + ".label")); //$NON-NLS-1$ - + setDescription(CUIPlugin.getResourceString(ACTION_NAME + ".description")); //$NON-NLS-1$ setToolTipText(CUIPlugin.getResourceString(ACTION_NAME + ".tooltip")); //$NON-NLS-1$ - + MakeUIImages.setImageDescriptors(this, MakeUIImages.T_TOOL, MakeUIImages.IMG_TOOLS_ALPHA_SORTING); - - fSorter= new LexicalCSorter(); + + fSorter = new LexicalCSorter(); } - + public void setTreeViewer(TreeViewer treeViewer) { fTreeViewer = treeViewer; boolean checked = CUIPlugin.getDefault().getDialogSettings().getBoolean(DIALOG_STORE_KEY); @@ -53,39 +51,46 @@ public class LexicalSortingAction extends Action { public void run() { valueChanged(isChecked(), true); } - + private void valueChanged(boolean on, boolean store) { setChecked(on); fTreeViewer.setComparator(on ? fSorter : null); - - String key= ACTION_NAME + ".tooltip" + (on ? ".on" : ".off"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + String key = ACTION_NAME + ".tooltip" + (on ? ".on" : ".off"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ setToolTipText(CUIPlugin.getResourceString(key)); - + if (store) { CUIPlugin.getDefault().getDialogSettings().put(DIALOG_STORE_KEY, on); } } - + private static class LexicalCSorter extends ViewerComparator { @Override public int category(Object obj) { if (obj instanceof ICElement) { - ICElement elem= (ICElement)obj; + ICElement elem = (ICElement) obj; switch (elem.getElementType()) { - case ICElement.C_MACRO: return 1; - case ICElement.C_INCLUDE: return 2; - - case ICElement.C_CLASS: return 3; - case ICElement.C_STRUCT: return 4; - case ICElement.C_UNION: return 5; - - case ICElement.C_FIELD: return 6; - case ICElement.C_FUNCTION: return 7; + case ICElement.C_MACRO: + return 1; + case ICElement.C_INCLUDE: + return 2; + + case ICElement.C_CLASS: + return 3; + case ICElement.C_STRUCT: + return 4; + case ICElement.C_UNION: + return 5; + + case ICElement.C_FIELD: + return 6; + case ICElement.C_FUNCTION: + return 7; } - + } return 0; } } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/autoconf/ProjectionFileUpdater.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/autoconf/ProjectionFileUpdater.java index 177a48c9939..c78899c6d04 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/autoconf/ProjectionFileUpdater.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/autoconf/ProjectionFileUpdater.java @@ -50,53 +50,51 @@ import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; import org.eclipse.jface.text.source.projection.ProjectionViewer; import org.eclipse.ui.texteditor.IDocumentProvider; - /** * ProjectionMakefileUpdater */ public class ProjectionFileUpdater implements IProjectionListener { private static class AutoconfProjectionAnnotation extends ProjectionAnnotation { - + private AutoconfElement fElement; private boolean fIsComment; - + public AutoconfProjectionAnnotation(AutoconfElement element, boolean isCollapsed, boolean isComment) { super(isCollapsed); fElement = element; fIsComment = isComment; } - + public AutoconfElement getElement() { return fElement; } - + public void setElement(AutoconfElement element) { fElement = element; } - + public boolean isComment() { return fIsComment; } - + } - public void install(AutoconfEditor editor, ProjectionViewer viewer) { - fEditor= editor; - fViewer= viewer; + fEditor = editor; + fViewer = viewer; fViewer.addProjectionListener(this); } - + public void uninstall() { if (isInstalled()) { projectionDisabled(); fViewer.removeProjectionListener(this); - fViewer= null; - fEditor= null; + fViewer = null; + fEditor = null; } } - + protected boolean isInstalled() { return fEditor != null; } @@ -128,49 +126,49 @@ public class ProjectionFileUpdater implements IProjectionListener { // we have to make sure that we disable first when getting an enable // message. projectionDisabled(); - - initialize(); - fParticipant= new ReconcilerParticipant(); + + initialize(); + fParticipant = new ReconcilerParticipant(); fEditor.addReconcilingParticipant(fParticipant); } - + @Override public void projectionDisabled() { - fCachedDocument= null; + fCachedDocument = null; if (fParticipant != null) { fEditor.addReconcilingParticipant(fParticipant); - fParticipant= null; + fParticipant = null; } } - + public void initialize() { - + if (!isInstalled()) return; - + initializePreferences(); - + try { - - IDocumentProvider provider= fEditor.getDocumentProvider(); - fCachedDocument= provider.getDocument(fEditor.getEditorInput()); - fAllowCollapsing= true; - -// IWorkingCopyManager manager= AutomakeEditorFactory.getDefault().getWorkingCopyManager(); - AutoconfElement fInput= fEditor.getRootElement(); - + + IDocumentProvider provider = fEditor.getDocumentProvider(); + fCachedDocument = provider.getDocument(fEditor.getEditorInput()); + fAllowCollapsing = true; + + // IWorkingCopyManager manager= AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + AutoconfElement fInput = fEditor.getRootElement(); + if (fInput != null) { ProjectionAnnotationModel model = fEditor.getAdapter(ProjectionAnnotationModel.class); if (model != null) { - Map<AutoconfProjectionAnnotation, Position> additions= computeAdditions(fInput); + Map<AutoconfProjectionAnnotation, Position> additions = computeAdditions(fInput); model.removeAllAnnotations(); model.replaceAnnotations(null, additions); } } - + } finally { - fCachedDocument= null; - fAllowCollapsing= false; + fCachedDocument = null; + fAllowCollapsing = false; } } @@ -184,55 +182,52 @@ public class ProjectionFileUpdater implements IProjectionListener { } private Map<AutoconfProjectionAnnotation, Position> computeAdditions(AutoconfElement root) { - Map<AutoconfProjectionAnnotation, Position> map= new HashMap<>(); + Map<AutoconfProjectionAnnotation, Position> map = new HashMap<>(); if (root instanceof AutoconfRootElement) computeAdditions(root.getChildren(), map); return map; } private void computeAdditions(Object[] elements, Map<AutoconfProjectionAnnotation, Position> map) { - for (int i= 0; i < elements.length; i++) { - AutoconfElement element= (AutoconfElement)elements[i]; - + for (int i = 0; i < elements.length; i++) { + AutoconfElement element = (AutoconfElement) elements[i]; + computeAdditions(element, map); - - if (element.hasChildren()) { + + if (element.hasChildren()) { computeAdditions(element.getChildren(), map); } } } private void computeAdditions(AutoconfElement element, Map<AutoconfProjectionAnnotation, Position> map) { - - boolean createProjection= false; - + + boolean createProjection = false; + @SuppressWarnings("unused") - boolean collapse= false; - - if (element instanceof AutoconfIfElement || - element instanceof AutoconfElseElement || - element instanceof AutoconfElifElement) { - collapse= fAllowCollapsing && fCollapseConditional; - createProjection= true; + boolean collapse = false; + + if (element instanceof AutoconfIfElement || element instanceof AutoconfElseElement + || element instanceof AutoconfElifElement) { + collapse = fAllowCollapsing && fCollapseConditional; + createProjection = true; } else if (element instanceof AutoconfMacroElement) { - collapse= fAllowCollapsing && fCollapseMacroDef; - createProjection= true; + collapse = fAllowCollapsing && fCollapseMacroDef; + createProjection = true; } else if (element instanceof AutoconfMacroArgumentElement) { - collapse= fAllowCollapsing && fCollapseMacroDef; - createProjection= true; + collapse = fAllowCollapsing && fCollapseMacroDef; + createProjection = true; } else if (element instanceof AutoconfCaseElement) { - collapse= fAllowCollapsing && fCollapseCase; - createProjection= true; - } else if (element instanceof AutoconfForElement || - element instanceof AutoconfWhileElement || - element instanceof AutoconfUntilElement || - element instanceof AutoconfSelectElement) { + collapse = fAllowCollapsing && fCollapseCase; + createProjection = true; + } else if (element instanceof AutoconfForElement || element instanceof AutoconfWhileElement + || element instanceof AutoconfUntilElement || element instanceof AutoconfSelectElement) { collapse = fAllowCollapsing && fCollapseLoop; createProjection = true; } - + if (createProjection) { - Position position= createProjectionPosition(element); + Position position = createProjectionPosition(element); if (position != null) { map.put(new AutoconfProjectionAnnotation(element, fAllowCollapsing, true), position); } @@ -250,7 +245,7 @@ public class ProjectionFileUpdater implements IProjectionListener { endLine = fCachedDocument.getLineOfOffset(element.getEndOffset()); if (startLine != endLine) { - offset= fCachedDocument.getLineOffset(startLine); + offset = fCachedDocument.getLineOffset(startLine); int endOffset = fCachedDocument.getLineOffset(endLine) + fCachedDocument.getLineLength(endLine); return new Position(offset, endOffset - offset); } @@ -264,40 +259,39 @@ public class ProjectionFileUpdater implements IProjectionListener { public void processReconcile() { if (!isInstalled()) return; - - ProjectionAnnotationModel model= fEditor.getAdapter(ProjectionAnnotationModel.class); + + ProjectionAnnotationModel model = fEditor.getAdapter(ProjectionAnnotationModel.class); if (model == null) return; - + try { - IDocumentProvider provider= fEditor.getDocumentProvider(); - fCachedDocument= provider.getDocument(fEditor.getEditorInput()); - fAllowCollapsing= false; - - Map<AutoconfProjectionAnnotation, Position> additions= new HashMap<>(); - List<AutoconfProjectionAnnotation> deletions= new ArrayList<>(); + IDocumentProvider provider = fEditor.getDocumentProvider(); + fCachedDocument = provider.getDocument(fEditor.getEditorInput()); + fAllowCollapsing = false; + + Map<AutoconfProjectionAnnotation, Position> additions = new HashMap<>(); + List<AutoconfProjectionAnnotation> deletions = new ArrayList<>(); List<AutoconfProjectionAnnotation> updates = new ArrayList<>(); - - Map<AutoconfProjectionAnnotation, Position> updated= computeAdditions(fEditor.getRootElement()); - - Map<AutoconfElement, List<AutoconfProjectionAnnotation>> previous= createAnnotationMap(model); - - - Iterator<AutoconfProjectionAnnotation> e= updated.keySet().iterator(); + + Map<AutoconfProjectionAnnotation, Position> updated = computeAdditions(fEditor.getRootElement()); + + Map<AutoconfElement, List<AutoconfProjectionAnnotation>> previous = createAnnotationMap(model); + + Iterator<AutoconfProjectionAnnotation> e = updated.keySet().iterator(); while (e.hasNext()) { - AutoconfProjectionAnnotation annotation= e.next(); - AutoconfElement element= annotation.getElement(); - Position position= updated.get(annotation); - - List<AutoconfProjectionAnnotation> annotations= previous.get(element); + AutoconfProjectionAnnotation annotation = e.next(); + AutoconfElement element = annotation.getElement(); + Position position = updated.get(annotation); + + List<AutoconfProjectionAnnotation> annotations = previous.get(element); if (annotations == null) { additions.put(annotation, position); } else { - Iterator<AutoconfProjectionAnnotation> x= annotations.iterator(); + Iterator<AutoconfProjectionAnnotation> x = annotations.iterator(); while (x.hasNext()) { - AutoconfProjectionAnnotation a= x.next(); + AutoconfProjectionAnnotation a = x.next(); if (annotation.isComment() == a.isComment()) { - Position p= model.getPosition(a); + Position p = model.getPosition(a); if (p != null && !position.equals(p)) { p.setOffset(position.getOffset()); p.setLength(position.getLength()); @@ -307,108 +301,109 @@ public class ProjectionFileUpdater implements IProjectionListener { break; } } - + if (annotations.isEmpty()) previous.remove(element); } } - + Iterator<List<AutoconfProjectionAnnotation>> e2 = previous.values().iterator(); while (e2.hasNext()) { - List<AutoconfProjectionAnnotation> list= e2.next(); - int size= list.size(); - for (int i= 0; i < size; i++) + List<AutoconfProjectionAnnotation> list = e2.next(); + int size = list.size(); + for (int i = 0; i < size; i++) deletions.add(list.get(i)); } match(model, deletions, additions, updates); - Annotation[] removals= new Annotation[deletions.size()]; + Annotation[] removals = new Annotation[deletions.size()]; deletions.toArray(removals); - Annotation[] changes= new Annotation[updates.size()]; + Annotation[] changes = new Annotation[updates.size()]; updates.toArray(changes); model.modifyAnnotations(removals, additions, changes); - + } finally { - fCachedDocument= null; - fAllowCollapsing= true; + fCachedDocument = null; + fAllowCollapsing = true; } } - private void match(ProjectionAnnotationModel model, List<AutoconfProjectionAnnotation> deletions, Map<AutoconfProjectionAnnotation, Position> additions, List<AutoconfProjectionAnnotation> changes) { + private void match(ProjectionAnnotationModel model, List<AutoconfProjectionAnnotation> deletions, + Map<AutoconfProjectionAnnotation, Position> additions, List<AutoconfProjectionAnnotation> changes) { if (deletions.isEmpty() || (additions.isEmpty() && changes.isEmpty())) return; - - List<AutoconfProjectionAnnotation> newDeletions= new ArrayList<>(); - List<AutoconfProjectionAnnotation> newChanges= new ArrayList<>(); - - Iterator<AutoconfProjectionAnnotation> deletionIterator= deletions.iterator(); + + List<AutoconfProjectionAnnotation> newDeletions = new ArrayList<>(); + List<AutoconfProjectionAnnotation> newChanges = new ArrayList<>(); + + Iterator<AutoconfProjectionAnnotation> deletionIterator = deletions.iterator(); outer: while (deletionIterator.hasNext()) { - AutoconfProjectionAnnotation deleted= deletionIterator.next(); - Position deletedPosition= model.getPosition(deleted); + AutoconfProjectionAnnotation deleted = deletionIterator.next(); + Position deletedPosition = model.getPosition(deleted); if (deletedPosition == null) continue; - - Iterator<AutoconfProjectionAnnotation> changesIterator= changes.iterator(); + + Iterator<AutoconfProjectionAnnotation> changesIterator = changes.iterator(); while (changesIterator.hasNext()) { - AutoconfProjectionAnnotation changed= changesIterator.next(); + AutoconfProjectionAnnotation changed = changesIterator.next(); if (deleted.isComment() == changed.isComment()) { - Position changedPosition= model.getPosition(changed); + Position changedPosition = model.getPosition(changed); if (changedPosition == null) continue; - + if (deletedPosition.getOffset() == changedPosition.getOffset()) { - + deletedPosition.setLength(changedPosition.getLength()); deleted.setElement(changed.getElement()); - + deletionIterator.remove(); newChanges.add(deleted); - + changesIterator.remove(); newDeletions.add(changed); - + continue outer; } } } - - Iterator<AutoconfProjectionAnnotation> additionsIterator= additions.keySet().iterator(); + + Iterator<AutoconfProjectionAnnotation> additionsIterator = additions.keySet().iterator(); while (additionsIterator.hasNext()) { - AutoconfProjectionAnnotation added= additionsIterator.next(); + AutoconfProjectionAnnotation added = additionsIterator.next(); if (deleted.isComment() == added.isComment()) { - Position addedPosition= additions.get(added); - + Position addedPosition = additions.get(added); + if (deletedPosition.getOffset() == addedPosition.getOffset()) { - + deletedPosition.setLength(addedPosition.getLength()); deleted.setElement(added.getElement()); - + deletionIterator.remove(); newChanges.add(deleted); - + additionsIterator.remove(); - + break; } } } } - + deletions.addAll(newDeletions); changes.addAll(newChanges); } private Map<AutoconfElement, List<AutoconfProjectionAnnotation>> createAnnotationMap(IAnnotationModel model) { - Map<AutoconfElement, List<AutoconfProjectionAnnotation>> map= new HashMap<>(); + Map<AutoconfElement, List<AutoconfProjectionAnnotation>> map = new HashMap<>(); Iterator<Annotation> e = model.getAnnotationIterator(); while (e.hasNext()) { Annotation annotation = e.next(); if (annotation instanceof AutoconfProjectionAnnotation) { - AutoconfProjectionAnnotation directive= (AutoconfProjectionAnnotation) annotation; - List<AutoconfProjectionAnnotation> list= map.get(directive.getElement()); + AutoconfProjectionAnnotation directive = (AutoconfProjectionAnnotation) annotation; + List<AutoconfProjectionAnnotation> list = map.get(directive.getElement()); if (list == null) { - list= new ArrayList<>(2); + list = new ArrayList<>(2); map.put(directive.getElement(), list); } list.add(directive); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractElementListSelectionDialog.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractElementListSelectionDialog.java index dff7caeecbe..a05cfb1475d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractElementListSelectionDialog.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractElementListSelectionDialog.java @@ -34,76 +34,81 @@ import org.eclipse.swt.widgets.Shell; * A class to select one or more elements out of an indexed property */ public abstract class AbstractElementListSelectionDialog extends SelectionStatusDialog { - + private ILabelProvider fRenderer; private boolean fIgnoreCase; private boolean fIsMultipleSelection; - + private SelectionList fSelectionList; private Label fMessage; - private ISelectionValidator fValidator; - + private ISelectionValidator fValidator; + private String fMessageText; private String fEmptyListMessage; private String fNothingSelectedMessage; - + private StatusInfo fCurrStatus; - + protected void access$superOpen() { super.open(); } + @Override protected void cancelPressed() { setResult(null); super.cancelPressed(); } + protected Point computeInitialSize() { return new Point(convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(18)); } + @Override protected Control createDialogArea(Composite parent) { - Composite contents= (Composite)super.createDialogArea(parent); - - fMessage= createMessage(contents); - - int flags= fIsMultipleSelection ? SWT.MULTI : SWT.SINGLE; - fSelectionList= new SelectionList(contents, flags | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, - fRenderer, fIgnoreCase); - + Composite contents = (Composite) super.createDialogArea(parent); + + fMessage = createMessage(contents); + + int flags = fIsMultipleSelection ? SWT.MULTI : SWT.SINGLE; + fSelectionList = new SelectionList(contents, flags | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, fRenderer, + fIgnoreCase); + fSelectionList.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { handleDoubleClick(); } + @Override public void widgetSelected(SelectionEvent e) { verifyCurrentSelection(); } }); - GridData spec= new GridData(); - Point initialSize= computeInitialSize(); - spec.widthHint= initialSize.x; - spec.heightHint= initialSize.y; - spec.grabExcessVerticalSpace= true; - spec.grabExcessHorizontalSpace= true; - spec.horizontalAlignment= GridData.FILL; - spec.verticalAlignment= GridData.FILL; + GridData spec = new GridData(); + Point initialSize = computeInitialSize(); + spec.widthHint = initialSize.x; + spec.heightHint = initialSize.y; + spec.grabExcessVerticalSpace = true; + spec.grabExcessHorizontalSpace = true; + spec.horizontalAlignment = GridData.FILL; + spec.verticalAlignment = GridData.FILL; fSelectionList.setLayoutData(spec); - + return contents; } + /** * Creates the message text widget and sets layout data. */ protected Label createMessage(Composite parent) { - Label text= new Label(parent, SWT.NULL); + Label text = new Label(parent, SWT.NULL); text.setText(fMessageText); - GridData spec= new GridData(); - spec.grabExcessVerticalSpace= false; - spec.grabExcessHorizontalSpace= true; - spec.horizontalAlignment= GridData.FILL; - spec.verticalAlignment= GridData.BEGINNING; + GridData spec = new GridData(); + spec.grabExcessVerticalSpace = false; + spec.grabExcessHorizontalSpace = true; + spec.horizontalAlignment = GridData.FILL; + spec.verticalAlignment = GridData.BEGINNING; text.setLayoutData(spec); return text; } @@ -111,27 +116,30 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus @Override public void create() { super.create(); - if (isEmptyList()) { - fMessage.setEnabled(false); - fSelectionList.setEnabled(false); - } else { - verifyCurrentSelection(); + if (isEmptyList()) { + fMessage.setEnabled(false); + fSelectionList.setEnabled(false); + } else { + verifyCurrentSelection(); fSelectionList.selectFilterText(); fSelectionList.setFocus(); - } + } } + /** * Returns the currently used filter text. */ protected String getFilter() { return fSelectionList.getFilter(); } + /** * Returns the selection indices. */ protected int[] getSelectionIndices() { return fSelectionList.getSelectionIndices(); } + /** * Returns the widget selection. Returns empty list when the widget is not * usable. @@ -139,13 +147,15 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus protected List<Object> getWidgetSelection() { if (fSelectionList == null || fSelectionList.isDisposed()) return new ArrayList<>(0); - return fSelectionList.getSelection(); + return fSelectionList.getSelection(); } + /** * An element as been selected in the list by double clicking on it. * Emulate a OK button pressed to close the dialog. - */ + */ protected abstract void handleDoubleClick(); + /** * Checks whether the list of elements is empty or not. */ @@ -154,42 +164,48 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus return true; return fSelectionList.isEmptyList(); } + /** * Constructs a list selection dialog. * @param renderer The label renderer used * @param ignoreCase Decides if the match string ignores lower/upppr case - * @param multipleSelection Allow multiple selection + * @param multipleSelection Allow multiple selection */ - protected AbstractElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) { + protected AbstractElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, + boolean ignoreCase, boolean multipleSelection) { super(parent); setTitle(title); setImage(image); - fRenderer= renderer; - fIgnoreCase= ignoreCase; - fIsMultipleSelection= multipleSelection; - - fMessageText= ""; //$NON-NLS-1$ - - fCurrStatus= new StatusInfo(); - - fValidator= null; - fEmptyListMessage= ""; //$NON-NLS-1$ - fNothingSelectedMessage= ""; //$NON-NLS-1$ + fRenderer = renderer; + fIgnoreCase = ignoreCase; + fIsMultipleSelection = multipleSelection; + + fMessageText = ""; //$NON-NLS-1$ + + fCurrStatus = new StatusInfo(); + + fValidator = null; + fEmptyListMessage = ""; //$NON-NLS-1$ + fNothingSelectedMessage = ""; //$NON-NLS-1$ } + /** * Constructs a list selection dialog. * @param renderer The label renderer used * @param ignoreCase Decides if the match string ignores lower/upppr case - * @param multipleSelection Allow multiple selection + * @param multipleSelection Allow multiple selection */ - protected AbstractElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) { + protected AbstractElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, + boolean multipleSelection) { this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$ } + @Override public int open() { BusyIndicator.showWhile(null, () -> access$superOpen()); - return getReturnCode() ; + return getReturnCode(); } + /** * Refilters the current list according to the filter entered into the * text edit field. @@ -197,33 +213,38 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus protected void refilter() { fSelectionList.filter(true); } + /** * If a empty-list message is set, a error message is shown * Must be set before widget creation */ public void setEmptyListMessage(String message) { - fEmptyListMessage= message; + fEmptyListMessage = message; } + /** * Sets the filter text to the given value. */ protected void setFilter(String text, boolean refilter) { fSelectionList.setFilter(text, refilter); } + /** * Sets the message to be shown above the match text field. * Must be set before widget creation */ @Override public void setMessage(String message) { - fMessageText= message; + fMessageText = message; } + /** * If the selection is empty, this message is shown */ public void setNothingSelectedMessage(String message) { - fNothingSelectedMessage= message; + fNothingSelectedMessage = message; } + /** * Selects the elements in the list determined by the given * selection indices. @@ -231,6 +252,7 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus protected void setSelection(int[] selection) { fSelectionList.setSelection(selection); } + /** * Initializes the selection list widget with the given list of * elements. @@ -238,20 +260,22 @@ public abstract class AbstractElementListSelectionDialog extends SelectionStatus protected void setSelectionListElements(List<Object> elements, boolean refilter) { fSelectionList.setElements(elements, refilter); } + /** * A validator can be set to check if the current selection * is valid */ public void setValidator(ISelectionValidator validator) { - fValidator= validator; + fValidator = validator; } + /** * Verifies the current selection and updates the status line * accordingly. */ protected boolean verifyCurrentSelection() { - List<Object> sel= getWidgetSelection(); - int length= sel.size(); + List<Object> sel = getWidgetSelection(); + int length = sel.size(); if (length > 0) { if (fValidator != null) { fValidator.isValid(sel.toArray(), fCurrStatus); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractMakefile.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractMakefile.java index 81d0fca8bb8..d828451beed 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractMakefile.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractMakefile.java @@ -31,15 +31,15 @@ import org.eclipse.cdt.make.core.makefile.ITargetRule; * statement : rule | macro_definition | comments | empty * rule : inference_rule | target_rule * inference_rule : target ':' <nl> ( <tab> command <nl> ) + - * target_rule : target [ ( target ) * ] ':' [ ( prerequisite ) * ] [ ';' command ] <nl> + * target_rule : target [ ( target ) * ] ':' [ ( prerequisite ) * ] [ ';' command ] <nl> [ ( command ) * ] - * macro_definition : string '=' (string)* + * macro_definition : string '=' (string)* * comments : ('#' (string) <nl>) * * empty : <nl> * command : <tab> prefix_command string <nl> * target : string * prefix_command : '-' | '@' | '+' - * internal_macro : "$<" | "$*" | "$@" | "$?" | "$%" + * internal_macro : "$<" | "$*" | "$@" | "$?" | "$%" */ public abstract class AbstractMakefile extends Parent implements IMakefile { @@ -59,7 +59,7 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { List<IRule> array = new ArrayList<>(stmts.length); for (int i = 0; i < stmts.length; i++) { if (stmts[i] instanceof IRule) { - array.add((IRule)stmts[i]); + array.add((IRule) stmts[i]); } } return array.toArray(new IRule[0]); @@ -83,7 +83,7 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { List<IInferenceRule> array = new ArrayList<>(rules.length); for (int i = 0; i < rules.length; i++) { if (rules[i] instanceof IInferenceRule) { - array.add((IInferenceRule)rules[i]); + array.add((IInferenceRule) rules[i]); } } return array.toArray(new IInferenceRule[0]); @@ -107,7 +107,7 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { List<ITargetRule> array = new ArrayList<>(trules.length); for (int i = 0; i < trules.length; i++) { if (trules[i] instanceof ITargetRule) { - array.add((ITargetRule)trules[i]); + array.add((ITargetRule) trules[i]); } } return array.toArray(new ITargetRule[0]); @@ -131,7 +131,7 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { List<IMacroDefinition> array = new ArrayList<>(stmts.length); for (int i = 0; i < stmts.length; i++) { if (stmts[i] instanceof IMacroDefinition) { - array.add((IMacroDefinition)stmts[i]); + array.add((IMacroDefinition) stmts[i]); } } return array.toArray(new IMacroDefinition[0]); @@ -155,7 +155,7 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { List<IMacroDefinition> array = new ArrayList<>(stmts.length); for (int i = 0; i < stmts.length; i++) { if (stmts[i] instanceof IMacroDefinition) { - array.add((IMacroDefinition)stmts[i]); + array.add((IMacroDefinition) stmts[i]); } } return array.toArray(new IMacroDefinition[0]); @@ -178,7 +178,7 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { List<IInferenceRule> array = new ArrayList<>(stmts.length); for (int i = 0; i < stmts.length; i++) { if (stmts[i] instanceof IInferenceRule) { - array.add((IInferenceRule)stmts[i]); + array.add((IInferenceRule) stmts[i]); } } return array.toArray(new IInferenceRule[0]); @@ -209,54 +209,29 @@ public abstract class AbstractMakefile extends Parent implements IMakefile { StringBuilder macroName = new StringBuilder(); 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); + 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); @@ -267,44 +242,67 @@ 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; + } + 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 { - buffer.append(c); + // nothing found + buffer.append('$').append(c); } - foundDollar = false; - break; + inMacro = false; + } else { + buffer.append(c); + } + foundDollar = false; + break; } } return buffer.toString(); } - + @Override public URI getFileURI() { return filename; } - + public void setFileURI(URI filename) { - this.filename = filename; - } - + this.filename = filename; + } @Override public IMakefile getMakefile() { return this; } - + @Override public IMakefileReaderProvider getMakefileReaderProvider() { return null; } - + @Override - public void parse(URI fileURI, - IMakefileReaderProvider makefileReaderProvider) throws IOException { + public void parse(URI fileURI, IMakefileReaderProvider makefileReaderProvider) throws IOException { // not used } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractMakefileCodeScanner.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractMakefileCodeScanner.java index b6ec594e158..8d3d062c79f 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractMakefileCodeScanner.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AbstractMakefileCodeScanner.java @@ -32,17 +32,16 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; - /** * AbstractMakefileEditorScanner */ public abstract class AbstractMakefileCodeScanner extends RuleBasedScanner { - private Map<String, Token> fTokenMap= new HashMap<>(); + private Map<String, Token> fTokenMap = new HashMap<>(); private String[] fPropertyNamesColor; /** * Preference keys for boolean preferences which are <code>true</code>, - * iff the corresponding token should be rendered bold. + * iff the corresponding token should be rendered bold. */ private String[] fPropertyNamesBold; /** @@ -50,42 +49,41 @@ public abstract class AbstractMakefileCodeScanner extends RuleBasedScanner { * iff the corresponding token should be rendered italic. */ private String[] fPropertyNamesItalic; - - /** + /** * Returns the list of preference keys which define the tokens * used in the rules of this scanner. */ abstract protected String[] getTokenProperties(); - + /** * Creates the list of rules controlling this scanner. */ abstract protected List<IRule> createRules(); - + /** * Must be called after the constructor has been called. */ public final void initialize() { - - fPropertyNamesColor= getTokenProperties(); - int length= fPropertyNamesColor.length; - fPropertyNamesBold= new String[length]; - fPropertyNamesItalic= new String[length]; - - for (int i= 0; i < length; i++) { - fPropertyNamesBold[i]= fPropertyNamesColor[i] + MakefileEditorPreferenceConstants.EDITOR_BOLD_SUFFIX; - fPropertyNamesItalic[i]= fPropertyNamesColor[i] + MakefileEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX; + + fPropertyNamesColor = getTokenProperties(); + int length = fPropertyNamesColor.length; + fPropertyNamesBold = new String[length]; + fPropertyNamesItalic = new String[length]; + + for (int i = 0; i < length; i++) { + fPropertyNamesBold[i] = fPropertyNamesColor[i] + MakefileEditorPreferenceConstants.EDITOR_BOLD_SUFFIX; + fPropertyNamesItalic[i] = fPropertyNamesColor[i] + MakefileEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX; addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i]); } - + initializeRules(); } private void initializeRules() { - List<IRule> rules= createRules(); + List<IRule> rules = createRules(); if (rules != null) { - IRule[] result= new IRule[rules.size()]; + IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); } @@ -101,23 +99,24 @@ public abstract class AbstractMakefileCodeScanner extends RuleBasedScanner { private int indexOf(String property) { if (property != null) { - int length= fPropertyNamesColor.length; - for (int i= 0; i < length; i++) { - if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBold[i]) || property.equals(fPropertyNamesItalic[i])) + int length = fPropertyNamesColor.length; + for (int i = 0; i < length; i++) { + if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBold[i]) + || property.equals(fPropertyNamesItalic[i])) return i; } } return -1; } - + public boolean affectsBehavior(PropertyChangeEvent event) { return indexOf(event.getProperty()) >= 0; } - + public void adaptToPreferenceChange(PropertyChangeEvent event) { - String p= event.getProperty(); - int index= indexOf(p); - Token token= getToken(fPropertyNamesColor[index]); + String p = event.getProperty(); + int index = indexOf(p); + Token token = getToken(fPropertyNamesColor[index]); if (fPropertyNamesColor[index].equals(p)) adaptToColorChange(event, token); else if (fPropertyNamesBold[index].equals(p)) @@ -127,49 +126,51 @@ public abstract class AbstractMakefileCodeScanner extends RuleBasedScanner { } protected void adaptToColorChange(PropertyChangeEvent event, Token token) { - RGB rgb= null; - Object value= event.getNewValue(); + RGB rgb = null; + Object value = event.getNewValue(); if (value instanceof RGB) { - rgb= (RGB) value; + rgb = (RGB) value; } else if (value instanceof String) { - rgb= StringConverter.asRGB((String) value); + rgb = StringConverter.asRGB((String) value); } - + if (rgb != null) { - TextAttribute attr= (TextAttribute) token.getData(); - token.setData(new TextAttribute(ColorManager.getDefault().getColor(rgb), attr.getBackground(), attr.getStyle())); + TextAttribute attr = (TextAttribute) token.getData(); + token.setData( + new TextAttribute(ColorManager.getDefault().getColor(rgb), attr.getBackground(), attr.getStyle())); } } protected void adaptToStyleChange(PropertyChangeEvent event, Token token, int styleAttribute) { - if (token == null) { + if (token == null) { return; } - boolean eventValue= false; - Object value= event.getNewValue(); + boolean eventValue = false; + Object value = event.getNewValue(); if (value instanceof Boolean) { - eventValue= ((Boolean) value).booleanValue(); + eventValue = ((Boolean) value).booleanValue(); } else if (IPreferenceStore.TRUE.equals(value)) { - eventValue= true; + eventValue = true; } - - TextAttribute attr= (TextAttribute) token.getData(); - boolean activeValue= (attr.getStyle() & styleAttribute) == styleAttribute; - if (activeValue != eventValue) { - token.setData(new TextAttribute(attr.getForeground(), attr.getBackground(), eventValue ? attr.getStyle() | styleAttribute : attr.getStyle() & ~styleAttribute)); + + TextAttribute attr = (TextAttribute) token.getData(); + boolean activeValue = (attr.getStyle() & styleAttribute) == styleAttribute; + if (activeValue != eventValue) { + token.setData(new TextAttribute(attr.getForeground(), attr.getBackground(), + eventValue ? attr.getStyle() | styleAttribute : attr.getStyle() & ~styleAttribute)); } } protected TextAttribute createTextAttribute(String colorID, String boldKey, String italicKey) { - Color color= null; + Color color = null; if (colorID != null) { - color= AutomakeEditorFactory.getPreferenceColor(colorID); + color = AutomakeEditorFactory.getPreferenceColor(colorID); } - IPreferenceStore store= AutotoolsPlugin.getDefault().getPreferenceStore(); - int style= store.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL; + IPreferenceStore store = AutotoolsPlugin.getDefault().getPreferenceStore(); + int style = store.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL; if (store.getBoolean(italicKey)) { style |= SWT.ITALIC; - } + } return new TextAttribute(color, null, style); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutoconfSubstRule.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutoconfSubstRule.java index 4beecf83c57..3fb85aef5be 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutoconfSubstRule.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutoconfSubstRule.java @@ -23,7 +23,7 @@ public class AutoconfSubstRule implements IPredicateRule { private IToken token; private char[][] fLineDelimiters; private char[][] fSortedLineDelimiters; - + private static class DecreasingCharArrayLengthComparator implements Comparator<Object> { @Override public int compare(Object o1, Object o2) { @@ -31,32 +31,32 @@ public class AutoconfSubstRule implements IPredicateRule { } } - private Comparator<Object> fLineDelimiterComparator= new DecreasingCharArrayLengthComparator(); + private Comparator<Object> fLineDelimiterComparator = new DecreasingCharArrayLengthComparator(); public AutoconfSubstRule(IToken token) { this.token = token; } - + @Override public IToken evaluate(ICharacterScanner scanner, boolean resume) { - char[][] originalDelimiters= scanner.getLegalLineDelimiters(); - int count= originalDelimiters.length; + char[][] originalDelimiters = scanner.getLegalLineDelimiters(); + int count = originalDelimiters.length; if (fLineDelimiters == null || originalDelimiters.length != count) { - fSortedLineDelimiters= new char[count][]; + fSortedLineDelimiters = new char[count][]; } else { - while (count > 0 && fLineDelimiters[count-1] == originalDelimiters[count-1]) + while (count > 0 && fLineDelimiters[count - 1] == originalDelimiters[count - 1]) count--; } if (count != 0) { - fLineDelimiters= originalDelimiters; + fLineDelimiters = originalDelimiters; System.arraycopy(fLineDelimiters, 0, fSortedLineDelimiters, 0, fLineDelimiters.length); Arrays.sort(fSortedLineDelimiters, fLineDelimiterComparator); } - + int c; boolean okToScan = resume; int charCount = 0; - + if (!resume) { // Not resuming. Verify first char is '@'. c = scanner.read(); @@ -65,7 +65,7 @@ public class AutoconfSubstRule implements IPredicateRule { okToScan = true; } } - + if (okToScan) { // We want to make sure we have a valid id (not @@) or (@_@). When // we resume, we have no choice but to assume it is valid so far. @@ -75,21 +75,19 @@ public class AutoconfSubstRule implements IPredicateRule { if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') { // A valid id has some alphabetic character in it. isId = true; - } - else if (c >= '0' && c <= '9' || c == '_') { + } else if (c >= '0' && c <= '9' || c == '_') { ; // continue - } - else if (c == '@' && isId) + } else if (c == '@' && isId) return getSuccessToken(); else break; ++charCount; } } - + for (int i = 0; i < charCount; ++i) scanner.unread(); - + return Token.UNDEFINED; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeCompletionProcessor.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeCompletionProcessor.java index ace622556ca..309ac934967 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeCompletionProcessor.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeCompletionProcessor.java @@ -1,7 +1,7 @@ /******************************************************************************* * Mostly copied from makefileCompletionProcessor which has the following * copyright notice: - * + * * Copyright (c) 2000, 2015 QNX Software Systems and others. * * This program and the accompanying materials @@ -38,185 +38,177 @@ import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.IEditorPart; - public class AutomakeCompletionProcessor implements IContentAssistProcessor { - /** - * Simple content assist tip closer. The tip is valid in a range - * of 5 characters around its popup location. - */ - protected static class Validator implements IContextInformationValidator, IContextInformationPresenter { - - protected int fInstallOffset; + /** + * Simple content assist tip closer. The tip is valid in a range + * of 5 characters around its popup location. + */ + protected static class Validator implements IContextInformationValidator, IContextInformationPresenter { - @Override - public boolean isContextInformationValid(int offset) { - return Math.abs(fInstallOffset - offset) < 5; - } - - @Override - public void install(IContextInformation info, ITextViewer viewer, int offset) { - fInstallOffset = offset; - } + protected int fInstallOffset; - @Override - public boolean updatePresentation(int documentPosition, TextPresentation presentation) { - return false; - } + @Override + public boolean isContextInformationValid(int offset) { + return Math.abs(fInstallOffset - offset) < 5; } - public static class DirectiveComparator implements Comparator<Object> { + @Override + public void install(IContextInformation info, ITextViewer viewer, int offset) { + fInstallOffset = offset; + } - @Override - public int compare(Object o1, Object o2) { - String name1; - String name2; + @Override + public boolean updatePresentation(int documentPosition, TextPresentation presentation) { + return false; + } + } - if (o1 instanceof IMacroDefinition) { - name1 = ((IMacroDefinition)o1).getName(); - } else if (o1 instanceof IRule) { - name1 = ((IRule)o1).getTarget().toString(); - } else { - name1 =""; //$NON-NLS-1$ - } + public static class DirectiveComparator implements Comparator<Object> { - if (o2 instanceof IMacroDefinition) { - name2 = ((IMacroDefinition)o1).getName(); - } else if (o2 instanceof IRule) { - name2 = ((IRule)o1).getTarget().toString(); - } else { - name2 =""; //$NON-NLS-1$ - } + @Override + public int compare(Object o1, Object o2) { + String name1; + String name2; + + if (o1 instanceof IMacroDefinition) { + name1 = ((IMacroDefinition) o1).getName(); + } else if (o1 instanceof IRule) { + name1 = ((IRule) o1).getTarget().toString(); + } else { + name1 = ""; //$NON-NLS-1$ + } - //return String.CASE_INSENSITIVE_ORDER.compare(name1, name2); - return name1.compareToIgnoreCase(name2); + if (o2 instanceof IMacroDefinition) { + name2 = ((IMacroDefinition) o1).getName(); + } else if (o2 instanceof IRule) { + name2 = ((IRule) o1).getTarget().toString(); + } else { + name2 = ""; //$NON-NLS-1$ } - - } - protected IContextInformationValidator fValidator = new Validator(); - protected Image imageMacro = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_MACRO); - protected Image imageTarget = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_TARGET_RULE); - protected CompletionProposalComparator comparator = new CompletionProposalComparator(); - protected IEditorPart fEditor; - protected IWorkingCopyManager fManager; + //return String.CASE_INSENSITIVE_ORDER.compare(name1, name2); + return name1.compareToIgnoreCase(name2); + } - public AutomakeCompletionProcessor(IEditorPart editor) { - fEditor = editor; - fManager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + } + + protected IContextInformationValidator fValidator = new Validator(); + protected Image imageMacro = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_MACRO); + protected Image imageTarget = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_TARGET_RULE); + + protected CompletionProposalComparator comparator = new CompletionProposalComparator(); + protected IEditorPart fEditor; + protected IWorkingCopyManager fManager; + + public AutomakeCompletionProcessor(IEditorPart editor) { + fEditor = editor; + fManager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + } + + @Override + public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { + WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset); + boolean macro = WordPartDetector.inMacro(viewer, documentOffset); + IMakefile makefile = fManager.getWorkingCopy(fEditor.getEditorInput()); + IDirective[] statements = null; + if (macro) { + IDirective[] m1 = makefile.getMacroDefinitions(); + IDirective[] m2 = makefile.getBuiltinMacroDefinitions(); + statements = new IDirective[m1.length + m2.length]; + System.arraycopy(m1, 0, statements, 0, m1.length); + System.arraycopy(m2, 0, statements, m1.length, m2.length); + } else { + statements = makefile.getTargetRules(); } - @Override - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { - WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset); - boolean macro = WordPartDetector.inMacro(viewer, documentOffset); - IMakefile makefile = fManager.getWorkingCopy(fEditor.getEditorInput()); - IDirective[] statements = null; - if (macro) { - IDirective[] m1 = makefile.getMacroDefinitions(); - IDirective[] m2 = makefile.getBuiltinMacroDefinitions(); - statements = new IDirective[m1.length + m2.length]; - System.arraycopy(m1, 0, statements, 0, m1.length); - System.arraycopy(m2, 0, statements, m1.length, m2.length); - } else { - statements = makefile.getTargetRules(); + ArrayList<ICompletionProposal> proposalList = new ArrayList<>(statements.length); + + // iterate over all the different categories + for (int i = 0; i < statements.length; i++) { + String name = null; + Image image = null; + String infoString = "";//getContentInfoString(name); //$NON-NLS-1$ + if (statements[i] instanceof IMacroDefinition) { + name = ((IMacroDefinition) statements[i]).getName(); + image = imageMacro; + infoString = ((IMacroDefinition) statements[i]).getValue().toString(); + } else if (statements[i] instanceof IRule) { + name = ((IRule) statements[i]).getTarget().toString(); + image = imageTarget; + infoString = name; } - - ArrayList<ICompletionProposal> proposalList = new ArrayList<>(statements.length); - - // iterate over all the different categories - for (int i = 0; i < statements.length; i++) { - String name = null; - Image image = null; - String infoString = "";//getContentInfoString(name); //$NON-NLS-1$ - if (statements[i] instanceof IMacroDefinition) { - name = ((IMacroDefinition) statements[i]).getName(); - image = imageMacro; - infoString = ((IMacroDefinition)statements[i]).getValue().toString(); - } else if (statements[i] instanceof IRule) { - name = ((IRule) statements[i]).getTarget().toString(); - image = imageTarget; - infoString = name; - } - if (name != null && name.startsWith(wordPart.toString())) { - 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); - proposalList.add(result); - } + if (name != null && name.startsWith(wordPart.toString())) { + 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); + proposalList.add(result); } - ICompletionProposal[] proposals = proposalList.toArray(new ICompletionProposal[0]); - Arrays.sort(proposals, comparator); - return proposals; } - - @Override - public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { - WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset); - boolean macro = WordPartDetector.inMacro(viewer, documentOffset); - IMakefile makefile = fManager.getWorkingCopy(fEditor.getEditorInput()); - ArrayList<String> contextList = new ArrayList<>(); - if (macro) { + ICompletionProposal[] proposals = proposalList.toArray(new ICompletionProposal[0]); + Arrays.sort(proposals, comparator); + return proposals; + } + + @Override + public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { + WordPartDetector wordPart = new WordPartDetector(viewer, documentOffset); + boolean macro = WordPartDetector.inMacro(viewer, documentOffset); + IMakefile makefile = fManager.getWorkingCopy(fEditor.getEditorInput()); + ArrayList<String> contextList = new ArrayList<>(); + if (macro) { IMacroDefinition[] statements = makefile.getMacroDefinitions(); - for (int i = 0; i < statements.length; i++) { + for (int i = 0; i < statements.length; i++) { String name = statements[i].getName(); if (name != null && name.equals(wordPart.toString())) { String value = statements[i].getValue().toString(); if (value != null && value.length() > 0) { contextList.add(value); - } - } + } } - statements = makefile.getBuiltinMacroDefinitions(); - for (int i = 0; i < statements.length; i++) { - if (statements[i] != null) { - String name = statements[i].getName(); - if (name != null && name.equals(wordPart.toString())) { - String value = statements[i].getValue().toString(); - if (value != null && value.length() > 0) { - contextList.add(value); - } + } + statements = makefile.getBuiltinMacroDefinitions(); + for (int i = 0; i < statements.length; i++) { + if (statements[i] != null) { + String name = statements[i].getName(); + if (name != null && name.equals(wordPart.toString())) { + String value = statements[i].getValue().toString(); + if (value != null && value.length() > 0) { + contextList.add(value); } } } } - - IContextInformation[] result = new IContextInformation[contextList.size()]; - for (int i = 0; i < result.length; i++) { - String context = contextList.get(i); - result[i] = new ContextInformation(imageMacro, wordPart.toString(), context); - } - return result; - } - @Override - public char[] getCompletionProposalAutoActivationCharacters() { - return null; + IContextInformation[] result = new IContextInformation[contextList.size()]; + for (int i = 0; i < result.length; i++) { + String context = contextList.get(i); + result[i] = new ContextInformation(imageMacro, wordPart.toString(), context); } + return result; - @Override - public char[] getContextInformationAutoActivationCharacters() { - return null; - } + } - @Override - public String getErrorMessage() { - return null; - } + @Override + public char[] getCompletionProposalAutoActivationCharacters() { + return null; + } + + @Override + public char[] getContextInformationAutoActivationCharacters() { + return null; + } + + @Override + public String getErrorMessage() { + return null; + } + + @Override + public IContextInformationValidator getContextInformationValidator() { + return fValidator; + } - @Override - public IContextInformationValidator getContextInformationValidator() { - return fValidator; - } - } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeConfigMacro.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeConfigMacro.java index eddb710b8b2..939265c2fa7 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeConfigMacro.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeConfigMacro.java @@ -14,20 +14,18 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - - public class AutomakeConfigMacro extends Directive { String name; - + public AutomakeConfigMacro(Directive parent, String name) { super(parent); this.name = name; } - + public String getName() { return name; } - + @Override public String toString() { return name + "\n"; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeDocumentProvider.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeDocumentProvider.java index cc50453cce4..1b693072f5a 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeDocumentProvider.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeDocumentProvider.java @@ -26,48 +26,47 @@ import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IURIEditorInput; import org.eclipse.ui.editors.text.TextFileDocumentProvider; +public class AutomakeDocumentProvider extends TextFileDocumentProvider implements IMakefileDocumentProvider { -public class AutomakeDocumentProvider extends TextFileDocumentProvider implements IMakefileDocumentProvider { - /** * Remembers a IMakefile for each element. */ - protected class AutomakefileFileInfo extends FileInfo { + protected class AutomakefileFileInfo extends FileInfo { public IMakefile fCopy; } - + @Override protected FileInfo createEmptyFileInfo() { return new AutomakefileFileInfo(); } - + @Override protected FileInfo createFileInfo(Object element) throws CoreException { IMakefile original = null; - if (element instanceof IFileEditorInput) { - IFileEditorInput input= (IFileEditorInput) element; + if (element instanceof IFileEditorInput) { + IFileEditorInput input = (IFileEditorInput) element; if (input.getFile().exists()) - original= createMakefile(input.getFile().getLocation().toOSString()); + original = createMakefile(input.getFile().getLocation().toOSString()); } else if (element instanceof IURIEditorInput) { - IURIEditorInput input = (IURIEditorInput)element; + IURIEditorInput input = (IURIEditorInput) element; original = createMakefile(input.getURI().getPath().toString()); } if (original == null) return null; - FileInfo info= super.createFileInfo(element); + FileInfo info = super.createFileInfo(element); if (!(info instanceof AutomakefileFileInfo)) { return null; } - AutomakefileFileInfo makefileInfo= (AutomakefileFileInfo) info; + AutomakefileFileInfo makefileInfo = (AutomakefileFileInfo) info; setUpSynchronization(makefileInfo); makefileInfo.fCopy = original; return makefileInfo; } - + /** */ private IMakefile createMakefile(String fileName) { @@ -80,37 +79,37 @@ public class AutomakeDocumentProvider extends TextFileDocumentProvider implement makefile = automakefile; return makefile; } - + @Override public IMakefile getWorkingCopy(Object element) { - FileInfo fileInfo= getFileInfo(element); + FileInfo fileInfo = getFileInfo(element); if (fileInfo instanceof AutomakefileFileInfo) { return ((AutomakefileFileInfo) fileInfo).fCopy; } return null; } - + @Override public void shutdown() { Iterator<?> e = getConnectedElementsIterator(); while (e.hasNext()) disconnect(e.next()); } - + @Override public void connect(Object element) throws CoreException { super.connect(element); IMakefile makefile = getWorkingCopy(element); - AutomakeErrorHandler errorHandler = new AutomakeErrorHandler((IEditorInput)element); + AutomakeErrorHandler errorHandler = new AutomakeErrorHandler((IEditorInput) element); errorHandler.update(makefile); } - + @Override public IDocument getDocument(Object element) { - FileInfo info= getFileInfo(element); + FileInfo info = getFileInfo(element); if (info != null) return info.fTextFileBuffer.getDocument(); return getParentProvider().getDocument(element); } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditor.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditor.java index 7b83ba7dfdd..c7d28d925a3 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditor.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditor.java @@ -28,32 +28,31 @@ import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.DefaultRangeIndicator; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - public class AutomakeEditor extends MakefileEditor { - + protected AutomakefileContentOutlinePage ampage; private AutomakefileSourceConfiguration sourceViewerConfiguration; private static AutomakeEditor fgInstance; private IEditorInput input; - + static { fgInstance = new AutomakeEditor(); } - - public AutomakeEditor() { - super(); - } - - /** - * Returns the default editor instance. - * - * @return the default editor instance - */ - public static AutomakeEditor getDefault() { - return fgInstance; - } - - @Override + + public AutomakeEditor() { + super(); + } + + /** + * Returns the default editor instance. + * + * @return the default editor instance + */ + public static AutomakeEditor getDefault() { + return fgInstance; + } + + @Override protected void doSetInput(IEditorInput newInput) throws CoreException { super.doSetInput(newInput); this.input = newInput; @@ -79,11 +78,11 @@ public class AutomakeEditor extends MakefileEditor { configureInsertMode(SMART_INSERT, false); setInsertMode(INSERT); } - + public AutomakeDocumentProvider getAutomakefileDocumentProvider() { return AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider(); } - + public AutomakefileContentOutlinePage getAutomakeOutlinePage() { if (ampage == null) { ampage = new AutomakefileContentOutlinePage(this); @@ -92,7 +91,7 @@ public class AutomakeEditor extends MakefileEditor { } return ampage; } - + @SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> key) { @@ -101,17 +100,17 @@ public class AutomakeEditor extends MakefileEditor { } return super.getAdapter(key); } - + public AutomakefileSourceConfiguration getAutomakeSourceViewerConfiguration() { return sourceViewerConfiguration; } - + public IMakefile getMakefile() { return getAutomakefileDocumentProvider().getWorkingCopy(this.getEditorInput()); } - + public ISourceViewer getAutomakeSourceViewer() { return getSourceViewer(); } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditorFactory.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditorFactory.java index be4d8cf6928..0423492ba71 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditorFactory.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditorFactory.java @@ -19,7 +19,6 @@ import org.eclipse.cdt.make.ui.IWorkingCopyManager; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.swt.graphics.Color; - public class AutomakeEditorFactory { private IWorkingCopyManager workingCopyManager; private AutomakeDocumentProvider automakeFileDocumentProvider; @@ -31,18 +30,18 @@ public class AutomakeEditorFactory { private AutomakeEditorFactory() { factory = this; } - + public synchronized AutomakeDocumentProvider getAutomakefileDocumentProvider() { if (automakeFileDocumentProvider == null) { - automakeFileDocumentProvider= new AutomakeDocumentProvider(); + automakeFileDocumentProvider = new AutomakeDocumentProvider(); } return automakeFileDocumentProvider; } public synchronized IWorkingCopyManager getWorkingCopyManager() { if (workingCopyManager == null) { - IMakefileDocumentProvider provider= getAutomakefileDocumentProvider(); - workingCopyManager= new WorkingCopyManager(provider); + IMakefileDocumentProvider provider = getAutomakefileDocumentProvider(); + workingCopyManager = new WorkingCopyManager(provider); } return workingCopyManager; } @@ -52,7 +51,8 @@ public class AutomakeEditorFactory { */ public static Color getPreferenceColor(String key) { //FIXME: what do we do with Makefile editor preferences? - return ColorManager.getDefault().getColor(PreferenceConverter.getColor(AutotoolsPlugin.getDefault().getPreferenceStore(), key)); + return ColorManager.getDefault() + .getColor(PreferenceConverter.getColor(AutotoolsPlugin.getDefault().getPreferenceStore(), key)); } public static AutomakeEditorFactory getDefault() { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeErrorHandler.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeErrorHandler.java index ff9fbaa1ac9..621f4d882be 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeErrorHandler.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeErrorHandler.java @@ -26,18 +26,16 @@ import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.AnnotationModel; import org.eclipse.ui.IEditorInput; - public class AutomakeErrorHandler { - public static final String AUTOMAKE_ERROR_MARKER_ID = AutotoolsUIPlugin.PLUGIN_ID - + ".parsefileerror"; - + public static final String AUTOMAKE_ERROR_MARKER_ID = AutotoolsUIPlugin.PLUGIN_ID + ".parsefileerror"; + private IDocument document; private AnnotationModel fAnnotationModel; public static final String CDT_ANNOTATION_INFO = "org.eclipse.cdt.ui.info"; public static final String CDT_ANNOTATION_WARNING = "org.eclipse.cdt.ui.warning"; public static final String CDT_ANNOTATION_ERROR = "org.eclipse.cdt.ui.error"; - + // TODO: no quickfixes yet implemented, but maybe in the future private static class AutomakeAnnotation extends Annotation implements IQuickFixableAnnotation { public AutomakeAnnotation(String annotationType, boolean persist, String message) { @@ -60,45 +58,44 @@ public class AutomakeErrorHandler { } } - + public AutomakeErrorHandler(IEditorInput input) { this.document = AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider().getDocument(input); - this.fAnnotationModel = (AnnotationModel)AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider().getAnnotationModel(input); + this.fAnnotationModel = (AnnotationModel) AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider() + .getAnnotationModel(input); } - public void update(IMakefile makefile) { removeExistingMarkers(); // Recursively process all the directives in the Makefile checkChildren(makefile); } - + private void checkChildren(IParent parent) { IDirective[] directives = parent.getDirectives(); for (int i = 0; i < directives.length; i++) { IDirective directive = directives[i]; if (directive instanceof IParent) { - checkChildren((IParent)directive); + checkChildren((IParent) directive); } else if (directive instanceof BadDirective) { int lineNumber = directive.getStartLine(); Integer charStart = getCharOffset(lineNumber - 1, 0); Integer charEnd = getCharOffset(directive.getEndLine() - 1, -1); - + String annotationType = CDT_ANNOTATION_ERROR; Annotation annotation = new AutomakeAnnotation(annotationType, true, "Bad directive"); //$NON-NLS-1$ - Position p = new Position(charStart.intValue(),charEnd.intValue() - charStart.intValue()); + Position p = new Position(charStart.intValue(), charEnd.intValue() - charStart.intValue()); fAnnotationModel.addAnnotation(annotation, p); } } return; } - + public void removeExistingMarkers() { fAnnotationModel.removeAllAnnotations(); } - - + private Integer getCharOffset(int lineNumber, int columnNumber) { try { if (columnNumber >= 0) diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeIfElse.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeIfElse.java index 83315b4732c..9ddfd34919f 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeIfElse.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeIfElse.java @@ -17,20 +17,25 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; public class AutomakeIfElse extends Parent { String condition; String type; + public AutomakeIfElse(Directive parent, String type, String condition) { super(parent); this.type = type; this.condition = condition; } + public String getCondition() { return condition; } + public void setCondition(String condition) { this.condition = condition; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeMacroDefinitionRule.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeMacroDefinitionRule.java index 38bb3374e99..f70a7eafb52 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeMacroDefinitionRule.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeMacroDefinitionRule.java @@ -31,7 +31,7 @@ class AutomakeMacroDefinitionRule implements IPredicateRule { private IToken token; private StringBuilder buffer = new StringBuilder(); protected IToken defaultToken; - + public AutomakeMacroDefinitionRule(IToken token, IToken defaultToken) { this.token = token; this.defaultToken = defaultToken; @@ -53,45 +53,45 @@ class AutomakeMacroDefinitionRule implements IPredicateRule { for (c = scanner.read(); c != ICharacterScanner.EOF; c = scanner.read()) { switch (state) { - case INIT_STATE : - if (c != '\n' && Character.isWhitespace((char) c)) { - break; - } - if (isValidCharacter(c)) { - state = VAR_STATE; - } else { - state = ERROR_STATE; - } - break; - case VAR_STATE : - if (isValidCharacter(c)) { - break; - } - case END_VAR_STATE : - if (Character.isWhitespace((char) c)) { - state = END_VAR_STATE; - } else if (c == ':' || c == '+') { - state = EQUAL_STATE; - } else if (c == '=') { - state = FINISH_STATE; - } else { -// if (state == END_VAR_STATE) { -// scanner.unread(); // Return back to the space -// } - state = ERROR_STATE; - } - break; - case EQUAL_STATE : - if (c == '=') { - state = FINISH_STATE; - } else { - state = ERROR_STATE; - } + case INIT_STATE: + if (c != '\n' && Character.isWhitespace((char) c)) { break; - case FINISH_STATE : - break; - default : + } + if (isValidCharacter(c)) { + state = VAR_STATE; + } else { + state = ERROR_STATE; + } + break; + case VAR_STATE: + if (isValidCharacter(c)) { break; + } + case END_VAR_STATE: + if (Character.isWhitespace((char) c)) { + state = END_VAR_STATE; + } else if (c == ':' || c == '+') { + state = EQUAL_STATE; + } else if (c == '=') { + state = FINISH_STATE; + } else { + // if (state == END_VAR_STATE) { + // scanner.unread(); // Return back to the space + // } + state = ERROR_STATE; + } + break; + case EQUAL_STATE: + if (c == '=') { + state = FINISH_STATE; + } else { + state = ERROR_STATE; + } + break; + case FINISH_STATE: + break; + default: + break; } if (state >= FINISH_STATE) { break; @@ -104,21 +104,21 @@ class AutomakeMacroDefinitionRule implements IPredicateRule { return token; } - boolean debug = true; - if (debug) { -// System.out.println("This should be a 'c': " + peek(scanner)); -// System.out.println("This is what's in the **REST OF** the buffer:"); -// int count = 0; -// for (int c = scanner.read(); c != ICharacterScanner.EOF; c = scanner.read()) { -// System.out.println((char) c); -// count++; -// } -// // Unread what we just displayed -// for (int i = 0; i < count; i++) { -// scanner.unread(); -// } - } - + boolean debug = true; + if (debug) { + // System.out.println("This should be a 'c': " + peek(scanner)); + // System.out.println("This is what's in the **REST OF** the buffer:"); + // int count = 0; + // for (int c = scanner.read(); c != ICharacterScanner.EOF; c = scanner.read()) { + // System.out.println((char) c); + // count++; + // } + // // Unread what we just displayed + // for (int i = 0; i < count; i++) { + // scanner.unread(); + // } + } + if (defaultToken.isUndefined()) { // If c is EOF, we've read it and broken out of the for loop above, // but we need to unread it since it got read but not put into the @@ -126,27 +126,27 @@ class AutomakeMacroDefinitionRule implements IPredicateRule { if (state == ERROR_STATE || c == ICharacterScanner.EOF) scanner.unread(); unreadBuffer(scanner); - debug = true; - if (debug) { -// System.out.println("This should be an 'i': " + peek(scanner)); -// System.out.println("We've supposedly just unread the entire buffer. Here it is:"); -// int count = 0; -// for (int c = scanner.read(); c != ICharacterScanner.EOF; c = scanner.read()) { -// System.out.println((char) c); -// count++; -// } -// // Unread what we just displayed -// for (int i = 0; i < count + 1; i++) { -// scanner.unread(); -// } -// System.out.println("... just to be safe, here's the first character: " + peek(scanner)); - } + debug = true; + if (debug) { + // System.out.println("This should be an 'i': " + peek(scanner)); + // System.out.println("We've supposedly just unread the entire buffer. Here it is:"); + // int count = 0; + // for (int c = scanner.read(); c != ICharacterScanner.EOF; c = scanner.read()) { + // System.out.println((char) c); + // count++; + // } + // // Unread what we just displayed + // for (int i = 0; i < count + 1; i++) { + // scanner.unread(); + // } + // System.out.println("... just to be safe, here's the first character: " + peek(scanner)); + } } - + return Token.UNDEFINED; } - + public char peek(ICharacterScanner scanner) { char c = (char) scanner.read(); scanner.unread(); @@ -182,7 +182,7 @@ class AutomakeMacroDefinitionRule implements IPredicateRule { } private void scanToBeginOfLine(ICharacterScanner scanner) { - while(scanner.getColumn() != 0) { + while (scanner.getColumn() != 0) { scanner.unread(); } } @@ -203,10 +203,11 @@ class AutomakeMacroDefinitionRule implements IPredicateRule { return true; } + protected boolean isValidCharacter(int c) { char c0 = (char) c; - return Character.isLetterOrDigit(c0) || (c0 == '_') || (c0 == '-') || - (c0 == '@') || (c0 == '+') || (c0 == '$') || (c0 == '(') || (c0 == ')'); + return Character.isLetterOrDigit(c0) || (c0 == '_') || (c0 == '-') || (c0 == '@') || (c0 == '+') || (c0 == '$') + || (c0 == '(') || (c0 == ')'); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeMacroReferenceRule.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeMacroReferenceRule.java index e16968e2fba..53404ca0182 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeMacroReferenceRule.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeMacroReferenceRule.java @@ -1,7 +1,7 @@ /******************************************************************************* * Copyright (c) 2006, 2015, Red Hat, Inc. * Based on MacroReferenceRule which has the following copyright notice - * + * * Copyright (c) 2000, 2006 QNX Software Systems and others. * * This program and the accompanying materials @@ -25,19 +25,19 @@ public class AutomakeMacroReferenceRule extends PatternRule { int nOfBrackets; int fBracket; -// public MacroReferenceRule(IToken token) { -// super("$(", ")", token, (char) 0, true); //$NON-NLS-1$ //$NON-NLS-2$ -// } + // public MacroReferenceRule(IToken token) { + // super("$(", ")", token, (char) 0, true); //$NON-NLS-1$ //$NON-NLS-2$ + // } public AutomakeMacroReferenceRule(IToken token, String startSeq, String endSeq) { - super(startSeq, endSeq, token, (char)0, true); + super(startSeq, endSeq, token, (char) 0, true); if (endSeq.length() > 0 && endSeq.charAt(0) == '}') { fBracket = '{'; } else { fBracket = '('; } } - + @Override protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) { nOfBrackets = 1; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeTextHover.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeTextHover.java index 63b0d70944e..24a0d3d0951 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeTextHover.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeTextHover.java @@ -25,26 +25,25 @@ import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Region; import org.eclipse.swt.graphics.Point; - public class AutomakeTextHover implements ITextHover, ITextHoverExtension { AutomakeEditor editor; - + public AutomakeTextHover(AutomakeEditor editor) { this.editor = editor; } - + @Override public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { TargetRule target = null; String[] preReqs = null; - + if (hoverRegion == null || hoverRegion.getLength() == 0) return null; Automakefile makefile = (Automakefile) editor.getMakefile(); if (makefile == null) return null; - + String hoverText; int hoverLine; try { @@ -53,7 +52,7 @@ public class AutomakeTextHover implements ITextHover, ITextHoverExtension { } catch (BadLocationException e) { return null; } - + // Automatic variables if (hoverText.startsWith("$")) { IDirective containingDirective = makefile.getDirectiveContainingLine(hoverLine); @@ -71,8 +70,8 @@ public class AutomakeTextHover implements ITextHover, ITextHoverExtension { return preReqs[0]; break; // FIXME: implement $* ? -// case '*': -// break; + // case '*': + // break; case '?': preReqs = target.getPrerequisites(); if (preReqs != null && preReqs.length > 0) { @@ -85,12 +84,12 @@ public class AutomakeTextHover implements ITextHover, ITextHoverExtension { } break; case '%': -// if (target instanceOf ArchiveTarget) { -// return target.getMember(); -// } else { -// error; -// } -// break; + // if (target instanceOf ArchiveTarget) { + // return target.getMember(); + // } else { + // error; + // } + // break; default: break; } @@ -103,21 +102,20 @@ public class AutomakeTextHover implements ITextHover, ITextHoverExtension { return definition.getValue().toString(); } } - + return ""; } @Override public IRegion getHoverRegion(ITextViewer textViewer, int offset) { - + if (textViewer != null) { /* * If the hover offset falls within the selection range return the * region for the whole selection. */ Point selectedRange = textViewer.getSelectedRange(); - if (selectedRange.x >= 0 && selectedRange.y > 0 - && offset >= selectedRange.x + if (selectedRange.x >= 0 && selectedRange.y > 0 && offset >= selectedRange.x && offset <= selectedRange.x + selectedRange.y) return new Region(selectedRange.x, selectedRange.y); else { @@ -137,8 +135,8 @@ public class AutomakeTextHover implements ITextHover, ITextHoverExtension { while (pos >= 0) { c = document.getChar(pos); - if (!Character.isJavaIdentifierPart(c) && - (c != '@') && (c != '<') && (c != '*') && (c != '?') && (c != '%')) + if (!Character.isJavaIdentifierPart(c) && (c != '@') && (c != '<') && (c != '*') && (c != '?') + && (c != '%')) break; --pos; } @@ -150,8 +148,8 @@ public class AutomakeTextHover implements ITextHover, ITextHoverExtension { while (pos < length) { c = document.getChar(pos); - if (!Character.isJavaIdentifierPart(c) && - (c != '@') && (c != '<') && (c != '*') && (c != '?') && (c != '%')) + if (!Character.isJavaIdentifierPart(c) && (c != '@') && (c != '<') && (c != '*') && (c != '?') + && (c != '%')) break; ++pos; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeWordDetector.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeWordDetector.java index a2b7324348a..9ee3ccbaf89 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeWordDetector.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeWordDetector.java @@ -16,10 +16,10 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; import org.eclipse.jface.text.rules.IWordDetector; public class AutomakeWordDetector implements IWordDetector { - + private static final String correctStartSpecChars = "$%*().><"; //$NON-NLS-1$ private static final String correctSpecChars = "?@$/\\<*%"; //$NON-NLS-1$ - + @Override public boolean isWordStart(char character) { return Character.isLetterOrDigit(character) || (correctStartSpecChars.indexOf(character) >= 0); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Automakefile.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Automakefile.java index a193588947d..f1c07a306cf 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Automakefile.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Automakefile.java @@ -37,7 +37,7 @@ public class Automakefile extends GNUAutomakefile { } return null; } - + public static void main(String[] args) { try { String filename = "Makefile.am"; //$NON-NLS-1$ @@ -56,5 +56,5 @@ public class Automakefile extends GNUAutomakefile { System.out.println(e); } } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileCodeScanner.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileCodeScanner.java index bec0ad5a83a..5c220704ded 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileCodeScanner.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileCodeScanner.java @@ -31,35 +31,27 @@ import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.text.rules.WhitespaceRule; import org.eclipse.jface.text.rules.WordRule; - public class AutomakefileCodeScanner extends AbstractMakefileCodeScanner { - private final static String[] keywords = { "define", "endef", "ifdef", "ifndef", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "ifeq", "ifneq", "else", "endif", "include", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - "-include", "sinclude", "override", "endef", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "export", "unexport", "vpath", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - "if", "@if", "@endif" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "ifeq", "ifneq", "else", "endif", "include", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + "-include", "sinclude", "override", "endef", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "export", "unexport", "vpath", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "if", "@if", "@endif" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ private final static String[] functions = { "subst", "patsubst", "strip", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - "findstring", "filter", "sort", "dir", "notdir", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - "suffix", "basename", "addsuffix", "addprefix", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "join", "word", "words", "wordlist", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "firstword", "wildcard", "error", "warning", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "shell", "origin", "foreach", "call" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - }; - - private final static String[] automaticVariables = { "$<" , "$*" , "$@" , "$?" , "$%" + "findstring", "filter", "sort", "dir", "notdir", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + "suffix", "basename", "addsuffix", "addprefix", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "join", "word", "words", "wordlist", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "firstword", "wildcard", "error", "warning", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "shell", "origin", "foreach", "call" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ }; - static final String[] fTokenProperties = new String[] { - ColorManager.MAKE_COMMENT_COLOR, - ColorManager.MAKE_KEYWORD_COLOR, - ColorManager.MAKE_FUNCTION_COLOR, - ColorManager.MAKE_MACRO_REF_COLOR, - ColorManager.MAKE_MACRO_DEF_COLOR, - ColorManager.MAKE_DEFAULT_COLOR - }; + private final static String[] automaticVariables = { "$<", "$*", "$@", "$?", "$%" }; + + static final String[] fTokenProperties = new String[] { ColorManager.MAKE_COMMENT_COLOR, + ColorManager.MAKE_KEYWORD_COLOR, ColorManager.MAKE_FUNCTION_COLOR, ColorManager.MAKE_MACRO_REF_COLOR, + ColorManager.MAKE_MACRO_DEF_COLOR, ColorManager.MAKE_DEFAULT_COLOR }; /** * Constructor for AutomakefileCodeScanner @@ -68,7 +60,7 @@ public class AutomakefileCodeScanner extends AbstractMakefileCodeScanner { super(); initialize(); } - + @Override protected List<IRule> createRules() { IToken keyword = getToken(ColorManager.MAKE_KEYWORD_COLOR); @@ -85,14 +77,14 @@ public class AutomakefileCodeScanner extends AbstractMakefileCodeScanner { // Add generic whitespace rule. rules.add(new WhitespaceRule(character -> Character.isWhitespace(character))); - + // Put before the the word rules MultiLineRule defineRule = new MultiLineRule("define", "endef", macroDef); //$NON-NLS-1$ //$NON-NLS-2$ defineRule.setColumnConstraint(0); rules.add(defineRule); - + rules.add(new AutomakeMacroDefinitionRule(macroDef, Token.UNDEFINED)); - + // @AC_SUBST_VAR@ IPredicateRule substVarRule = new AutoconfSubstRule(macroRef); rules.add(substVarRule); @@ -106,28 +98,27 @@ public class AutomakefileCodeScanner extends AbstractMakefileCodeScanner { keyWordRule.setColumnConstraint(0); rules.add(keyWordRule); - WordRule functionRule = new WordRule(new MakefileWordDetector(), Token.UNDEFINED); for (int i = 0; i < functions.length; i++) functionRule.addWord(functions[i], function); rules.add(functionRule); - + WordRule automaticVarRule = new WordRule(new AutomakeWordDetector(), Token.UNDEFINED); for (int i = 0; i < automaticVariables.length; i++) automaticVarRule.addWord(automaticVariables[i], keyword); rules.add(automaticVarRule); -// rules.add(new SingleLineRule("$(", ")", macroRef)); //$NON-NLS-1$ //$NON-NLS-2$ -// rules.add(new SingleLineRule("${", "}", macroRef)); //$NON-NLS-1$ //$NON-NLS-2$ + // rules.add(new SingleLineRule("$(", ")", macroRef)); //$NON-NLS-1$ //$NON-NLS-2$ + // rules.add(new SingleLineRule("${", "}", macroRef)); //$NON-NLS-1$ //$NON-NLS-2$ rules.add(new AutomakeMacroReferenceRule(macroRef, "$(", ")")); //$NON-NLS-1$ //$NON-NLS-2$ rules.add(new AutomakeMacroReferenceRule(macroRef, "${", "}")); //$NON-NLS-1$ //$NON-NLS-2$ // Add word rule for identifier. rules.add(new AutoconfIdentifierRule(other)); - + // Make sure we don't treat "\#" as comment start. rules.add(new SingleLineRule("\\#", null, Token.UNDEFINED)); - + rules.add(new WhitespaceRule(new AutoconfWhitespaceDetector())); setDefaultReturnToken(other); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileContentOutlinePage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileContentOutlinePage.java index f7263bfd856..5e86a02d75d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileContentOutlinePage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileContentOutlinePage.java @@ -46,9 +46,8 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.views.contentoutline.ContentOutlinePage; - public class AutomakefileContentOutlinePage extends ContentOutlinePage { - + protected IMakefile makefile; protected IMakefile nullMakefile = new NullMakefile(); private LexicalSortingAction sortAction; @@ -78,7 +77,7 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage { if (element instanceof IMakefile) { return fInput; } else if (element instanceof IDirective) { - return ((IDirective)element).getParent(); + return ((IDirective) element).getParent(); } return fInput; } @@ -103,12 +102,12 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage { if (inputElement == fInput) { directives = makefile.getDirectives(); } else if (inputElement instanceof IRule) { - directives = ((IRule)inputElement).getCommands(); + directives = ((IRule) inputElement).getCommands(); } else if (inputElement instanceof IParent) { if (inputElement instanceof IInclude && !showIncludeChildren) { directives = new IDirective[0]; } else { - directives = ((IParent)inputElement).getDirectives(); + directives = ((IParent) inputElement).getDirectives(); } } else { directives = new IDirective[0]; @@ -124,9 +123,8 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage { } else if (showTargetRule && directives[i] instanceof AutomakeIfElse) { list.add(directives[i]); } else { - boolean irrelevant = (directives[i] instanceof IComment || - directives[i] instanceof IEmptyLine || - directives[i] instanceof ITerminal); + boolean irrelevant = (directives[i] instanceof IComment || directives[i] instanceof IEmptyLine + || directives[i] instanceof ITerminal); if (!irrelevant) { list.add(directives[i]); } @@ -146,7 +144,7 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage { } if (newInput != null) { - IWorkingCopyManager manager= AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + IWorkingCopyManager manager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); makefile = manager.getWorkingCopy((IEditorInput) newInput); if (makefile == null) { makefile = nullMakefile; @@ -196,7 +194,7 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage { } else name = "else"; } else if (element instanceof AutomakeConfigMacro) { - AutomakeConfigMacro macro = (AutomakeConfigMacro)element; + AutomakeConfigMacro macro = (AutomakeConfigMacro) element; name = macro.getName(); } else { name = super.getText(element); @@ -211,15 +209,15 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage { } } - + protected AutomakeEditor fEditor; protected Object fInput; - + public AutomakefileContentOutlinePage(AutomakeEditor editor) { super(); fEditor = editor; } - + /** * Sets the input of the outline page */ @@ -227,7 +225,7 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage { fInput = input; update(); } - + /** * Updates the outline page. */ @@ -260,15 +258,15 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage { } sortAction.setTreeViewer(viewer); } - + public void inputChanged(Object oldInput, Object newInput) { if (oldInput != null) { makefile = nullMakefile; } if (newInput != null) { - IWorkingCopyManager manager= AutomakeEditorFactory.getDefault().getWorkingCopyManager(); - makefile = manager.getWorkingCopy((IEditorInput)newInput); + IWorkingCopyManager manager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + makefile = manager.getWorkingCopy((IEditorInput) newInput); if (makefile == null) { makefile = nullMakefile; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileReconcilingStrategy.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileReconcilingStrategy.java index 34d52b00846..a49bd721276 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileReconcilingStrategy.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileReconcilingStrategy.java @@ -28,41 +28,39 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; - public class AutomakefileReconcilingStrategy implements IReconcilingStrategy { private int fLastRegionOffset; - private ITextEditor fEditor; + private ITextEditor fEditor; private IWorkingCopyManager fManager; private IDocumentProvider fDocumentProvider; private AutomakefileContentOutlinePage fOutliner; private IReconcilingParticipant fMakefileReconcilingParticipant; private AutomakeErrorHandler fErrorHandler; private IEditorInput input; - + public AutomakefileReconcilingStrategy(AutomakeEditor editor) { - fOutliner= editor.getAutomakeOutlinePage(); + fOutliner = editor.getAutomakeOutlinePage(); fLastRegionOffset = Integer.MAX_VALUE; - fEditor= editor; + fEditor = editor; input = fEditor.getEditorInput(); - fManager= AutomakeEditorFactory.getDefault().getWorkingCopyManager(); - fDocumentProvider= AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider(); - fErrorHandler= new AutomakeErrorHandler(input); - fMakefileReconcilingParticipant= (IReconcilingParticipant)fEditor; + fManager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + fDocumentProvider = AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider(); + fErrorHandler = new AutomakeErrorHandler(input); + fMakefileReconcilingParticipant = (IReconcilingParticipant) fEditor; } - + @Override public void setDocument(IDocument document) { - } - + } @Override public void reconcile(IRegion region) { // We use a trick to avoid running the reconciler multiple times // on a file when it gets changed. This is because this gets called - // multiple times with different regions of the file, we do a + // multiple times with different regions of the file, we do a // complete parse on the first region. - if(region.getOffset() <= fLastRegionOffset) { + if (region.getOffset() <= fLastRegionOffset) { reconcile(); } fLastRegionOffset = region.getOffset(); @@ -74,7 +72,7 @@ public class AutomakefileReconcilingStrategy implements IReconcilingStrategy { // the contentoutline viewer. //reconcile(); } - + private void reconcile() { try { IMakefile makefile = fManager.getWorkingCopy(fEditor.getEditorInput()); @@ -85,7 +83,7 @@ public class AutomakefileReconcilingStrategy implements IReconcilingStrategy { makefile.parse(makefile.getFileURI(), reader); } catch (IOException e) { } - + fOutliner.update(); fErrorHandler.update(makefile); } @@ -98,6 +96,6 @@ public class AutomakefileReconcilingStrategy implements IReconcilingStrategy { // } } - } + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileSourceConfiguration.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileSourceConfiguration.java index 60f3d345e37..e2ae906082d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileSourceConfiguration.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileSourceConfiguration.java @@ -27,40 +27,38 @@ import org.eclipse.jface.text.reconciler.MonoReconciler; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.util.PropertyChangeEvent; +public class AutomakefileSourceConfiguration extends MakefileSourceConfiguration { -public class AutomakefileSourceConfiguration extends - MakefileSourceConfiguration { - AutomakeEditor editor; AutomakefileCodeScanner codeScanner; AutomakeTextHover amHover; - + /** * Constructor for MakeConfiguration */ public AutomakefileSourceConfiguration(IPreferenceStore preferenceStore) { super(preferenceStore, null); } - + public AutomakefileSourceConfiguration(IPreferenceStore preferenceStore, AutomakeEditor editor) { super(preferenceStore, editor); this.editor = editor; } - + public AutomakefileCodeScanner getAutomakeCodeScanner() { if (null == codeScanner) codeScanner = new AutomakefileCodeScanner(); return codeScanner; } - + @Override public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { if (amHover == null) amHover = new AutomakeTextHover(editor); return amHover; } - + /** * @param event */ @@ -69,7 +67,7 @@ public class AutomakefileSourceConfiguration extends AutomakefileCodeScanner scanner = getAutomakeCodeScanner(); scanner.adaptToPreferenceChange(event); } - + /** * @param event * @return @@ -79,7 +77,7 @@ public class AutomakefileSourceConfiguration extends AutomakefileCodeScanner scanner = getAutomakeCodeScanner(); return scanner.affectsBehavior(event); } - + @Override public IPresentationReconciler getPresentationReconciler(ISourceViewer v) { @@ -89,23 +87,28 @@ public class AutomakefileSourceConfiguration extends @Override public IReconciler getReconciler(ISourceViewer sourceViewer) { if (editor != null && editor.isEditable()) { - MonoReconciler reconciler= new MonoReconciler(new AutomakefileReconcilingStrategy(editor), false); + MonoReconciler reconciler = new MonoReconciler(new AutomakefileReconcilingStrategy(editor), false); reconciler.setDelay(1000); reconciler.setProgressMonitor(new NullProgressMonitor()); return reconciler; } return null; } - + @Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ContentAssistant assistant = new ContentAssistant(); assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), IDocument.DEFAULT_CONTENT_TYPE); - assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION); - assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); + assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), + MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION); + assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), + MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION); + assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), + MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION); + assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), + MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION); + assistant.setContentAssistProcessor(new AutomakeCompletionProcessor(editor), + MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); assistant.enableAutoActivation(true); assistant.setAutoActivationDelay(500); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileUtil.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileUtil.java index 9aae153caa4..ef95a8527d7 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileUtil.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileUtil.java @@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class AutomakefileUtil { // Look for Automake conditionals which optionally @@ -22,7 +21,7 @@ public class AutomakefileUtil { public static boolean isAutomakeCommand(String line) { return line.matches("^@[a-z_A-Z0-9]+@\\t.*$"); //$NON-NLS-1$ } - + public static boolean isIfBlock(String line) { return line.startsWith("if"); //$NON-NLS-1$ } @@ -30,7 +29,7 @@ public class AutomakefileUtil { public static boolean isElseBlock(String line) { return line.startsWith("else"); //$NON-NLS-1$ } - + public static boolean isElseIfBlock(String line) { return line.startsWith("else if"); //$NON-NLS-1$ } @@ -38,7 +37,7 @@ public class AutomakefileUtil { public static boolean isEndifBlock(String line) { return line.startsWith("endif"); //$NON-NLS-1$ } - + public static boolean isConfigMacro(String line) { return line.matches("\\s*@[a-z_A-Z0-9]+@"); //$NON-NLS-1$ } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Command.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Command.java index e94925d8365..f15a0dd7af9 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Command.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Command.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.make.core.makefile.ICommand; /** * Makefile : ( statement ) * - * statement : command | .. + * statement : command | .. * command : <tab> prefix_command string <nl> * prefix_command : '-' | '@' | '+' */ @@ -84,7 +84,7 @@ public class Command extends Directive implements ICommand { @Override public String toString() { StringBuilder cmd = new StringBuilder(); - cmd.append( '\t'); + cmd.append('\t'); if (getPrefix() != 0) { cmd.append(getPrefix()); } @@ -103,7 +103,7 @@ public class Command extends Directive implements ICommand { public int hashCode() { return toString().hashCode(); } - + char getPrefix() { return prefix; } @@ -121,7 +121,7 @@ public class Command extends Directive implements ICommand { @Override public Process execute(String shell, String[] envp, File dir) throws IOException { - String[] cmdArray = new String[] { shell, "-c", command}; //$NON-NLS-1$ + String[] cmdArray = new String[] { shell, "-c", command }; //$NON-NLS-1$ return Runtime.getRuntime().exec(cmdArray, envp, dir); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Comment.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Comment.java index 2f80d6b67f7..4e0f34e0772 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Comment.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Comment.java @@ -41,7 +41,7 @@ public class Comment extends Directive implements IComment { return cmt.toString().equals(toString()); return false; } - + @Override public int hashCode() { return toString().hashCode(); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/CompletionProposalComparator.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/CompletionProposalComparator.java index da40d91fa68..1594393c2f1 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/CompletionProposalComparator.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/CompletionProposalComparator.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - import java.io.Serializable; import java.util.Comparator; @@ -26,6 +25,6 @@ public class CompletionProposalComparator implements Comparator<ICompletionPropo @Override public int compare(ICompletionProposal o1, ICompletionProposal o2) { return o1.getDisplayString().compareToIgnoreCase(o2.getDisplayString()); - } - + } + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Conditional.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Conditional.java index 42612068dc9..57fdf36c3d8 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Conditional.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Conditional.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.make.core.makefile.gnu.IConditional; public abstract class Conditional extends Parent implements IConditional { - private static final String EMPTY = ""; //$NON-NLS-1$ + private static final String EMPTY = ""; //$NON-NLS-1$ String cond; String arg1; String arg2; @@ -40,7 +40,6 @@ public abstract class Conditional extends Parent implements IConditional { cond = conditional; } - @Override public String getConditional() { return cond; @@ -55,7 +54,7 @@ public abstract class Conditional extends Parent implements IConditional { public String getArg2() { return arg2; } - + public boolean isIf() { return false; } @@ -101,12 +100,12 @@ public abstract class Conditional extends Parent implements IConditional { String line = getConditional().trim(); char terminal = line.charAt(0) == '(' ? ',' : line.charAt(0); - + if (line.length() < 5 && terminal != ',' && terminal != '"' && terminal != '\'') { arg1 = arg2 = EMPTY; return; } - + // Find the end of the first string. int count = 0; // For the (ARG1, ARG2) format. @@ -135,20 +134,20 @@ public abstract class Conditional extends Parent implements IConditional { if (count >= line.length()) { arg1 = arg2 = EMPTY; - return; + return; } arg1 = line.substring(1, count); - + /* Find the start of the second string. */ line = line.substring(count + 1).trim(); - + terminal = terminal == ',' ? ')' : line.charAt(0); if (terminal != ')' && terminal != '"' && terminal != '\'') { arg2 = EMPTY; return; } - + count = 0; /* Find the end of the second string. */ if (terminal == ')') { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/DefineVariable.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/DefineVariable.java index f1ff63b0e03..4d3dfce69af 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/DefineVariable.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/DefineVariable.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class DefineVariable extends GNUVariableDef { public DefineVariable(Directive parent, String name, StringBuffer value) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Directive.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Directive.java index 8a5ad54031b..e219d84f680 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Directive.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Directive.java @@ -58,7 +58,7 @@ public abstract class Directive implements IDirective { } return filename; } - + @Override public IMakefile getMakefile() { if (makefile == null) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/EditorUtility.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/EditorUtility.java index accb81cba4c..01ea1eb5246 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/EditorUtility.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/EditorUtility.java @@ -61,12 +61,13 @@ public class EditorUtility { */ public static final String DEFAULT_TEXT_EDITOR_ID = EditorsUI.DEFAULT_TEXT_EDITOR_ID; - private EditorUtility () { + private EditorUtility() { } - private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException { + private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) + throws PartInitException { if (input != null) { - IWorkbenchPage p= CUIPlugin.getActivePage(); + IWorkbenchPage p = CUIPlugin.getActivePage(); if (p != null) { return p.openEditor(input, editorID, activate); } @@ -76,31 +77,31 @@ public class EditorUtility { private static IEditorInput getEditorInput(ICElement element) { while (element != null) { - if (element instanceof ISourceReference) { - ITranslationUnit tu = ((ISourceReference)element).getTranslationUnit(); - if (tu != null) { - element = tu; - } - } - if (element instanceof IWorkingCopy && ((IWorkingCopy) element).isWorkingCopy()) - element= ((IWorkingCopy) element).getOriginalElement(); - + if (element instanceof ISourceReference) { + ITranslationUnit tu = ((ISourceReference) element).getTranslationUnit(); + if (tu != null) { + element = tu; + } + } + if (element instanceof IWorkingCopy && ((IWorkingCopy) element).isWorkingCopy()) + element = ((IWorkingCopy) element).getOriginalElement(); + if (element instanceof ITranslationUnit) { - ITranslationUnit unit= (ITranslationUnit) element; - IResource resource= unit.getResource(); + ITranslationUnit unit = (ITranslationUnit) element; + IResource resource = unit.getResource(); if (resource instanceof IFile) { return new FileEditorInput((IFile) resource); } return new ExternalEditorInput(unit, new FileStorage(unit.getPath())); } - + if (element instanceof IBinary) { - return new ExternalEditorInput(getStorage((IBinary)element), (IPath)null); + return new ExternalEditorInput(getStorage((IBinary) element), (IPath) null); } - - element= element.getParent(); + + element = element.getParent(); } - + return null; } @@ -108,11 +109,11 @@ public class EditorUtility { if (input instanceof ICElement) { return getEditorInput((ICElement) input); } - if (input instanceof IFile) { + if (input instanceof IFile) { return new FileEditorInput((IFile) input); } - if (input instanceof IStorage) { - return new ExternalEditorInput((IStorage)input); + if (input instanceof IStorage) { + return new ExternalEditorInput((IStorage) input); } return null; } @@ -121,14 +122,14 @@ public class EditorUtility { * Utility method to open an editor for the given file system location * using {@link #getEditorInputForLocation(IPath, ICElement)} to create * the editor input. - * + * * @param location a file system location * @param element an element related to the target file, may be <code>null</code> - * @throws PartInitException + * @throws PartInitException */ public static IEditorPart openInEditor(IPath location, ICElement element) throws PartInitException { - IEditorInput input= getEditorInputForLocation(location, element); - return EditorUtility.openInEditor(input, getEditorID(input, element), true); + IEditorInput input = getEditorInputForLocation(location, element); + return EditorUtility.openInEditor(input, getEditorID(input, element), true); } /** @@ -138,17 +139,17 @@ public class EditorUtility { * assuming the location points to an existing file in the file system. * The <code>ICElement</code> is used to determine the associated project * in case the location can not be resolved to a workspace <code>IFile</code>. - * + * * @param location a valid file system location * @param context an element related to the target file, may be <code>null</code> * @return an editor input */ public static IEditorInput getEditorInputForLocation(IPath location, ICElement context) { - IFile resource= getWorkspaceFileAtLocation(location, context); + IFile resource = getWorkspaceFileAtLocation(location, context); if (resource != null) { return new FileEditorInput(resource); - } - + } + if (context == null) { // try to synthesize a context for a location appearing on a project's // include paths @@ -165,15 +166,15 @@ public class EditorUtility { } if (context == null && projects.length > 0) { // last resort: just take any of them - context= projects[0]; + context = projects[0]; } } catch (CModelException e) { } } - + if (context != null) { // try to get a translation unit from the location and associated element - ICProject cproject= context.getCProject(); + ICProject cproject = context.getCProject(); if (cproject != null) { ITranslationUnit unit = CoreModel.getDefault().createTranslationUnitFrom(cproject, location); if (unit != null) { @@ -181,46 +182,45 @@ public class EditorUtility { } // no translation unit - still try to get a sensible marker resource // from the associated element - IResource markerResource= cproject.getProject(); + IResource markerResource = cproject.getProject(); return new ExternalEditorInput(new FileStorage(location), markerResource); } } return new ExternalEditorInput(new FileStorage(location)); } - /** * Utility method to resolve a file system location to a workspace resource. * If a context element is given and there are multiple matches in the workspace, * a resource with the same project of the context element are preferred. - * + * * @param location a valid file system location * @param context an element related to the target file, may be <code>null</code> * @return an <code>IFile</code> or <code>null</code> */ private static IFile getWorkspaceFileAtLocation(IPath location, ICElement context) { - IFile file= FileBuffers.getWorkspaceFileAtLocation(location); + IFile file = FileBuffers.getWorkspaceFileAtLocation(location); if (file == null) { // try to find a linked resource - IProject project= null; + IProject project = null; if (context != null) { - ICProject cProject= context.getCProject(); + ICProject cProject = context.getCProject(); if (cProject != null) { - project= cProject.getProject(); + project = cProject.getProject(); } } - IFile bestMatch= null; - IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); - IFile[] files= root.findFilesForLocationURI(URIUtil.toURI(location)); - for (int i= 0; i < files.length; i++) { - file= files[i]; + IFile bestMatch = null; + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IFile[] files = root.findFilesForLocationURI(URIUtil.toURI(location)); + for (int i = 0; i < files.length; i++) { + file = files[i]; if (file.isAccessible()) { if (project != null && file.getProject() == project) { - bestMatch= file; + bestMatch = file; break; } if (bestMatch == null) { - bestMatch= file; + bestMatch = file; if (project == null) { break; } @@ -235,7 +235,7 @@ public class EditorUtility { /** * Determine the editor id from the given file name using * the workspace-wide content-type definitions. - * + * * @param name the file name * @return a valid editor id, never <code>null</code> */ @@ -256,7 +256,7 @@ public class EditorUtility { * mechanism is used to determine the correct editor id. * If that fails, the editor id is determined by file name and extension using * the workspace-wide content-type definitions. - * + * * @param input the editor input * @param inputObject the input object (used to create the editor input) or <code>null</code> * @return a valid editor id, never <code>null</code> @@ -265,26 +265,26 @@ public class EditorUtility { ITranslationUnit tunit = null; if (inputObject instanceof ITranslationUnit) { - tunit= (ITranslationUnit)inputObject; + tunit = (ITranslationUnit) inputObject; } else if (input instanceof IFileEditorInput) { - IFileEditorInput editorInput = (IFileEditorInput)input; + IFileEditorInput editorInput = (IFileEditorInput) input; IFile file = editorInput.getFile(); ICElement celement = CoreModel.getDefault().create(file); if (celement instanceof ITranslationUnit) { - tunit = (ITranslationUnit)celement; + tunit = (ITranslationUnit) celement; } } else if (input instanceof ITranslationUnitEditorInput) { - ITranslationUnitEditorInput editorInput = (ITranslationUnitEditorInput)input; + ITranslationUnitEditorInput editorInput = (ITranslationUnitEditorInput) input; tunit = editorInput.getTranslationUnit(); } if (tunit != null) { // Choose an editor based on the content type - String contentTypeId= tunit.getContentTypeId(); + String contentTypeId = tunit.getContentTypeId(); if (contentTypeId != null) { - IContentType contentType= Platform.getContentTypeManager().getContentType(contentTypeId); + IContentType contentType = Platform.getContentTypeManager().getContentType(contentTypeId); IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); - IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType); + IEditorDescriptor desc = registry.getDefaultEditor(input.getName(), contentType); if (desc != null) { return desc.getId(); } @@ -310,12 +310,12 @@ public class EditorUtility { try { IBuffer buffer = bin.getBuffer(); if (buffer != null) { - store = new FileStorage (new ByteArrayInputStream(buffer.getContents().getBytes()), bin.getPath()); + store = new FileStorage(new ByteArrayInputStream(buffer.getContents().getBytes()), bin.getPath()); } } catch (CModelException e) { // nothing; } return store; } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ElementListSelectionDialog.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ElementListSelectionDialog.java index f6030bca8bc..7fe0d6c29a4 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ElementListSelectionDialog.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ElementListSelectionDialog.java @@ -27,70 +27,78 @@ import org.eclipse.swt.widgets.Shell; * A class to select one or more elements out of an indexed property */ public class ElementListSelectionDialog extends AbstractElementListSelectionDialog { - + private List<Object> fElements; - + @Override protected void computeResult() { setResult(getWidgetSelection()); } - @Override protected Control createDialogArea(Composite parent) { - Control result= super.createDialogArea(parent); - + Control result = super.createDialogArea(parent); + setSelectionListElements(fElements, false); - //a little trick to make the window come up faster - String initialFilter= null; - if (getPrimaryInitialSelection() instanceof String) - initialFilter= (String)getPrimaryInitialSelection(); - if (initialFilter != null) - setFilter(initialFilter, true); - else - refilter(); - + //a little trick to make the window come up faster + String initialFilter = null; + if (getPrimaryInitialSelection() instanceof String) + initialFilter = (String) getPrimaryInitialSelection(); + if (initialFilter != null) + setFilter(initialFilter, true); + else + refilter(); + return result; } + public Object getSelectedElement() { return getPrimaryResult(); } + public Object[] getSelectedElements() { return getResult(); } + @Override protected void handleDoubleClick() { if (verifyCurrentSelection()) { buttonPressed(IDialogConstants.OK_ID); } } + /** * Constructs a list selection dialog. * @param renderer The label renderer used * @param ignoreCase Decides if the match string ignores lower/upper case - * @param multipleSelection Allow multiple selection + * @param multipleSelection Allow multiple selection */ - public ElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) { - super (parent, title, image, renderer, ignoreCase, multipleSelection); + public ElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, + boolean ignoreCase, boolean multipleSelection) { + super(parent, title, image, renderer, ignoreCase, multipleSelection); } + /** * Constructs a list selection dialog. * @param renderer The label renderer used * @param ignoreCase Decides if the match string ignores lower/upppr case - * @param multipleSelection Allow multiple selection + * @param multipleSelection Allow multiple selection */ - public ElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) { + public ElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, + boolean multipleSelection) { this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$ } + /** * Open the dialog. * @param elements The elements to show in the list * @return Returns OK or CANCEL - */ + */ public int open(List<Object> elements) { setElements(elements); return open(); } + /** * Open the dialog. * @param elements The elements to show in the list @@ -102,10 +110,11 @@ public class ElementListSelectionDialog extends AbstractElementListSelectionDial setInitialSelection(initialSelection); return open(); } + /** * Sets the elements presented by this dialog. */ public void setElements(List<Object> elements) { - fElements= elements; + fElements = elements; } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Else.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Else.java index 5be169626e2..f68df791128 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Else.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Else.java @@ -22,7 +22,7 @@ public class Else extends Conditional implements IAutomakeConditional, ICommand private boolean isAutomake; private Rule[] rules; - + public Else(Directive parent) { super(parent); } @@ -31,7 +31,7 @@ public class Else extends Conditional implements IAutomakeConditional, ICommand public boolean isAutomake() { return isAutomake; } - + @Override public Rule[] getRules() { if (rules != null) @@ -46,12 +46,12 @@ public class Else extends Conditional implements IAutomakeConditional, ICommand else this.rules = rules; } - + @Override public void setAutomake(boolean value) { isAutomake = value; } - + @Override public boolean isElse() { return true; @@ -61,23 +61,23 @@ public class Else extends Conditional implements IAutomakeConditional, ICommand public String toString() { return GNUMakefileConstants.CONDITIONAL_ELSE; } - + // ICommand methods so Automake else can be a child of an IRule @Override public Process execute(String shell, String[] envp, File dir) { return null; } - + @Override public boolean shouldBeSilent() { return false; } - + @Override public boolean shouldIgnoreError() { return false; } - + @Override public boolean shouldExecute() { return false; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Endef.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Endef.java index 5e8cbe811dc..fe0adca060f 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Endef.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Endef.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; public class Endef extends Terminal { - public Endef(Directive parent) { super(parent); } @@ -24,9 +23,9 @@ public class Endef extends Terminal { public boolean isEndef() { return true; } - + @Override public String toString() { - return GNUMakefileConstants.TERMINAL_ENDEF; - } + return GNUMakefileConstants.TERMINAL_ENDEF; + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Endif.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Endif.java index c725a969383..e55bb876d77 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Endif.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Endif.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class Endif extends Terminal { public Endif(Directive parent) { @@ -24,9 +23,9 @@ public class Endif extends Terminal { public boolean isEndif() { return true; } - - @Override + + @Override public String toString() { - return GNUMakefileConstants.TERMINAL_ENDIF; - } + return GNUMakefileConstants.TERMINAL_ENDIF; + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ExternalEditorInput.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ExternalEditorInput.java index 5bbf7b99cdf..5872d71afef 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ExternalEditorInput.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ExternalEditorInput.java @@ -14,7 +14,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IStorage; @@ -29,12 +28,11 @@ import org.eclipse.ui.IStorageEditorInput; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.editors.text.ILocationProvider; - /** * An EditorInput for an external (non-workspace) file. */ public class ExternalEditorInput implements ITranslationUnitEditorInput, IPersistableElement { - + private IStorage externalFile; private IResource markerResource; private ITranslationUnit unit; @@ -46,14 +44,14 @@ public class ExternalEditorInput implements ITranslationUnitEditorInput, IPersis return true; if (!(obj instanceof IStorageEditorInput)) return false; - IStorageEditorInput other = (IStorageEditorInput)obj; + IStorageEditorInput other = (IStorageEditorInput) obj; try { return externalFile.equals(other.getStorage()); } catch (CoreException exc) { return false; } } - + @Override public int hashCode() { return externalFile.hashCode(); @@ -76,7 +74,7 @@ public class ExternalEditorInput implements ITranslationUnitEditorInput, IPersis @Override public ImageDescriptor getImageDescriptor() { - IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry(); + IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); return registry.getImageDescriptor(externalFile.getFullPath().getFileExtension()); } @@ -113,7 +111,7 @@ public class ExternalEditorInput implements ITranslationUnitEditorInput, IPersis public ExternalEditorInput(ITranslationUnit unit, IStorage exFile) { this(exFile, exFile.getFullPath()); this.unit = unit; - markerResource= unit.getCProject().getProject(); + markerResource = unit.getCProject().getProject(); } public ExternalEditorInput(IStorage exFile) { @@ -124,14 +122,14 @@ public class ExternalEditorInput implements ITranslationUnitEditorInput, IPersis externalFile = exFile; this.location = location; } - + /** * This constructor accepts the storage for the editor * and a reference to a resource which holds the markers for the external file. */ - public ExternalEditorInput(IStorage exFile, IResource markerResource) { + public ExternalEditorInput(IStorage exFile, IResource markerResource) { this(exFile, exFile.getFullPath()); - this.markerResource = markerResource ; + this.markerResource = markerResource; } /** @@ -150,5 +148,5 @@ public class ExternalEditorInput implements ITranslationUnitEditorInput, IPersis public void saveState(IMemento memento) { ExternalEditorInputFactory.saveState(memento, this); } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ExternalEditorInputFactory.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ExternalEditorInputFactory.java index c2e4a3b5ba4..694b59ba741 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ExternalEditorInputFactory.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ExternalEditorInputFactory.java @@ -41,48 +41,48 @@ public class ExternalEditorInputFactory implements IElementFactory { public static final String ID = "org.eclipse.cdt.ui.ExternalEditorInputFactory"; //$NON-NLS-1$ - private static final String TAG_PATH = "path";//$NON-NLS-1$ - private static final String TAG_PROJECT = "project";//$NON-NLS-1$ + private static final String TAG_PATH = "path";//$NON-NLS-1$ + private static final String TAG_PROJECT = "project";//$NON-NLS-1$ @Override public IAdaptable createElement(IMemento memento) { - // Get the file name. - String fileName = memento.getString(TAG_PATH); - if (fileName == null) { + // Get the file name. + String fileName = memento.getString(TAG_PATH); + if (fileName == null) { return null; } - IPath location= new Path(fileName); - ICProject cProject= null; - - String projectName= memento.getString(TAG_PROJECT); - if (projectName != null) { - IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - if (project.isAccessible() && CoreModel.hasCNature(project)) { - cProject= CoreModel.getDefault().create(project); - } - } + IPath location = new Path(fileName); + ICProject cProject = null; + + String projectName = memento.getString(TAG_PROJECT); + if (projectName != null) { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + if (project.isAccessible() && CoreModel.hasCNature(project)) { + cProject = CoreModel.getDefault().create(project); + } + } return EditorUtility.getEditorInputForLocation(location, cProject); } /** * Save the element state. - * + * * @param memento the storage * @param input the element */ static void saveState(IMemento memento, ExternalEditorInput input) { - IPath location= input.getPath(input); + IPath location = input.getPath(input); if (location != null) { memento.putString(TAG_PATH, location.toOSString()); } - IProject project= null; - ITranslationUnit unit= input.getTranslationUnit(); + IProject project = null; + ITranslationUnit unit = input.getTranslationUnit(); if (unit != null) { - project= unit.getCProject().getProject(); + project = unit.getCProject().getProject(); } if (project == null && input.getMarkerResource() instanceof IProject) { - project= (IProject)input.getMarkerResource(); + project = (IProject) input.getMarkerResource(); } if (project != null) { memento.putString(TAG_PROJECT, project.getName()); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUAutomakefile.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUAutomakefile.java index 2eebff18a92..0ebd0f89875 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUAutomakefile.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUAutomakefile.java @@ -46,21 +46,20 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; - /** * Makefile : ( statement ) * * statement : rule | macro_definition | comments | empty * rule : inference_rule | target_rule * inference_rule : target ':' <nl> ( <tab> command <nl> ) + - * target_rule : target [ ( target ) * ] ':' [ ( prerequisite ) * ] [ ';' command ] <nl> + * target_rule : target [ ( target ) * ] ':' [ ( prerequisite ) * ] [ ';' command ] <nl> [ ( command ) * ] - * macro_definition : string '=' (string)* + * macro_definition : string '=' (string)* * comments : ('#' (string) <nl>) * * empty : <nl> * command : <tab> prefix_command string <nl> * target : string * prefix_command : '-' | '@' | '+' - * internal_macro : "$<" | "$*" | "$@" | "$?" | "$%" + * internal_macro : "$<" | "$*" | "$@" | "$?" | "$%" */ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { @@ -80,7 +79,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { parse(name, stream); } } - + @Override public void parse(String filePath, Reader reader) throws IOException { parse(URIUtil.toURI(filePath), new MakefileReader(reader)); @@ -90,7 +89,6 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { public void parse(URI fileURI, Reader reader) throws IOException { parse(fileURI, new MakefileReader(reader)); } - protected void parse(URI fileURI, MakefileReader reader) throws IOException { String line; @@ -104,11 +102,11 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { clearDirectives(); setFileURI(fileURI); - + while ((line = reader.readLine()) != null) { startLine = endLine + 1; endLine = reader.getLineNumber(); - + // Check if we enter in "define" if (GNUMakefileUtil.isEndef(line)) { // We should have a "define" for a "endef". @@ -146,8 +144,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { } // 1- Try command first, since we can not strip '#' in command line - if (PosixMakefileUtil.isCommand(line) || - AutomakefileUtil.isAutomakeCommand(line)) { + if (PosixMakefileUtil.isCommand(line) || AutomakefileUtil.isAutomakeCommand(line)) { Command cmd = new Command(this, line); cmd.setLines(startLine, endLine); if (rules != null) { @@ -235,11 +232,11 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { rules = null; continue; } - + // 3c - Check for else or endif if (GNUMakefileUtil.isElse(line)) { - Else elseDirective = (Else)parseConditional(line); + Else elseDirective = (Else) parseConditional(line); elseDirective.setLines(startLine, endLine); Conditional cond = null; // FIXME: Are we missing a if condition ? @@ -250,7 +247,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { if (cond != null && cond.isIf()) { // See 3b above for description on automake if/else handling. elseDirective.setAutomake(true); - rules = ((If)cond).getRules(); + rules = ((If) cond).getRules(); // We cache the rules at the time of entry into the if/else block. elseDirective.setRules(rules); if (rules != null) { @@ -278,7 +275,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { cond.setEndLine(endLine); } if (cond instanceof IAutomakeConditional) { - rules = ((IAutomakeConditional)cond).getRules(); + rules = ((IAutomakeConditional) cond).getRules(); } if (rules != null) { // The endif is added to the rules. @@ -291,7 +288,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { } continue; } - + // 4 - reset rules to null // The first non empty line that does not begin with a <TAB> or '#' // shall begin a new entry. @@ -338,7 +335,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { vd.setLines(startLine, endLine); addDirective(conditions, vd); if (!vd.isTargetSpecific()) { - continue; + continue; } } @@ -363,7 +360,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { rules = trules; continue; } - + // - Configure macro (@xxxx@) if (AutomakefileUtil.isConfigMacro(line)) { AutomakeConfigMacro macro = parseConfigMacro(line); @@ -462,7 +459,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { */ protected SpecialRule parseSpecialRule(String line) { line = line.trim(); - String keyword = null; + String keyword = null; String[] reqs = null; SpecialRule special = null; int index = Util.indexOf(line, ':'); @@ -505,7 +502,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { } return special; } - + /** * if CONDITIONAL * @@ -526,15 +523,15 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { if (keyword == null) { keyword = line; } - if (keyword.equals(GNUMakefileConstants.CONDITIONAL_IF) || - keyword.equals(GNUMakefileConstants.AT_CONDITIONAL_IF)) { + if (keyword.equals(GNUMakefileConstants.CONDITIONAL_IF) + || keyword.equals(GNUMakefileConstants.AT_CONDITIONAL_IF)) { return new If(this, rules, line); } return null; } /** - * + * * ifdef CONDITIONAL * ifeq CONDITIONAL * ifneq CONDITIONAL @@ -579,14 +576,14 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { String extraChars = "_-"; char[] ch = line.toCharArray(); int i = 1; - while (Character.isLetterOrDigit(ch[i]) || - extraChars.indexOf(ch[i]) >= 0) { + while (Character.isLetterOrDigit(ch[i]) || extraChars.indexOf(ch[i]) >= 0) { ++i; } if (i > 1 && ch[i] == '@') - return new AutomakeConfigMacro(this, line.substring(0, i+1)); + return new AutomakeConfigMacro(this, line.substring(0, i + 1)); return null; } + /** * Format of the include directive: * include filename1 filename2 ... @@ -718,7 +715,8 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { GNUTargetRule[] rules = new GNUTargetRule[targetNames.length]; for (int i = 0; i < targetNames.length; i++) { - rules[i] = new GNUTargetRule(this, new Target(targetNames[i]), doubleColon, normalReqs, orderReqs, new Command[0]); + rules[i] = new GNUTargetRule(this, new Target(targetNames[i]), doubleColon, normalReqs, orderReqs, + new Command[0]); if (cmd != null) { rules[i].addDirective(new Command(this, cmd)); } @@ -798,9 +796,8 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { // Check for "+=", ":=", "?=" if (index > 0) { type = line.charAt(index - 1); - if (type == GNUVariableDef.TYPE_SIMPLE_EXPAND - || type == GNUVariableDef.TYPE_APPEND - || type == GNUVariableDef.TYPE_CONDITIONAL) { + if (type == GNUVariableDef.TYPE_SIMPLE_EXPAND || type == GNUVariableDef.TYPE_APPEND + || type == GNUVariableDef.TYPE_CONDITIONAL) { separator = index - 1; } else { type = GNUVariableDef.TYPE_RECURSIVE_EXPAND; @@ -861,7 +858,8 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { StaticTargetRule[] staticRules = new StaticTargetRule[targets.length]; for (int i = 0; i < targets.length; i++) { - staticRules[i] = new StaticTargetRule(this, new Target(targets[i]), targetPattern, prereqPatterns, new Command[0]); + staticRules[i] = new StaticTargetRule(this, new Target(targets[i]), targetPattern, prereqPatterns, + new Command[0]); } return staticRules; } @@ -890,10 +888,10 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { ArrayList<IDirective> list = new ArrayList<>(Arrays.asList(dirs)); for (int i = 0; i < dirs.length; ++i) { if (dirs[i] instanceof Include) { - Include include = (Include)dirs[i]; + Include include = (Include) dirs[i]; IDirective[] includedMakefiles = include.getDirectives(); for (int j = 0; j < includedMakefiles.length; ++j) { - IMakefile includedMakefile = (IMakefile)includedMakefiles[j]; + IMakefile includedMakefile = (IMakefile) includedMakefiles[j]; list.addAll(Arrays.asList(includedMakefile.getDirectives())); } } @@ -904,9 +902,10 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { @Override public IDirective[] getBuiltins() { if (builtins == null) { - String location = "builtin" + File.separator + "gnu.mk"; //$NON-NLS-1$ //$NON-NLS-2$ + String location = "builtin" + File.separator + "gnu.mk"; //$NON-NLS-1$ //$NON-NLS-2$ try { - InputStream stream = FileLocator.openStream(MakeCorePlugin.getDefault().getBundle(), new Path(location), false); + InputStream stream = FileLocator.openStream(MakeCorePlugin.getDefault().getBundle(), new Path(location), + false); GNUAutomakefile gnu = new GNUAutomakefile(); URL url = FileLocator.find(MakeCorePlugin.getDefault().getBundle(), new Path(location), null); url = FileLocator.resolve(url); @@ -915,7 +914,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { builtins = gnu.getDirectives(); for (int i = 0; i < builtins.length; i++) { if (builtins[i] instanceof MacroDefinition) { - ((MacroDefinition)builtins[i]).setFromDefault(true); + ((MacroDefinition) builtins[i]).setFromDefault(true); } } } catch (Exception e) { @@ -940,8 +939,8 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { /** * Create an IMakefile using the given IMakefileReaderProvider to fetch - * contents by name. - * + * contents by name. + * * @param fileURI URI of main file * @param makefileReaderProvider may be <code>null</code> for EFS IFileStore reading */ @@ -960,8 +959,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { if (!info.exists() || info.isDirectory()) throw new IOException(); - MakefileReader reader = new MakefileReader(new InputStreamReader( - store.openInputStream(EFS.NONE, null))); + MakefileReader reader = new MakefileReader(new InputStreamReader(store.openInputStream(EFS.NONE, null))); gnu.parse(fileURI, reader); } catch (IOException e) { AutotoolsUIPlugin.log(e); @@ -971,7 +969,7 @@ public class GNUAutomakefile extends AbstractMakefile implements IGNUMakefile { makefile = gnu; return makefile; } - + public static void main(String[] args) { try { String filename = "Makefile"; //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUMakefileConstants.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUMakefileConstants.java index b51a1c4f90f..5a0e460f883 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUMakefileConstants.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUMakefileConstants.java @@ -14,34 +14,33 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class GNUMakefileConstants extends MakeFileConstants { - static final String CONDITIONAL_ELSE = "else"; //$NON-NLS-1$ - static final String CONDITIONAL_IF = "if"; //$NON-NLS-1$ - static final String AT_CONDITIONAL_IF = "@if"; //$NON-NLS-1$ - static final String CONDITIONAL_IFNEQ = "ifneq"; //$NON-NLS-1$ - static final String CONDITIONAL_IFNDEF = "ifndef"; //$NON-NLS-1$ - static final String CONDITIONAL_IFEQ = "ifeq"; //$NON-NLS-1$ - static final String CONDITIONAL_IFDEF = "ifdef"; //$NON-NLS-1$ - - static final String TERMINAL_ENDEF = "endef"; //$NON-NLS-1$ - static final String TERMINAL_ENDIF = "endif"; //$NON-NLS-1$ - static final String AT_TERMINAL_ENDIF = "@endif"; //$NON-NLS-1$ + static final String CONDITIONAL_ELSE = "else"; //$NON-NLS-1$ + static final String CONDITIONAL_IF = "if"; //$NON-NLS-1$ + static final String AT_CONDITIONAL_IF = "@if"; //$NON-NLS-1$ + static final String CONDITIONAL_IFNEQ = "ifneq"; //$NON-NLS-1$ + static final String CONDITIONAL_IFNDEF = "ifndef"; //$NON-NLS-1$ + static final String CONDITIONAL_IFEQ = "ifeq"; //$NON-NLS-1$ + static final String CONDITIONAL_IFDEF = "ifdef"; //$NON-NLS-1$ + + static final String TERMINAL_ENDEF = "endef"; //$NON-NLS-1$ + static final String TERMINAL_ENDIF = "endif"; //$NON-NLS-1$ + static final String AT_TERMINAL_ENDIF = "@endif"; //$NON-NLS-1$ + + static final String DIRECTIVE_VPATH = "vpath"; //$NON-NLS-1$ + static final String DIRECTIVE_UNEXPORT = "unexport"; //$NON-NLS-1$ + + static final String VARIABLE_DEFINE = "define"; //$NON-NLS-1$ + static final String VARIABLE_EXPORT = "export"; //$NON-NLS-1$ + static final String VARIABLE_OVERRIDE = "override"; //$NON-NLS-1$ - static final String DIRECTIVE_VPATH = "vpath"; //$NON-NLS-1$ - static final String DIRECTIVE_UNEXPORT = "unexport"; //$NON-NLS-1$ - - static final String VARIABLE_DEFINE = "define"; //$NON-NLS-1$ - static final String VARIABLE_EXPORT = "export"; //$NON-NLS-1$ - static final String VARIABLE_OVERRIDE = "override"; //$NON-NLS-1$ - - static final String DIRECTIVE_INCLUDE = "include"; //$NON-NLS-1$ + static final String DIRECTIVE_INCLUDE = "include"; //$NON-NLS-1$ - static final String RULE_DELETE_ON_ERROR = ".DELETE_ON_ERROR"; //$NON-NLS-1$ - static final String RULE_PHONY = ".PHONY"; //$NON-NLS-1$ - static final String RULE_SECONDARY = ".SECONDARY"; //$NON-NLS-1$ - static final String RULE_LOW_RESOLUTION_TIME = ".LOW_RESOLUTION_TIME"; //$NON-NLS-1$ - static final String RULE_NOT_PARALLEL = ".NOTPARALLEL"; //$NON-NLS-1$ - static final String RULE_EXPORT_ALL_VARIABLES = ".EXPORT_ALL_VARIABLES"; //$NON-NLS-1$ - static final String RULE_INTERMEDIATE = ".INTERMEDIATE"; //$NON-NLS-1$ + static final String RULE_DELETE_ON_ERROR = ".DELETE_ON_ERROR"; //$NON-NLS-1$ + static final String RULE_PHONY = ".PHONY"; //$NON-NLS-1$ + static final String RULE_SECONDARY = ".SECONDARY"; //$NON-NLS-1$ + static final String RULE_LOW_RESOLUTION_TIME = ".LOW_RESOLUTION_TIME"; //$NON-NLS-1$ + static final String RULE_NOT_PARALLEL = ".NOTPARALLEL"; //$NON-NLS-1$ + static final String RULE_EXPORT_ALL_VARIABLES = ".EXPORT_ALL_VARIABLES"; //$NON-NLS-1$ + static final String RULE_INTERMEDIATE = ".INTERMEDIATE"; //$NON-NLS-1$ } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUMakefileUtil.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUMakefileUtil.java index 955881d1928..8659f766019 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUMakefileUtil.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUMakefileUtil.java @@ -14,7 +14,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - /** * GNUMakefile */ @@ -22,30 +21,39 @@ public class GNUMakefileUtil extends PosixMakefileUtil { public static boolean isInclude(String line) { line = line.trim(); - boolean isInclude = line.startsWith(GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 7 && Character.isWhitespace(line.charAt(7)); - boolean isDashInclude = line.startsWith("-" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); //$NON-NLS-1$ - boolean isSInclude = line.startsWith("s" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); //$NON-NLS-1$ + boolean isInclude = line.startsWith(GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 7 + && Character.isWhitespace(line.charAt(7)); + boolean isDashInclude = line.startsWith("-" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 //$NON-NLS-1$ + && Character.isWhitespace(line.charAt(8)); + boolean isSInclude = line.startsWith("s" + GNUMakefileConstants.DIRECTIVE_INCLUDE) && line.length() > 8 //$NON-NLS-1$ + && Character.isWhitespace(line.charAt(8)); return isInclude || isDashInclude || isSInclude; } public static boolean isVPath(String line) { line = line.trim(); - return line.equals(GNUMakefileConstants.DIRECTIVE_VPATH) || line.startsWith(GNUMakefileConstants.DIRECTIVE_VPATH) && line.length() > 5 && Character.isWhitespace(line.charAt(5)); + return line.equals(GNUMakefileConstants.DIRECTIVE_VPATH) + || line.startsWith(GNUMakefileConstants.DIRECTIVE_VPATH) && line.length() > 5 + && Character.isWhitespace(line.charAt(5)); } public static boolean isExport(String line) { line = line.trim(); - return line.equals(GNUMakefileConstants.VARIABLE_EXPORT) || line.startsWith(GNUMakefileConstants.VARIABLE_EXPORT) && line.length() > 6 && Character.isWhitespace(line.charAt(6)); + return line.equals(GNUMakefileConstants.VARIABLE_EXPORT) + || line.startsWith(GNUMakefileConstants.VARIABLE_EXPORT) && line.length() > 6 + && Character.isWhitespace(line.charAt(6)); } public static boolean isUnExport(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.DIRECTIVE_UNEXPORT) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); + return line.startsWith(GNUMakefileConstants.DIRECTIVE_UNEXPORT) && line.length() > 8 + && Character.isWhitespace(line.charAt(8)); } public static boolean isDefine(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.VARIABLE_DEFINE) && line.length() > 6 && Character.isWhitespace(line.charAt(6)); + return line.startsWith(GNUMakefileConstants.VARIABLE_DEFINE) && line.length() > 6 + && Character.isWhitespace(line.charAt(6)); } public static boolean isEndef(String line) { @@ -54,33 +62,40 @@ public class GNUMakefileUtil extends PosixMakefileUtil { public static boolean isOverride(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.VARIABLE_OVERRIDE) && line.length() > 8 && Character.isWhitespace(line.charAt(8)); + return line.startsWith(GNUMakefileConstants.VARIABLE_OVERRIDE) && line.length() > 8 + && Character.isWhitespace(line.charAt(8)); } public static boolean isIf(String line) { line = line.trim(); - return (line.startsWith(GNUMakefileConstants.CONDITIONAL_IF) && line.length() > 2 && Character.isWhitespace(line.charAt(2))) || - (line.startsWith(GNUMakefileConstants.AT_CONDITIONAL_IF) && line.length() > 3 && Character.isWhitespace(line.charAt(3))); + return (line.startsWith(GNUMakefileConstants.CONDITIONAL_IF) && line.length() > 2 + && Character.isWhitespace(line.charAt(2))) + || (line.startsWith(GNUMakefileConstants.AT_CONDITIONAL_IF) && line.length() > 3 + && Character.isWhitespace(line.charAt(3))); } - + public static boolean isIfeq(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFEQ) && line.length() > 4 && Character.isWhitespace(line.charAt(4)); + return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFEQ) && line.length() > 4 + && Character.isWhitespace(line.charAt(4)); } public static boolean isIfneq(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNEQ) && line.length() > 5 && Character.isWhitespace(line.charAt(5)); + return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNEQ) && line.length() > 5 + && Character.isWhitespace(line.charAt(5)); } public static boolean isIfdef(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFDEF) && line.length() > 5 && Character.isWhitespace(line.charAt(5)); + return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFDEF) && line.length() > 5 + && Character.isWhitespace(line.charAt(5)); } public static boolean isIfndef(String line) { line = line.trim(); - return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNDEF) && line.length() > 6 && Character.isWhitespace(line.charAt(6)); + return line.startsWith(GNUMakefileConstants.CONDITIONAL_IFNDEF) && line.length() > 6 + && Character.isWhitespace(line.charAt(6)); } public static boolean isElse(String line) { @@ -88,15 +103,15 @@ public class GNUMakefileUtil extends PosixMakefileUtil { } public static boolean isEndif(String line) { - return line.trim().equals(GNUMakefileConstants.TERMINAL_ENDIF) || - line.trim().startsWith(GNUMakefileConstants.AT_TERMINAL_ENDIF); + return line.trim().equals(GNUMakefileConstants.TERMINAL_ENDIF) + || line.trim().startsWith(GNUMakefileConstants.AT_TERMINAL_ENDIF); } public static boolean isOverrideDefine(String line) { line = line.trim(); if (line.startsWith(GNUMakefileConstants.VARIABLE_OVERRIDE)) { int i = 8; - while(i < line.length() && Character.isWhitespace(line.charAt(i))) { + while (i < line.length() && Character.isWhitespace(line.charAt(i))) { i++; } if (line.startsWith(GNUMakefileConstants.VARIABLE_DEFINE, i)) { @@ -120,12 +135,8 @@ public class GNUMakefileUtil extends PosixMakefileUtil { } public static boolean isVariableDefinition(String line) { - return isOverrideDefine(line) - || isTargetVariable(line) - || isDefine(line) - || isOverride(line) - || isExport(line) - || isMacroDefinition(line); + return isOverrideDefine(line) || isTargetVariable(line) || isDefine(line) || isOverride(line) || isExport(line) + || isMacroDefinition(line); } /** @@ -138,7 +149,7 @@ public class GNUMakefileUtil extends PosixMakefileUtil { if (colon1 > 0) { // move pass colon1 line = line.substring(colon1 + 1); - int colon2 = Util.indexOf(line, ':'); + int colon2 = Util.indexOf(line, ':'); // Catch operator "::" not a static pattern rule return (colon2 > 0); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUTargetRule.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUTargetRule.java index 819b1633389..0dff594cc9c 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUTargetRule.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUTargetRule.java @@ -22,7 +22,8 @@ public class GNUTargetRule extends TargetRule { String[] orderOnlyPrerequisites; boolean doubleColon; - public GNUTargetRule(Directive parent, Target target, boolean doubleColon, String[] normalPrereqs, String[] orderPrereqs, Command[] commands) { + public GNUTargetRule(Directive parent, Target target, boolean doubleColon, String[] normalPrereqs, + String[] orderPrereqs, Command[] commands) { super(parent, target, normalPrereqs, commands); orderOnlyPrerequisites = orderPrereqs.clone(); this.doubleColon = doubleColon; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUVariableDef.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUVariableDef.java index 4ca282b7767..863404d54a7 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUVariableDef.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/GNUVariableDef.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.make.core.makefile.gnu.IVariableDefinition; /** */ -public class GNUVariableDef extends MacroDefinition implements IVariableDefinition { +public class GNUVariableDef extends MacroDefinition implements IVariableDefinition { /** * ? is Conditional @@ -38,7 +38,7 @@ public class GNUVariableDef extends MacroDefinition implements IVariableDefiniti } public GNUVariableDef(Directive parent, String name, StringBuffer value, int type) { - this(parent, "", name, value, type); //$NON-NLS-1$ + this(parent, "", name, value, type); //$NON-NLS-1$ } public GNUVariableDef(Directive parent, String target, String name, StringBuffer value, int type) { @@ -122,7 +122,7 @@ public class GNUVariableDef extends MacroDefinition implements IVariableDefiniti /** * Variable from an `override' directive. */ - @Override + @Override public boolean isOverride() { return false; } @@ -130,7 +130,7 @@ public class GNUVariableDef extends MacroDefinition implements IVariableDefiniti /** * Automatic variable -- cannot be set. */ - @Override + @Override public boolean isAutomatic() { return false; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IAutomakeConditional.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IAutomakeConditional.java index 1594a876edb..1365c85455b 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IAutomakeConditional.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IAutomakeConditional.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; public interface IAutomakeConditional { - + boolean isAutomake(); void setAutomake(boolean value); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IMakefileEditorActionDefinitionIds.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IMakefileEditorActionDefinitionIds.java index 5de3fe2e7ef..01e95b460fb 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IMakefileEditorActionDefinitionIds.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IMakefileEditorActionDefinitionIds.java @@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - /** */ public interface IMakefileEditorActionDefinitionIds { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IReconcilingParticipant.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IReconcilingParticipant.java index a1fd0c7c108..b1e7198efa8 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IReconcilingParticipant.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/IReconcilingParticipant.java @@ -19,7 +19,7 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; * Interface of an object participating in reconciling. */ public interface IReconcilingParticipant { - + /** * Called after reconciling has been finished. */ diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/If.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/If.java index 6defd218eaa..4f40c074c3e 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/If.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/If.java @@ -19,9 +19,9 @@ import java.io.File; import org.eclipse.cdt.make.core.makefile.ICommand; public class If extends Conditional implements IAutomakeConditional, ICommand { - private static final String EMPTY = ""; //$NON-NLS-1$ - private Rule rules[] = null; - + private static final String EMPTY = ""; //$NON-NLS-1$ + private Rule rules[] = null; + public If(Directive parent, Rule[] rules, String var) { super(parent, var, EMPTY, EMPTY); if (rules != null) { @@ -36,7 +36,7 @@ public class If extends Conditional implements IAutomakeConditional, ICommand { return rules.clone(); return null; } - + @Override public void setRules(Rule[] rules) { if (rules != null) @@ -44,7 +44,7 @@ public class If extends Conditional implements IAutomakeConditional, ICommand { else this.rules = rules; } - + @Override public boolean isIf() { return true; @@ -54,12 +54,12 @@ public class If extends Conditional implements IAutomakeConditional, ICommand { public boolean isAutomake() { return true; } - + @Override public void setAutomake(boolean value) { // ignore value } - + @Override public String toString() { StringBuilder sb = new StringBuilder(GNUMakefileConstants.CONDITIONAL_IF); @@ -70,23 +70,23 @@ public class If extends Conditional implements IAutomakeConditional, ICommand { public String getVariable() { return getConditional(); } - + // ICommand methods so Automake if can be a child of an IRule @Override public Process execute(String shell, String[] envp, File dir) { return null; } - + @Override public boolean shouldBeSilent() { return false; } - + @Override public boolean shouldIgnoreError() { return false; } - + @Override public boolean shouldExecute() { return false; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifdef.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifdef.java index d74cdaba908..588a0b1888d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifdef.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifdef.java @@ -13,10 +13,9 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class Ifdef extends Conditional { - private static final String EMPTY = ""; //$NON-NLS-1$ - + private static final String EMPTY = ""; //$NON-NLS-1$ + public Ifdef(Directive parent, String var) { super(parent, var, EMPTY, EMPTY); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifeq.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifeq.java index 824c0a9cd7e..075a7936310 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifeq.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifeq.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class Ifeq extends Conditional { public Ifeq(Directive parent, String cond) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifndef.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifndef.java index 71a1905ef24..3aa444baff6 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifndef.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifndef.java @@ -13,10 +13,10 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class Ifndef extends Conditional { - private static final String EMPTY = ""; //$NON-NLS-1$ + private static final String EMPTY = ""; //$NON-NLS-1$ + public Ifndef(Directive parent, String var) { super(parent, var, EMPTY, EMPTY); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifneq.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifneq.java index d1b09519258..fa0079863af 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifneq.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Ifneq.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class Ifneq extends Conditional { public Ifneq(Directive parent, String cond) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Include.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Include.java index c52b30c70f8..4faf87dfa34 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Include.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Include.java @@ -58,7 +58,7 @@ public class Include extends Parent implements IInclude { if (!filenames[i].startsWith(GNUAutomakefile.FILE_SEPARATOR) && dirs != null) { for (int j = 0; j < dirs.length; j++) { try { - String filename = dirs[j] + GNUAutomakefile.FILE_SEPARATOR + filenames[i]; + String filename = dirs[j] + GNUAutomakefile.FILE_SEPARATOR + filenames[i]; gnu = new GNUAutomakefile(); gnu.parse(filename); addDirective(gnu); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroDefinition.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroDefinition.java index 3bb5c3bac22..7ca84e66bee 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroDefinition.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroDefinition.java @@ -38,7 +38,7 @@ public class MacroDefinition extends Directive implements IMacroDefinition { } public void setName(String n) { - name = (n == null) ? "" : n.trim() ; //$NON-NLS-1$ + name = (n == null) ? "" : n.trim(); //$NON-NLS-1$ } @Override @@ -56,7 +56,7 @@ public class MacroDefinition extends Directive implements IMacroDefinition { @Override public boolean equals(Object v) { if (v instanceof MacroDefinition) - return ((MacroDefinition)v).getName().equals(getName()); + return ((MacroDefinition) v).getName().equals(getName()); return false; } @@ -64,7 +64,7 @@ public class MacroDefinition extends Directive implements IMacroDefinition { public int hashCode() { return getName().hashCode(); } - + public void setFromCommand(boolean from) { fromCommand = from; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroDefinitionRule.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroDefinitionRule.java index bbb4e4d066f..3a864538185 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroDefinitionRule.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroDefinitionRule.java @@ -30,7 +30,7 @@ class MacroDefinitionRule implements IPredicateRule { private IToken token; private StringBuilder buffer = new StringBuilder(); protected IToken defaultToken; - + public MacroDefinitionRule(IToken token, IToken defaultToken) { this.token = token; this.defaultToken = defaultToken; @@ -51,45 +51,45 @@ class MacroDefinitionRule implements IPredicateRule { for (int c = scanner.read(); c != ICharacterScanner.EOF; c = scanner.read()) { switch (state) { - case INIT_STATE : - if (c != '\n' && Character.isWhitespace((char) c)) { - break; - } - if (isValidCharacter(c)) { - state = VAR_STATE; - } else { - state = ERROR_STATE; - } + case INIT_STATE: + if (c != '\n' && Character.isWhitespace((char) c)) { break; - case VAR_STATE : - if (isValidCharacter(c)) { - break; - } - case END_VAR_STATE : - if (c != '\n' && Character.isWhitespace((char) c)) { - state = END_VAR_STATE; - } else if (c == ':' || c == '+') { - state = EQUAL_STATE; - } else if (c == '=') { - state = FINISH_STATE; - } else { - if (state == END_VAR_STATE) { - scanner.unread(); // Return back to the space - } - state = ERROR_STATE; - } + } + if (isValidCharacter(c)) { + state = VAR_STATE; + } else { + state = ERROR_STATE; + } + break; + case VAR_STATE: + if (isValidCharacter(c)) { break; - case EQUAL_STATE : - if (c == '=') { - state = FINISH_STATE; - } else { - state = ERROR_STATE; + } + case END_VAR_STATE: + if (c != '\n' && Character.isWhitespace((char) c)) { + state = END_VAR_STATE; + } else if (c == ':' || c == '+') { + state = EQUAL_STATE; + } else if (c == '=') { + state = FINISH_STATE; + } else { + if (state == END_VAR_STATE) { + scanner.unread(); // Return back to the space } - break; - case FINISH_STATE : - break; - default : - break; + state = ERROR_STATE; + } + break; + case EQUAL_STATE: + if (c == '=') { + state = FINISH_STATE; + } else { + state = ERROR_STATE; + } + break; + case FINISH_STATE: + break; + default: + break; } if (state >= FINISH_STATE) { break; @@ -141,7 +141,7 @@ class MacroDefinitionRule implements IPredicateRule { } private void scanToBeginOfLine(ICharacterScanner scanner) { - while(scanner.getColumn() != 0) { + while (scanner.getColumn() != 0) { scanner.unread(); } } @@ -162,6 +162,7 @@ class MacroDefinitionRule implements IPredicateRule { return true; } + protected boolean isValidCharacter(int c) { char c0 = (char) c; return Character.isLetterOrDigit(c0) || (c0 == '_'); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroReferenceRule.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroReferenceRule.java index 60d113f4c3f..734e4311b2c 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroReferenceRule.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MacroReferenceRule.java @@ -22,19 +22,19 @@ public class MacroReferenceRule extends PatternRule { int nOfBrackets; int fBracket; -// public MacroReferenceRule(IToken token) { -// super("$(", ")", token, (char) 0, true); //$NON-NLS-1$ //$NON-NLS-2$ -// } + // public MacroReferenceRule(IToken token) { + // super("$(", ")", token, (char) 0, true); //$NON-NLS-1$ //$NON-NLS-2$ + // } public MacroReferenceRule(IToken token, String startSeq, String endSeq) { - super(startSeq, endSeq, token, (char)0, true); + super(startSeq, endSeq, token, (char) 0, true); if (endSeq.length() > 0 && endSeq.charAt(0) == '}') { fBracket = '{'; } else { fBracket = '('; } } - + @Override protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) { nOfBrackets = 1; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakeFileConstants.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakeFileConstants.java index 8ea62250715..bb36a4ba8e9 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakeFileConstants.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakeFileConstants.java @@ -13,15 +13,14 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class MakeFileConstants { - public static final String RULE_DEFAULT = ".DEFAULT"; //$NON-NLS-1$ - public static final String RULE_IGNORE =".IGNORE"; //$NON-NLS-1$ - public static final String RULE_POSIX = ".POSIX"; //$NON-NLS-1$ - public static final String RULE_PRECIOUS = ".PRECIOUS"; //$NON-NLS-1$ - public static final String RULE_SCCS_GET = ".SCCS_GET"; //$NON-NLS-1$ - public static final String RULE_SILENT = ".SILENT"; //$NON-NLS-1$ - public static final String RULE_SUFFIXES = ".SUFFIXES"; //$NON-NLS-1$ + public static final String RULE_DEFAULT = ".DEFAULT"; //$NON-NLS-1$ + public static final String RULE_IGNORE = ".IGNORE"; //$NON-NLS-1$ + public static final String RULE_POSIX = ".POSIX"; //$NON-NLS-1$ + public static final String RULE_PRECIOUS = ".PRECIOUS"; //$NON-NLS-1$ + public static final String RULE_SCCS_GET = ".SCCS_GET"; //$NON-NLS-1$ + public static final String RULE_SILENT = ".SILENT"; //$NON-NLS-1$ + public static final String RULE_SUFFIXES = ".SUFFIXES"; //$NON-NLS-1$ } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileAnnotationHover.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileAnnotationHover.java index 380370341ad..12d2857d194 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileAnnotationHover.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileAnnotationHover.java @@ -37,31 +37,30 @@ import org.eclipse.jface.text.source.LineRange; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; - /** * MakefileAnnotationHover - * + * */ public class MakefileAnnotationHover implements IAnnotationHover, IAnnotationHoverExtension { @SuppressWarnings("unused") private IEditorPart fEditor; - + /** - * + * */ public MakefileAnnotationHover(IEditorPart editor) { - fEditor = editor; + fEditor = editor; } /** * Returns the distance to the ruler line. */ protected int compareRulerLine(Position position, IDocument document, int line) { - + if (position.getOffset() > -1 && position.getLength() > -1) { try { - int markerLine= document.getLineOfOffset(position.getOffset()); + int markerLine = document.getLineOfOffset(position.getOffset()); if (line == markerLine) return 1; if (markerLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength())) @@ -69,10 +68,10 @@ public class MakefileAnnotationHover implements IAnnotationHover, IAnnotationHov } catch (BadLocationException x) { } } - + return 0; } - + /** * Selects a set of markers from the two lists. By default, it just returns * the set of exact matches. @@ -85,16 +84,16 @@ public class MakefileAnnotationHover implements IAnnotationHover, IAnnotationHov * Returns one marker which includes the ruler's line of activity. */ protected List<Annotation> getAnnotationsForLine(ISourceViewer viewer, int line) { - - IDocument document= viewer.getDocument(); - IAnnotationModel model= viewer.getAnnotationModel(); - + + IDocument document = viewer.getDocument(); + IAnnotationModel model = viewer.getAnnotationModel(); + if (model == null) return null; - - List<Annotation> exact= new ArrayList<>(); - List<Annotation> including= new ArrayList<>(); - + + List<Annotation> exact = new ArrayList<>(); + List<Annotation> including = new ArrayList<>(); + Iterator<Annotation> e = model.getAnnotationIterator(); while (e.hasNext()) { Annotation a = e.next(); @@ -107,7 +106,7 @@ public class MakefileAnnotationHover implements IAnnotationHover, IAnnotationHov break; } } - + return select(exact, including); } @@ -115,35 +114,35 @@ public class MakefileAnnotationHover implements IAnnotationHover, IAnnotationHov public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) { List<Annotation> annotations = getAnnotationsForLine(sourceViewer, lineNumber); if (annotations != null && annotations.size() > 0) { - + if (annotations.size() == 1) { - + // optimization Annotation annotation = annotations.get(0); - String message= annotation.getText(); + String message = annotation.getText(); if (message != null && message.trim().length() > 0) return formatSingleMessage(message); - + } else { - - List<String> messages= new ArrayList<>(); - - Iterator<Annotation> e= annotations.iterator(); + + List<String> messages = new ArrayList<>(); + + Iterator<Annotation> e = annotations.iterator(); while (e.hasNext()) { Annotation annotation = e.next(); - String message= annotation.getText(); + String message = annotation.getText(); if (message != null && message.trim().length() > 0) messages.add(message.trim()); } - + if (messages.size() == 1) return formatSingleMessage(messages.get(0)); - + if (messages.size() > 1) return formatMultipleMessages(messages); } } - + return null; } @@ -151,36 +150,36 @@ public class MakefileAnnotationHover implements IAnnotationHover, IAnnotationHov * Formats a message as HTML text. */ private String formatSingleMessage(String message) { - StringBuilder buffer= new StringBuilder(); + StringBuilder buffer = new StringBuilder(); HTMLPrinter.addPageProlog(buffer); HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message)); HTMLPrinter.addPageEpilog(buffer); return buffer.toString(); } - + /* * Formats several message as HTML text. */ private String formatMultipleMessages(List<String> messages) { - StringBuilder buffer= new StringBuilder(); + StringBuilder buffer = new StringBuilder(); HTMLPrinter.addPageProlog(buffer); - HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(AutoconfEditorMessages.getString("AutoconfAnnotationHover.multipleMarkers"))); //$NON-NLS-1$ - + HTMLPrinter.addParagraph(buffer, HTMLPrinter + .convertToHTMLContent(AutoconfEditorMessages.getString("AutoconfAnnotationHover.multipleMarkers"))); //$NON-NLS-1$ + HTMLPrinter.startBulletList(buffer); - Iterator<String> e= messages.iterator(); + Iterator<String> e = messages.iterator(); while (e.hasNext()) HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent(e.next())); - HTMLPrinter.endBulletList(buffer); - + HTMLPrinter.endBulletList(buffer); + HTMLPrinter.addPageEpilog(buffer); return buffer.toString(); } - + // IAnnotationHoverExtension members // We need to use the extension to get a Hover Control Creator which // handles html. - - + @Override public IInformationControlCreator getHoverControlCreator() { return new IInformationControlCreator() { @@ -190,17 +189,17 @@ public class MakefileAnnotationHover implements IAnnotationHover, IAnnotationHov } }; } - + @Override public boolean canHandleMouseCursor() { return false; } - + @Override public ILineRange getHoverLineRange(ISourceViewer viewer, int lineNumber) { return new LineRange(lineNumber, 1); } - + @Override public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleNumberOfLines) { return getHoverInfo(sourceViewer, lineRange.getStartLine()); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileCodeScanner.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileCodeScanner.java index 81f3bec921d..a975e2a7850 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileCodeScanner.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileCodeScanner.java @@ -24,31 +24,25 @@ import org.eclipse.jface.text.rules.MultiLineRule; import org.eclipse.jface.text.rules.WhitespaceRule; import org.eclipse.jface.text.rules.WordRule; - public class MakefileCodeScanner extends AbstractMakefileCodeScanner { private final static String[] keywords = { "define", "endef", "ifdef", "ifndef", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "ifeq", "ifneq", "else", "endif", "include", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - "-include", "sinclude", "override", "endef", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "export", "unexport", "vpath" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "ifeq", "ifneq", "else", "endif", "include", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + "-include", "sinclude", "override", "endef", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "export", "unexport", "vpath" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }; private final static String[] functions = { "subst", "patsubst", "strip", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - "findstring", "filter", "sort", "dir", "notdir", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - "suffix", "basename", "addsuffix", "addprefix", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "join", "word", "words", "wordlist", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "firstword", "wildcard", "error", "warning", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - "shell", "origin", "foreach", "call" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "findstring", "filter", "sort", "dir", "notdir", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + "suffix", "basename", "addsuffix", "addprefix", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "join", "word", "words", "wordlist", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "firstword", "wildcard", "error", "warning", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "shell", "origin", "foreach", "call" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ }; - static final String[] fTokenProperties = new String[] { - ColorManager.MAKE_COMMENT_COLOR, - ColorManager.MAKE_KEYWORD_COLOR, - ColorManager.MAKE_FUNCTION_COLOR, - ColorManager.MAKE_MACRO_REF_COLOR, - ColorManager.MAKE_MACRO_DEF_COLOR, - ColorManager.MAKE_DEFAULT_COLOR - }; + static final String[] fTokenProperties = new String[] { ColorManager.MAKE_COMMENT_COLOR, + ColorManager.MAKE_KEYWORD_COLOR, ColorManager.MAKE_FUNCTION_COLOR, ColorManager.MAKE_MACRO_REF_COLOR, + ColorManager.MAKE_MACRO_DEF_COLOR, ColorManager.MAKE_DEFAULT_COLOR }; /** * Constructor for MakefileCodeScanner @@ -57,7 +51,7 @@ public class MakefileCodeScanner extends AbstractMakefileCodeScanner { super(); initialize(); } - + @Override protected List<IRule> createRules() { IToken keyword = getToken(ColorManager.MAKE_KEYWORD_COLOR); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileCompletionProcessor.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileCompletionProcessor.java index e8aaaf58008..0c1da80a50c 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileCompletionProcessor.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileCompletionProcessor.java @@ -36,7 +36,6 @@ import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.IEditorPart; - /** * MakefileCompletionProcessor */ @@ -66,7 +65,7 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { } } - public static class DirectiveComparator implements Comparator<Object>{ + public static class DirectiveComparator implements Comparator<Object> { @Override public int compare(Object o1, Object o2) { @@ -74,26 +73,27 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { String name2; if (o1 instanceof IMacroDefinition) { - name1 = ((IMacroDefinition)o1).getName(); + name1 = ((IMacroDefinition) o1).getName(); } else if (o1 instanceof IRule) { - name1 = ((IRule)o1).getTarget().toString(); + name1 = ((IRule) o1).getTarget().toString(); } else { - name1 =""; //$NON-NLS-1$ + name1 = ""; //$NON-NLS-1$ } if (o2 instanceof IMacroDefinition) { - name2 = ((IMacroDefinition)o1).getName(); + name2 = ((IMacroDefinition) o1).getName(); } else if (o2 instanceof IRule) { - name2 = ((IRule)o1).getTarget().toString(); + name2 = ((IRule) o1).getTarget().toString(); } else { - name2 =""; //$NON-NLS-1$ + name2 = ""; //$NON-NLS-1$ } //return String.CASE_INSENSITIVE_ORDER.compare(name1, name2); return name1.compareToIgnoreCase(name2); } - + } + protected IContextInformationValidator fValidator = new Validator(); protected Image imageMacro = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_MACRO); protected Image imageTarget = MakeUIImages.getImage(MakeUIImages.IMG_OBJS_MAKEFILE_TARGET_RULE); @@ -104,7 +104,7 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { public MakefileCompletionProcessor(IEditorPart editor) { fEditor = editor; - fManager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + fManager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); } @Override @@ -133,7 +133,7 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { if (statements[i] instanceof IMacroDefinition) { name = ((IMacroDefinition) statements[i]).getName(); image = imageMacro; - infoString = ((IMacroDefinition)statements[i]).getValue().toString(); + infoString = ((IMacroDefinition) statements[i]).getValue().toString(); } else if (statements[i] instanceof IRule) { name = ((IRule) statements[i]).getTarget().toString(); image = imageTarget; @@ -142,16 +142,8 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { if (name != null && name.startsWith(wordPart.toString())) { 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); + ICompletionProposal result = new CompletionProposal(name, wordPart.getOffset(), + wordPart.toString().length(), name.length(), image, displayString, info, infoString); proposalList.add(result); } } @@ -169,13 +161,13 @@ public class MakefileCompletionProcessor implements IContentAssistProcessor { if (macro) { IMacroDefinition[] statements = makefile.getMacroDefinitions(); for (int i = 0; i < statements.length; i++) { - String name = statements[i].getName(); - if (name != null && name.equals(wordPart.toString())) { - String value = statements[i].getValue().toString(); - if (value != null && value.length() > 0) { - contextList.add(value); - } + String name = statements[i].getName(); + if (name != null && name.equals(wordPart.toString())) { + String value = statements[i].getValue().toString(); + if (value != null && value.length() > 0) { + contextList.add(value); } + } } statements = makefile.getBuiltinMacroDefinitions(); for (int i = 0; i < statements.length; i++) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileContentOutlinePage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileContentOutlinePage.java index 90051cb4849..09b1076ac7b 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileContentOutlinePage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileContentOutlinePage.java @@ -49,7 +49,6 @@ import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.views.contentoutline.ContentOutlinePage; - /** * MakefileContentOutlinePage */ @@ -80,7 +79,7 @@ public class MakefileContentOutlinePage extends ContentOutlinePage { if (element instanceof IMakefile) { return fInput; } else if (element instanceof IDirective) { - return ((IDirective)element).getParent(); + return ((IDirective) element).getParent(); } return fInput; } @@ -105,12 +104,12 @@ public class MakefileContentOutlinePage extends ContentOutlinePage { if (inputElement == fInput) { directives = makefile.getDirectives(); } else if (inputElement instanceof IRule) { - directives = ((IRule)inputElement).getCommands(); + directives = ((IRule) inputElement).getCommands(); } else if (inputElement instanceof IParent) { if (inputElement instanceof IInclude && !showIncludeChildren) { directives = new IDirective[0]; } else { - directives = ((IParent)inputElement).getDirectives(); + directives = ((IParent) inputElement).getDirectives(); } } else { directives = new IDirective[0]; @@ -124,9 +123,8 @@ public class MakefileContentOutlinePage extends ContentOutlinePage { } else if (showTargetRule && directives[i] instanceof ITargetRule) { list.add(directives[i]); } else { - boolean irrelevant = (directives[i] instanceof IComment || - directives[i] instanceof IEmptyLine || - directives[i] instanceof ITerminal); + boolean irrelevant = (directives[i] instanceof IComment || directives[i] instanceof IEmptyLine + || directives[i] instanceof ITerminal); if (!irrelevant) { list.add(directives[i]); } @@ -146,8 +144,8 @@ public class MakefileContentOutlinePage extends ContentOutlinePage { } if (newInput != null) { - IWorkingCopyManager manager= AutomakeEditorFactory.getDefault().getWorkingCopyManager(); - makefile = manager.getWorkingCopy((IEditorInput)newInput); + IWorkingCopyManager manager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + makefile = manager.getWorkingCopy((IEditorInput) newInput); if (makefile == null) { makefile = nullMakefile; } @@ -219,7 +217,7 @@ public class MakefileContentOutlinePage extends ContentOutlinePage { viewer.setInput(fInput); } - MenuManager manager= new MenuManager("#MakefileOutlinerContext"); //$NON-NLS-1$ + MenuManager manager = new MenuManager("#MakefileOutlinerContext"); //$NON-NLS-1$ manager.setRemoveAllWhenShown(true); manager.addMenuListener(m -> contextMenuAboutToShow(m)); Control tree = viewer.getControl(); @@ -232,7 +230,7 @@ public class MakefileContentOutlinePage extends ContentOutlinePage { } }); - IPageSite site= getSite(); + IPageSite site = getSite(); //FIXME: should pluginid below be MakeUIPlugin id? site.registerContextMenu(AutotoolsUIPlugin.getPluginId() + ".outline", manager, viewer); //$NON-NLS-1$ site.setSelectionProvider(viewer); @@ -247,7 +245,7 @@ public class MakefileContentOutlinePage extends ContentOutlinePage { menu.add(fOpenIncludeAction); } menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$ + menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end"));//$NON-NLS-1$ } /** diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileDocumentProvider.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileDocumentProvider.java index 71b7a86876b..d01b85ca87d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileDocumentProvider.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileDocumentProvider.java @@ -28,10 +28,10 @@ import org.eclipse.ui.editors.text.TextFileDocumentProvider; import org.eclipse.ui.texteditor.IDocumentProvider; public class MakefileDocumentProvider extends TextFileDocumentProvider implements IMakefileDocumentProvider { - + IMakefile fMakefile; - protected class MakefileAnnotationModel extends AnnotationModel /*implements IProblemRequestor */{ + protected class MakefileAnnotationModel extends AnnotationModel /*implements IProblemRequestor */ { /** * @param resource */ @@ -50,13 +50,14 @@ public class MakefileDocumentProvider extends TextFileDocumentProvider implement /** * Remembers a IMakefile for each element. */ - protected class MakefileFileInfo extends FileInfo { + protected class MakefileFileInfo extends FileInfo { public IMakefile fCopy; } public MakefileDocumentProvider() { - IDocumentProvider provider= new TextFileDocumentProvider(new MakefileStorageDocumentProvider()); - provider= new ForwardingDocumentProvider(MakefileDocumentSetupParticipant.MAKEFILE_PARTITIONING, new MakefileDocumentSetupParticipant(), provider); + IDocumentProvider provider = new TextFileDocumentProvider(new MakefileStorageDocumentProvider()); + provider = new ForwardingDocumentProvider(MakefileDocumentSetupParticipant.MAKEFILE_PARTITIONING, + new MakefileDocumentSetupParticipant(), provider); setParentDocumentProvider(provider); } @@ -69,57 +70,57 @@ public class MakefileDocumentProvider extends TextFileDocumentProvider implement return null; } - @Override + @Override protected IAnnotationModel createAnnotationModel(IFile file) { - return new MakefileAnnotationModel(file); - } + return new MakefileAnnotationModel(file); + } @Override protected FileInfo createFileInfo(Object element) throws CoreException { if (!(element instanceof IFileEditorInput)) return null; - - IFileEditorInput input= (IFileEditorInput) element; - IMakefile original= createMakefile(input.getFile()); + + IFileEditorInput input = (IFileEditorInput) element; + IMakefile original = createMakefile(input.getFile()); if (original == null) return null; - FileInfo info= super.createFileInfo(element); + FileInfo info = super.createFileInfo(element); if (!(info instanceof MakefileFileInfo)) { return null; } - - MakefileFileInfo makefileInfo= (MakefileFileInfo) info; + + MakefileFileInfo makefileInfo = (MakefileFileInfo) info; setUpSynchronization(makefileInfo); makefileInfo.fCopy = original; - if (makefileInfo.fModel instanceof MakefileAnnotationModel) { - MakefileAnnotationModel model= (MakefileAnnotationModel) makefileInfo.fModel; + if (makefileInfo.fModel instanceof MakefileAnnotationModel) { + MakefileAnnotationModel model = (MakefileAnnotationModel) makefileInfo.fModel; model.setMakefile(makefileInfo.fCopy); - } + } return makefileInfo; } - - @Override + + @Override protected void disposeFileInfo(Object element, FileInfo info) { - if (info instanceof MakefileFileInfo) { - MakefileFileInfo makefileInfo= (MakefileFileInfo) info; - if (makefileInfo.fCopy != null) { - makefileInfo.fCopy = null; - } - } - super.disposeFileInfo(element, info); - } - + if (info instanceof MakefileFileInfo) { + MakefileFileInfo makefileInfo = (MakefileFileInfo) info; + if (makefileInfo.fCopy != null) { + makefileInfo.fCopy = null; + } + } + super.disposeFileInfo(element, info); + } + @Override protected FileInfo createEmptyFileInfo() { return new MakefileFileInfo(); } - + @Override public IMakefile getWorkingCopy(Object element) { - FileInfo fileInfo= getFileInfo(element); + FileInfo fileInfo = getFileInfo(element); if (fileInfo instanceof MakefileFileInfo) { return ((MakefileFileInfo) fileInfo).fCopy; } @@ -132,5 +133,5 @@ public class MakefileDocumentProvider extends TextFileDocumentProvider implement while (e.hasNext()) disconnect(e.next()); } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileDocumentSetupParticipant.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileDocumentSetupParticipant.java index a26ad71df1e..3b73fecb57a 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileDocumentSetupParticipant.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileDocumentSetupParticipant.java @@ -24,28 +24,27 @@ import org.eclipse.jface.text.rules.FastPartitioner; * MakefileDocumentSetupParticipant * The document setup participant for Ant. */ -public class MakefileDocumentSetupParticipant implements IDocumentSetupParticipant { - +public class MakefileDocumentSetupParticipant implements IDocumentSetupParticipant { + /** * The name of the Makefile partitioning. */ - public final static String MAKEFILE_PARTITIONING= "___makefile_partitioning"; //$NON-NLS-1$ - + public final static String MAKEFILE_PARTITIONING = "___makefile_partitioning"; //$NON-NLS-1$ + public MakefileDocumentSetupParticipant() { } - + @Override public void setup(IDocument document) { if (document instanceof IDocumentExtension3) { - IDocumentExtension3 extension3= (IDocumentExtension3) document; + IDocumentExtension3 extension3 = (IDocumentExtension3) document; IDocumentPartitioner partitioner = createDocumentPartitioner(); extension3.setDocumentPartitioner(MAKEFILE_PARTITIONING, partitioner); partitioner.connect(document); - } + } } - + private IDocumentPartitioner createDocumentPartitioner() { - return new FastPartitioner( - new MakefilePartitionScanner(), MakefilePartitionScanner.MAKE_PARTITIONS); + return new FastPartitioner(new MakefilePartitionScanner(), MakefilePartitionScanner.MAKE_PARTITIONS); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditor.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditor.java index 72aa0fcb0cd..1b7c94f6fb6 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditor.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditor.java @@ -56,7 +56,6 @@ import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - public class MakefileEditor extends TextEditor implements ISelectionChangedListener, IReconcilingParticipant { /** @@ -73,11 +72,10 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe */ private ListenerList<IReconcilingParticipant> fReconcilingListeners = new ListenerList<>(ListenerList.IDENTITY); - MakefileSourceConfiguration getMakefileSourceConfiguration() { SourceViewerConfiguration configuration = getSourceViewerConfiguration(); if (configuration instanceof MakefileSourceConfiguration) { - return (MakefileSourceConfiguration)configuration; + return (MakefileSourceConfiguration) configuration; } return null; } @@ -113,13 +111,14 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe public void dispose() { if (fProjectionMakefileUpdater != null) { fProjectionMakefileUpdater.uninstall(); - fProjectionMakefileUpdater= null; + fProjectionMakefileUpdater = null; } super.dispose(); } boolean isFoldingEnabled() { - return AutotoolsPlugin.getDefault().getPreferenceStore().getBoolean(MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED); + return AutotoolsPlugin.getDefault().getPreferenceStore() + .getBoolean(MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED); } @Override @@ -142,9 +141,9 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe projectionViewer.doOperation(ProjectionViewer.TOGGLE); } -// ProjectionAnnotationModel model= (ProjectionAnnotationModel) getAdapter(ProjectionAnnotationModel.class); + // ProjectionAnnotationModel model= (ProjectionAnnotationModel) getAdapter(ProjectionAnnotationModel.class); - fProjectionMakefileUpdater= new ProjectionMakefileUpdater(); + fProjectionMakefileUpdater = new ProjectionMakefileUpdater(); if (fProjectionMakefileUpdater != null) { fProjectionMakefileUpdater.install(this, projectionViewer); fProjectionMakefileUpdater.initialize(); @@ -153,11 +152,12 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe @Override protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { - ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles); + ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), + styles); // ensure decoration support has been created and configured. getSourceViewerDecorationSupport(viewer); - + return viewer; } @@ -191,7 +191,8 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe ResourceBundle bundle = MakeUIMessages.getResourceBundle(); - IAction a = new TextOperationAction(bundle, "ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS); //$NON-NLS-1$ + IAction a = new TextOperationAction(bundle, "ContentAssistProposal.", this, //$NON-NLS-1$ + ISourceViewer.CONTENTASSIST_PROPOSALS); a.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); setAction("ContentAssistProposal", a); //$NON-NLS-1$ @@ -203,7 +204,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe a.setActionDefinitionId(IMakefileEditorActionDefinitionIds.COMMENT); setAction("Comment", a); //$NON-NLS-1$ markAsStateDependentAction("Comment", true); //$NON-NLS-1$ - + a = new TextOperationAction(bundle, "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$ a.setActionDefinitionId(IMakefileEditorActionDefinitionIds.UNCOMMENT); setAction("Uncomment", a); //$NON-NLS-1$ @@ -221,13 +222,13 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe ISelection selection = event.getSelection(); if (selection.isEmpty()) { resetHighlightRange(); - } else if (selection instanceof IStructuredSelection){ + } else if (selection instanceof IStructuredSelection) { if (!isActivePart() && AutotoolsUIPlugin.getActivePage() != null) { AutotoolsUIPlugin.getActivePage().bringToTop(this); - } - Object element = ((IStructuredSelection) selection).getFirstElement(); + } + Object element = ((IStructuredSelection) selection).getFirstElement(); if (element instanceof IDirective) { - IDirective statement = (IDirective)element; + IDirective statement = (IDirective) element; setSelection(statement, !isActivePart()); } } @@ -237,21 +238,21 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe * Returns whether the editor is active. */ private boolean isActivePart() { - IWorkbenchWindow window= getSite().getWorkbenchWindow(); - IPartService service= window.getPartService(); - IWorkbenchPart part= service.getActivePart(); + IWorkbenchWindow window = getSite().getWorkbenchWindow(); + IPartService service = window.getPartService(); + IWorkbenchPart part = service.getActivePart(); return part != null && part.equals(this); } /** * Returns the find/replace document adapter. - * + * * @return the find/replace document adapter. */ private FindReplaceDocumentAdapter getFindRepalceDocumentAdapter() { if (fFindReplaceDocumentAdapter == null) { IDocument doc = getDocumentProvider().getDocument(getEditorInput()); - fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(doc); + fFindReplaceDocumentAdapter = new FindReplaceDocumentAdapter(doc); } return fFindReplaceDocumentAdapter; } @@ -308,7 +309,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe /** * Adds the given listener. * Has no effect if an identical listener was not already registered. - * + * * @param listener The reconcile listener to be added * @since 3.0 */ @@ -317,11 +318,11 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe fReconcilingListeners.add(listener); } } - + /** * Removes the given listener. * Has no effect if an identical listener was not already registered. - * + * * @param listener the reconcile listener to be removed * @since 3.0 */ @@ -330,65 +331,64 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe fReconcilingListeners.remove(listener); } } - + @Override - public void reconciled() { + public void reconciled() { // Notify listeners - for (IReconcilingParticipant listener: fReconcilingListeners) { + for (IReconcilingParticipant listener : fReconcilingListeners) { listener.reconciled(); } } @Override protected void performRevert() { - ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer(); + ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer(); projectionViewer.setRedraw(false); try { - - boolean projectionMode= projectionViewer.isProjectionMode(); + + boolean projectionMode = projectionViewer.isProjectionMode(); if (projectionMode) { - projectionViewer.disableProjection(); + projectionViewer.disableProjection(); if (fProjectionMakefileUpdater != null) fProjectionMakefileUpdater.uninstall(); } - + super.performRevert(); - + if (projectionMode) { if (fProjectionMakefileUpdater != null) - fProjectionMakefileUpdater.install(this, projectionViewer); + fProjectionMakefileUpdater.install(this, projectionViewer); projectionViewer.enableProjection(); } - + } finally { projectionViewer.setRedraw(true); } } - @Override protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { - ISourceViewer sourceViewer= getSourceViewer(); + ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer == null) return; - String property = event.getProperty(); + String property = event.getProperty(); - MakefileSourceConfiguration makeConf = getMakefileSourceConfiguration(); - if (makeConf != null) { - if (makeConf.affectsBehavior(event)) { - makeConf.adaptToPreferenceChange(event); - sourceViewer.invalidateTextPresentation(); - } - } + MakefileSourceConfiguration makeConf = getMakefileSourceConfiguration(); + if (makeConf != null) { + if (makeConf.affectsBehavior(event)) { + makeConf.adaptToPreferenceChange(event); + sourceViewer.invalidateTextPresentation(); + } + } - if (MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED.equals(property)) { + if (MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED.equals(property)) { if (sourceViewer instanceof ProjectionViewer) { - ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer; + ProjectionViewer projectionViewer = (ProjectionViewer) sourceViewer; if (fProjectionMakefileUpdater != null) fProjectionMakefileUpdater.uninstall(); // either freshly enabled or provider changed - fProjectionMakefileUpdater= new ProjectionMakefileUpdater(); + fProjectionMakefileUpdater = new ProjectionMakefileUpdater(); if (fProjectionMakefileUpdater != null) { fProjectionMakefileUpdater.install(this, projectionViewer); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorActionContributor.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorActionContributor.java index 5babe2a1235..f0352083a70 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorActionContributor.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorActionContributor.java @@ -28,7 +28,6 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.RetargetTextEditorAction; - /** */ public class MakefileEditorActionContributor extends BasicTextEditorActionContributor { @@ -50,7 +49,7 @@ public class MakefileEditorActionContributor extends BasicTextEditorActionContri fContentAssistTip.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION); fTogglePresentation = new MakefileEditorTogglePresentationAction(); fOpenDeclarationAction = new OpenDeclarationAction(); - + } @Override @@ -72,7 +71,7 @@ public class MakefileEditorActionContributor extends BasicTextEditorActionContri fTogglePresentation.setEditor(editor); fTogglePresentation.update(); - + fOpenDeclarationAction.setEditor(editor); fOpenDeclarationAction.update(); } @@ -95,14 +94,15 @@ public class MakefileEditorActionContributor extends BasicTextEditorActionContri editMenu.add(fOpenDeclarationAction); } - bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation); + bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, + fTogglePresentation); // there is a global action in the toolbar, that is retargeted, // there is no need to add another one. -// IToolBarManager toolBarManager = bars.getToolBarManager(); -// if (toolBarManager != null) { -// toolBarManager.add(new Separator()); -// toolBarManager.add(fTogglePresentation); -// } + // IToolBarManager toolBarManager = bars.getToolBarManager(); + // if (toolBarManager != null) { + // toolBarManager.add(new Separator()); + // toolBarManager.add(fTogglePresentation); + // } } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorPreferenceConstants.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorPreferenceConstants.java index b30dda73b1a..46a966ebd02 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorPreferenceConstants.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorPreferenceConstants.java @@ -22,7 +22,7 @@ import org.eclipse.jface.preference.IPreferenceStore; public class MakefileEditorPreferenceConstants { /** - * + * */ private MakefileEditorPreferenceConstants() { } @@ -33,30 +33,27 @@ public class MakefileEditorPreferenceConstants { */ public static final String CURRENT_LINE_COLOR = "org.eclipse.cdt.make.ui.currentLineHightlightColor"; //$NON-NLS-1$ public static final String LINE_NUMBER_RULER_COLOR = "org.eclipse.cdt.make.ui.lineNumberForegroundColor"; //$NON-NLS-1$ - public static final String PRINT_MARGIN_COLOR = "org.eclipse.cdt.make.ui.printMarginColor"; //$NON-NLS-1$ - + public static final String PRINT_MARGIN_COLOR = "org.eclipse.cdt.make.ui.printMarginColor"; //$NON-NLS-1$ + /** * Preference key suffix for bold text style preference keys. - * + * */ - public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$ + public static final String EDITOR_BOLD_SUFFIX = "_bold"; //$NON-NLS-1$ /** * Preference key suffix for italic text style preference keys. */ - public static final String EDITOR_ITALIC_SUFFIX= "_italic"; //$NON-NLS-1$ - + public static final String EDITOR_ITALIC_SUFFIX = "_italic"; //$NON-NLS-1$ public static final String EDITOR_FOLDING_MACRODEF = "editor_folding_default_macrodef"; //$NON-NLS-1$ - public static final String EDITOR_FOLDING_RULE = "editor_folding_default_rule"; //$NON-NLS-1$ - public static final String EDITOR_FOLDING_CONDITIONAL = "editor_folding_default_conditional"; //$NON-NLS-1$ public static final String EDITOR_FOLDING_ENABLED = "editor_folding_enabled"; //$NON-NLS-1$ - + public static void initializeDefaultValues(IPreferenceStore store) { store.setDefault(MakefileEditorPreferenceConstants.EDITOR_FOLDING_ENABLED, false); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorTogglePresentationAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorTogglePresentationAction.java index 59fc131d881..87f1a50dbe0 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorTogglePresentationAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileEditorTogglePresentationAction.java @@ -19,7 +19,6 @@ import org.eclipse.cdt.internal.autotools.ui.MakeUIMessages; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.TextEditorAction; - /** */ public class MakefileEditorTogglePresentationAction extends TextEditorAction { @@ -35,7 +34,7 @@ public class MakefileEditorTogglePresentationAction extends TextEditorAction { @Override public void run() { - ITextEditor editor= getTextEditor(); + ITextEditor editor = getTextEditor(); editor.resetHighlightRange(); boolean show = editor.showsHighlightRangeOnly(); setChecked(!show); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileMessages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileMessages.java index dfe170a3b9d..951c7d0b6ba 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileMessages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileMessages.java @@ -19,43 +19,42 @@ import java.util.ResourceBundle; public class MakefileMessages { - private static final String BUNDLE_NAME = MakefileMessages.class.getName(); + private static final String BUNDLE_NAME = MakefileMessages.class.getName(); - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - private MakefileMessages() { - } + private MakefileMessages() { + } public static ResourceBundle getResourceBundle() { return RESOURCE_BUNDLE; } - + /** * Returns the string from the plugin's resource bundle, * or 'key' if not found. - * + * * @param key the message key * @return the resource bundle message */ - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } - + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } + /** * Returns the string from the plugin's resource bundle, * or 'key' if not found. - * + * * @param key the message key * @param args an array of substitution strings * @return the resource bundle message */ public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getString(key), (Object[])args); + return MessageFormat.format(getString(key), (Object[]) args); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefilePartitionScanner.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefilePartitionScanner.java index 4dfce01a352..cab5a77b6c3 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefilePartitionScanner.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefilePartitionScanner.java @@ -33,15 +33,9 @@ public class MakefilePartitionScanner extends RuleBasedPartitionScanner { public final static String MAKEFILE_DEF_BLOCK_PARTITION = "makefile_def_block"; //$NON-NLS-1$ public final static String MAKEFILE_OTHER_PARTITION = "makefile_other"; //$NON-NLS-1$ - final static String[] MAKE_PARTITIONS = - new String[] { - MAKEFILE_COMMENT_PARTITION, - MAKEFILE_MACRO_ASSIGNEMENT_PARTITION, - MAKEFILE_INCLUDE_BLOCK_PARTITION, - MAKEFILE_IF_BLOCK_PARTITION, - MAKEFILE_DEF_BLOCK_PARTITION, - MAKEFILE_OTHER_PARTITION, - }; + final static String[] MAKE_PARTITIONS = new String[] { MAKEFILE_COMMENT_PARTITION, + MAKEFILE_MACRO_ASSIGNEMENT_PARTITION, MAKEFILE_INCLUDE_BLOCK_PARTITION, MAKEFILE_IF_BLOCK_PARTITION, + MAKEFILE_DEF_BLOCK_PARTITION, MAKEFILE_OTHER_PARTITION, }; /** The predefined delimiters of this tracker */ private char[][] fModDelimiters = { { '\r', '\n' }, { '\r' }, { '\n' } }; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileReader.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileReader.java index 9c8213a40db..bbd0c1225e2 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileReader.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileReader.java @@ -21,7 +21,6 @@ import java.io.Reader; */ public class MakefileReader extends LineNumberReader { - public MakefileReader(Reader reader) { super(reader); } @@ -30,7 +29,6 @@ public class MakefileReader extends LineNumberReader { super(reader, sz); } - @Override public String readLine() throws IOException { boolean done = false; @@ -47,7 +45,7 @@ public class MakefileReader extends LineNumberReader { // Eat the spaces at the beginning. int i = 0; while (i < line.length() && (Util.isSpace(line.charAt(i)))) { - i++ ; + i++; } line = line.substring(i); } else if (escapedCommand && line.length() > 0) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileReconcilingStrategy.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileReconcilingStrategy.java index 923fbd41020..e978b6152dd 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileReconcilingStrategy.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileReconcilingStrategy.java @@ -27,39 +27,35 @@ import org.eclipse.jface.text.reconciler.IReconcilingStrategy; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; - - public class MakefileReconcilingStrategy implements IReconcilingStrategy { - private int fLastRegionOffset; - private ITextEditor fEditor; + private ITextEditor fEditor; private IWorkingCopyManager fManager; private IDocumentProvider fDocumentProvider; private MakefileContentOutlinePage fOutliner; private IReconcilingParticipant fMakefileReconcilingParticipant; public MakefileReconcilingStrategy(MakefileEditor editor) { - fOutliner= editor.getOutlinePage(); + fOutliner = editor.getOutlinePage(); fLastRegionOffset = Integer.MAX_VALUE; - fEditor= editor; - fManager= AutomakeEditorFactory.getDefault().getWorkingCopyManager(); - fDocumentProvider= AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider(); - fMakefileReconcilingParticipant= (IReconcilingParticipant)fEditor; + fEditor = editor; + fManager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + fDocumentProvider = AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider(); + fMakefileReconcilingParticipant = (IReconcilingParticipant) fEditor; } - + @Override public void setDocument(IDocument document) { - } - + } @Override public void reconcile(IRegion region) { // We use a trick to avoid running the reconciler multiple times // on a file when it gets changed. This is because this gets called - // multiple times with different regions of the file, we do a + // multiple times with different regions of the file, we do a // complete parse on the first region. - if(region.getOffset() <= fLastRegionOffset) { + if (region.getOffset() <= fLastRegionOffset) { reconcile(); } fLastRegionOffset = region.getOffset(); @@ -71,7 +67,7 @@ public class MakefileReconcilingStrategy implements IReconcilingStrategy { // the contentouline viewer. //reconcile(); } - + private void reconcile() { try { IMakefile makefile = fManager.getWorkingCopy(fEditor.getEditorInput()); @@ -82,7 +78,7 @@ public class MakefileReconcilingStrategy implements IReconcilingStrategy { makefile.parse(makefile.getFileURI(), reader); } catch (IOException e) { } - + fOutliner.update(); } } finally { @@ -94,5 +90,5 @@ public class MakefileReconcilingStrategy implements IReconcilingStrategy { // } } - } + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileSourceConfiguration.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileSourceConfiguration.java index d6e1a28b6c3..daad4961c26 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileSourceConfiguration.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileSourceConfiguration.java @@ -35,7 +35,6 @@ import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.graphics.RGB; import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; - public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { private ColorManager colorManager; @@ -62,14 +61,11 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { @Override public String[] getConfiguredContentTypes(ISourceViewer v) { - return new String[] { - IDocument.DEFAULT_CONTENT_TYPE, - MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION, - MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION, - MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION, - MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION, - MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION, - }; + return new String[] { IDocument.DEFAULT_CONTENT_TYPE, MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION, + MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION, + MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION, + MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION, + MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION, }; } @@ -77,11 +73,16 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ContentAssistant assistant = new ContentAssistant(); assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), IDocument.DEFAULT_CONTENT_TYPE); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION); - assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), + MakefilePartitionScanner.MAKEFILE_COMMENT_PARTITION); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), + MakefilePartitionScanner.MAKEFILE_DEF_BLOCK_PARTITION); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), + MakefilePartitionScanner.MAKEFILE_IF_BLOCK_PARTITION); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), + MakefilePartitionScanner.MAKEFILE_INCLUDE_BLOCK_PARTITION); + assistant.setContentAssistProcessor(new MakefileCompletionProcessor(fEditor), + MakefilePartitionScanner.MAKEFILE_MACRO_ASSIGNEMENT_PARTITION); assistant.enableAutoActivation(true); assistant.setAutoActivationDelay(500); @@ -140,7 +141,7 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { @Override public IReconciler getReconciler(ISourceViewer sourceViewer) { if (fEditor != null && fEditor.isEditable()) { - MonoReconciler reconciler= new MonoReconciler(new MakefileReconcilingStrategy(fEditor), false); + MonoReconciler reconciler = new MonoReconciler(new MakefileReconcilingStrategy(fEditor), false); reconciler.setDelay(1000); reconciler.setProgressMonitor(new NullProgressMonitor()); return reconciler; @@ -150,13 +151,14 @@ public class MakefileSourceConfiguration extends TextSourceViewerConfiguration { @Override public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) { - return new String[]{"#"}; //$NON-NLS-1$ + return new String[] { "#" }; //$NON-NLS-1$ } @Override public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { return new MakefileTextHover(fEditor); } + @Override public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { return new MakefileAnnotationHover(fEditor); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileStorageDocumentProvider.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileStorageDocumentProvider.java index e27a41b52f6..f5d1966378e 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileStorageDocumentProvider.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileStorageDocumentProvider.java @@ -28,9 +28,9 @@ public class MakefileStorageDocumentProvider extends StorageDocumentProvider { @Override protected void setupDocument(Object element, IDocument document) { if (document != null) { - IDocumentPartitioner partitioner= createDocumentPartitioner(); + IDocumentPartitioner partitioner = createDocumentPartitioner(); if (document instanceof IDocumentExtension3) { - IDocumentExtension3 extension3= (IDocumentExtension3) document; + IDocumentExtension3 extension3 = (IDocumentExtension3) document; extension3.setDocumentPartitioner(MakefileDocumentSetupParticipant.MAKEFILE_PARTITIONING, partitioner); } else { document.setDocumentPartitioner(partitioner); @@ -38,10 +38,9 @@ public class MakefileStorageDocumentProvider extends StorageDocumentProvider { partitioner.connect(document); } } - + private IDocumentPartitioner createDocumentPartitioner() { - return new FastPartitioner( - new MakefilePartitionScanner(), MakefilePartitionScanner.MAKE_PARTITIONS); + return new FastPartitioner(new MakefilePartitionScanner(), MakefilePartitionScanner.MAKE_PARTITIONS); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileTextHover.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileTextHover.java index d08c03de15b..959c705024b 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileTextHover.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MakefileTextHover.java @@ -26,17 +26,16 @@ import org.eclipse.jface.text.Region; import org.eclipse.swt.graphics.Point; import org.eclipse.ui.IEditorPart; - /** * MakefileTextHover - * + * */ public class MakefileTextHover implements ITextHover { private IEditorPart fEditor; /** - * + * */ public MakefileTextHover(IEditorPart editor) { fEditor = editor; @@ -62,7 +61,7 @@ public class MakefileTextHover implements ITextHover { statements = makefile.getBuiltinMacroDefinitions(name); } } - + if (statements == null) { statements = new IMacroDefinition[0]; } @@ -75,7 +74,7 @@ public class MakefileTextHover implements ITextHover { String infoString = statements[i].getValue().toString(); buffer.append(name); buffer.append(" - "); //$NON-NLS-1$ - buffer.append(infoString); + buffer.append(infoString); } return buffer.toString(); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MessageLine.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MessageLine.java index 6e4fd38da12..6fb21f98b08 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MessageLine.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/MessageLine.java @@ -22,8 +22,8 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; /** - * A message line. It distinguishs between "normal" messages and errors. - * Setting an error message hides a currently displayed message until + * A message line. It distinguishs between "normal" messages and errors. + * Setting an error message hides a currently displayed message until * <code>clearErrorMessage</code> is called. */ public class MessageLine { @@ -36,7 +36,7 @@ public class MessageLine { private RGB fErrorRGB; protected Color fErrorColor; - private static RGB fgErrorRGB= new RGB(200, 0, 0); + private static RGB fgErrorRGB = new RGB(200, 0, 0); /** * Clears the currently displayed error message and redisplayes @@ -45,12 +45,14 @@ public class MessageLine { public void clearErrorMessage() { setErrorMessage(null); } + /** * Clears the currently displayed message. */ public void clearMessage() { setMessage(null); } + /** * Get the currently displayed error text. * @return The error message. If no error message is displayed <code>null</code> is returned. @@ -58,6 +60,7 @@ public class MessageLine { public String getErrorMessage() { return fErrorText; } + /** * Get the currently displayed message. * @return The message. If no message is displayed <code>null<code> is returned. @@ -65,24 +68,27 @@ public class MessageLine { public String getMessage() { return fMessageText; } + /** * Creates a new message line as a child of the parent and with the given SWT stylebits. * Error message will be shown with in the given rgb color. */ public MessageLine(Composite parent, int style, RGB errorRGB) { clabel = new CLabel(parent, style); - fDefaultColor= clabel.getForeground(); - fErrorRGB= errorRGB; + fDefaultColor = clabel.getForeground(); + fErrorRGB = errorRGB; } + /** * Creates a new message line as a child of the parent and with the given SWT stylebits. * Error message will be shown with in the rgb color 200,0,0. */ public MessageLine(Composite parent, int style) { clabel = new CLabel(parent, style); - fDefaultColor= clabel.getForeground(); - fErrorRGB= fgErrorRGB; + fDefaultColor = clabel.getForeground(); + fErrorRGB = fgErrorRGB; } + /** * Creates a new message line as a child of the given parent. * Error message will be shown with in the rgb color 200,0,0. @@ -90,55 +96,58 @@ public class MessageLine { public MessageLine(Composite parent) { this(parent, SWT.LEFT); } + /** * Sets the default error color used by all message lines. - * Note: a call to this method only affects newly created MessageLines not existing ones. + * Note: a call to this method only affects newly created MessageLines not existing ones. */ public static void setErrorColor(RGB color) { - fgErrorRGB= color; + fgErrorRGB = color; } + /** * Display the given error message. A currently displayed message * is saved and will be redisplayed when the error message is cleared. */ public void setErrorMessage(String message) { - fErrorText= message; + fErrorText = message; if (message == null) { setMessage(fMessageText); } else { if (fErrorColor == null) { - fErrorColor= new Color(clabel.getDisplay(), fErrorRGB); + fErrorColor = new Color(clabel.getDisplay(), fErrorRGB); clabel.addDisposeListener(e -> fErrorColor.dispose()); } clabel.setForeground(fErrorColor); clabel.setText(message); } } + /** * Set the message text. If the message line currently displays an error, * the message is stored and will be shown after a call to clearErrorMessage */ public void setMessage(String message) { - fMessageText= message; + fMessageText = message; if (message == null) - message= ""; //$NON-NLS-1$ + message = ""; //$NON-NLS-1$ if (fErrorText == null) { clabel.setForeground(fDefaultColor); clabel.setText(message); } } - + public boolean isDisposed() { return clabel.isDisposed(); } - + public void setAlignment(int left) { clabel.setAlignment(left); } - + public void setLayoutData(GridData gridData) { clabel.setLayoutData(gridData); } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/NullMakefile.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/NullMakefile.java index e9c1d47d4ca..bd461cee641 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/NullMakefile.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/NullMakefile.java @@ -25,15 +25,15 @@ import org.eclipse.cdt.make.core.makefile.IDirective; * statement : rule | macro_definition | comments | empty * rule : inference_rule | target_rule * inference_rule : target ':' <nl> ( <tab> command <nl> ) + - * target_rule : target [ ( target ) * ] ':' [ ( prerequisite ) * ] [ ';' command ] <nl> + * target_rule : target [ ( target ) * ] ':' [ ( prerequisite ) * ] [ ';' command ] <nl> [ ( command ) * ] - * macro_definition : string '=' (string)* + * macro_definition : string '=' (string)* * comments : ('#' (string) <nl>) * * empty : <nl> * command : <tab> prefix_command string <nl> * target : string * prefix_command : '-' | '@' | '+' - * internal_macro : "$<" | "$*" | "$@" | "$?" | "$%" + * internal_macro : "$<" | "$*" | "$@" | "$?" | "$%" */ public class NullMakefile extends AbstractMakefile { @@ -65,11 +65,11 @@ public class NullMakefile extends AbstractMakefile { @Override public void parse(String name, Reader makefile) { } - + @Override public void parse(URI fileURI, Reader reader) { } - + protected void parse(URI fileURI, MakefileReader reader) { } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OpenDeclarationAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OpenDeclarationAction.java index 3cffacf147b..e5463865112 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OpenDeclarationAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OpenDeclarationAction.java @@ -38,7 +38,6 @@ import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.TextEditorAction; - public class OpenDeclarationAction extends TextEditorAction { public OpenDeclarationAction() { @@ -96,7 +95,7 @@ public class OpenDeclarationAction extends TextEditorAction { if (p != null) { IEditorPart editorPart = IDE.openEditor(p, file, true); if (editorPart instanceof MakefileEditor) { - ((MakefileEditor)editorPart).setSelection(directive, true); + ((MakefileEditor) editorPart).setSelection(directive, true); } return editorPart; } @@ -109,11 +108,11 @@ public class OpenDeclarationAction extends TextEditorAction { String editorID = "org.eclipse.cdt.make.editor"; //$NON-NLS-1$ IEditorPart editorPart = IDE.openEditor(p, input, editorID, true); if (editorPart instanceof MakefileEditor) { - ((MakefileEditor)editorPart).setSelection(directive, true); + ((MakefileEditor) editorPart).setSelection(directive, true); } return editorPart; } - + } return null; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OpenIncludeAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OpenIncludeAction.java index cbf314b8a40..c7e8e1604d7 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OpenIncludeAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OpenIncludeAction.java @@ -54,42 +54,38 @@ import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.MessageBox; - - public class OpenIncludeAction extends Action { + private static final String PREFIX = "OpenIncludeAction."; //$NON-NLS-1$ - private static final String PREFIX= "OpenIncludeAction."; //$NON-NLS-1$ - - private static final String DIALOG_TITLE= PREFIX + "dialog.title"; //$NON-NLS-1$ - private static final String DIALOG_MESSAGE= PREFIX + "dialog.message"; //$NON-NLS-1$ - - private ISelectionProvider fSelectionProvider; + private static final String DIALOG_TITLE = PREFIX + "dialog.title"; //$NON-NLS-1$ + private static final String DIALOG_MESSAGE = PREFIX + "dialog.message"; //$NON-NLS-1$ + private ISelectionProvider fSelectionProvider; public OpenIncludeAction(ISelectionProvider provider) { super(CUIPlugin.getResourceString(PREFIX + "label")); //$NON-NLS-1$ setDescription(CUIPlugin.getResourceString(PREFIX + "description")); //$NON-NLS-1$ setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip")); //$NON-NLS-1$ - + MakeUIImages.setImageDescriptors(this, MakeUIImages.T_LCL, MakeUIImages.IMG_MENU_OPEN_INCLUDE); - - fSelectionProvider= provider; + + fSelectionProvider = provider; } - + @Override public void run() { - IInclude include= getIncludeStatement(fSelectionProvider.getSelection()); + IInclude include = getIncludeStatement(fSelectionProvider.getSelection()); if (include == null) { return; } - + try { IResource res = include.getUnderlyingResource(); ArrayList<Object> filesFound = new ArrayList<>(4); - String fullFileName= include.getFullFileName(); + String fullFileName = include.getFullFileName(); if (fullFileName != null) { - IPath fullPath= new Path(fullFileName); + IPath fullPath = new Path(fullFileName); if (fullPath.isAbsolute() && fullPath.toFile().exists()) { filesFound.add(fullPath); } @@ -98,7 +94,7 @@ public class OpenIncludeAction extends Action { IProject proj = res.getProject(); String includeName = include.getElementName(); // Search in the scannerInfo information - IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(proj); + IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(proj); if (provider != null) { IScannerInfo info = provider.getScannerInformation(res); // XXXX this should fall back to project by itself @@ -107,14 +103,14 @@ public class OpenIncludeAction extends Action { } if (info != null) { IExtendedScannerInfo scanInfo = new ExtendedScannerInfo(info); - + boolean isSystemInclude = include.isStandard(); - + if (!isSystemInclude) { // search in current directory - IPath location= include.getTranslationUnit().getLocation(); + IPath location = include.getTranslationUnit().getLocation(); if (location != null) { - String currentDir= location.removeLastSegments(1).toOSString(); + String currentDir = location.removeLastSegments(1).toOSString(); findFile(new String[] { currentDir }, includeName, filesFound); } if (filesFound.isEmpty()) { @@ -123,14 +119,14 @@ public class OpenIncludeAction extends Action { findFile(localIncludePaths, includeName, filesFound); } } - + if (filesFound.isEmpty()) { // search in <...> include directories String[] includePaths = scanInfo.getIncludePaths(); findFile(includePaths, includeName, filesFound); } } - + if (filesFound.isEmpty()) { // Fall back and search the project findFile(proj, new Path(includeName), filesFound); @@ -138,43 +134,43 @@ public class OpenIncludeAction extends Action { } } IPath fileToOpen; - int nElementsFound= filesFound.size(); + int nElementsFound = filesFound.size(); if (nElementsFound == 0) { noElementsFound(); - fileToOpen= null; + fileToOpen = null; } else if (nElementsFound == 1) { - fileToOpen= (IPath) filesFound.get(0); + fileToOpen = (IPath) filesFound.get(0); } else { - fileToOpen= chooseFile(filesFound); + fileToOpen = chooseFile(filesFound); } - + if (fileToOpen != null) { EditorUtility.openInEditor(fileToOpen, include); - } + } } catch (CoreException e) { CUIPlugin.log(e.getStatus()); } } /** - * + * */ private void noElementsFound() { MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK); errorMsg.setText(CUIPlugin.getResourceString("OpenIncludeAction.error")); //$NON-NLS-1$ - errorMsg.setMessage (CUIPlugin.getResourceString("OpenIncludeAction.error.description")); //$NON-NLS-1$ + errorMsg.setMessage(CUIPlugin.getResourceString("OpenIncludeAction.error.description")); //$NON-NLS-1$ errorMsg.open(); } - + private boolean isInProject(IPath path) { - return getWorkspaceRoot().getFileForLocation(path) != null; + return getWorkspaceRoot().getFileForLocation(path) != null; } - + /** * Returns the path as is, if it points to a workspace resource. If the path * does not point to a workspace resource, but there are linked workspace * resources pointing to it, returns the paths of these resources. - * Othervise, returns the path as is. + * Othervise, returns the path as is. */ private IPath[] resolveIncludeLink(IPath path) { if (!isInProject(path)) { @@ -182,22 +178,22 @@ public class OpenIncludeAction extends Action { if (files.length > 0) { IPath[] paths = new IPath[files.length]; for (int i = 0; i < files.length; i++) { - paths[i] = files[i].getFullPath(); + paths[i] = files[i].getFullPath(); } return paths; } } - + return new IPath[] { path }; } private IWorkspaceRoot getWorkspaceRoot() { return ResourcesPlugin.getWorkspace().getRoot(); } - + private void findFile(String[] includePaths, String name, List<Object> list) { // in case it is an absolute path - IPath includeFile= new Path(name); + IPath includeFile = new Path(name); if (includeFile.isAbsolute()) { includeFile = PathUtil.getCanonicalPath(includeFile); if (includeFile.toFile().exists()) { @@ -217,7 +213,7 @@ public class OpenIncludeAction extends Action { list.add(p); } } - } + } } } @@ -245,53 +241,52 @@ public class OpenIncludeAction extends Action { }, 0); } - private IPath chooseFile(ArrayList<Object> filesFound) { - ILabelProvider renderer= new LabelProvider() { + ILabelProvider renderer = new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IPath) { - IPath file= (IPath)element; - return file.lastSegment() + " - " + file.toString(); //$NON-NLS-1$ + IPath file = (IPath) element; + return file.lastSegment() + " - " + file.toString(); //$NON-NLS-1$ } return super.getText(element); } }; - - ElementListSelectionDialog dialog= new ElementListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(), renderer, false, false); + + ElementListSelectionDialog dialog = new ElementListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(), + renderer, false, false); dialog.setTitle(CUIPlugin.getResourceString(DIALOG_TITLE)); dialog.setMessage(CUIPlugin.getResourceString(DIALOG_MESSAGE)); dialog.setElements(filesFound); - + if (dialog.open() == Window.OK) { return (IPath) dialog.getSelectedElement(); } return null; } - private static IInclude getIncludeStatement(ISelection sel) { if (!sel.isEmpty() && sel instanceof IStructuredSelection) { List<?> list = ((IStructuredSelection) sel).toList(); if (list.size() == 1) { - Object element= list.get(0); + Object element = list.get(0); if (element instanceof IInclude) { - return (IInclude)element; + return (IInclude) element; } } } return null; } - + public static boolean canActionBeAdded(ISelection selection) { ICElement include = getIncludeStatement(selection); if (include != null) { IResource res = include.getUnderlyingResource(); if (res != null) { - return true; + return true; } } return false; - } + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OverrideDefine.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OverrideDefine.java index 33a715efb08..f1c336383d9 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OverrideDefine.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/OverrideDefine.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - public class OverrideDefine extends DefineVariable { public OverrideDefine(Directive parent, String name, StringBuffer value) { @@ -22,7 +21,8 @@ public class OverrideDefine extends DefineVariable { @Override public String toString() { - StringBuffer sb = new StringBuffer(GNUMakefileConstants.VARIABLE_OVERRIDE + " " + GNUMakefileConstants.VARIABLE_DEFINE); //$NON-NLS-1$ + StringBuffer sb = new StringBuffer( + GNUMakefileConstants.VARIABLE_OVERRIDE + " " + GNUMakefileConstants.VARIABLE_DEFINE); //$NON-NLS-1$ sb.append(getName()).append('\n'); sb.append(getValue()); sb.append(GNUMakefileConstants.TERMINAL_ENDEF); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Parent.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Parent.java index 95a65408f49..2c4d0f377cb 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Parent.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Parent.java @@ -61,7 +61,7 @@ public abstract class Parent extends Directive implements IParent { public Directive[] getStatements() { children.trimToSize(); - return children.toArray(new Directive[0]); + return children.toArray(new Directive[0]); } @Override diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/PosixMakefileUtil.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/PosixMakefileUtil.java index a1fa4298340..38676f30e7c 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/PosixMakefileUtil.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/PosixMakefileUtil.java @@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; import java.util.ArrayList; import java.util.List; - /** */ public class PosixMakefileUtil { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ProjectionMakefileUpdater.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ProjectionMakefileUpdater.java index db84b997e75..d5db583f817 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ProjectionMakefileUpdater.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ProjectionMakefileUpdater.java @@ -40,52 +40,50 @@ import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; import org.eclipse.jface.text.source.projection.ProjectionViewer; import org.eclipse.ui.texteditor.IDocumentProvider; - /** * ProjectionMakefileUpdater */ public class ProjectionMakefileUpdater implements IProjectionListener { private static class MakefileProjectionAnnotation extends ProjectionAnnotation { - + private IDirective fDirective; private boolean fIsComment; - + public MakefileProjectionAnnotation(IDirective element, boolean isCollapsed, boolean isComment) { super(isCollapsed); fDirective = element; fIsComment = isComment; } - + public IDirective getElement() { return fDirective; } - + public void setElement(IDirective element) { fDirective = element; } - + public boolean isComment() { return fIsComment; } } - public void install(MakefileEditor editor, ProjectionViewer viewer) { - fEditor= editor; - fViewer= viewer; + fEditor = editor; + fViewer = viewer; fViewer.addProjectionListener(this); } - + public void uninstall() { if (isInstalled()) { projectionDisabled(); fViewer.removeProjectionListener(this); - fViewer= null; - fEditor= null; + fViewer = null; + fEditor = null; } } - + protected boolean isInstalled() { return fEditor != null; } @@ -120,37 +118,37 @@ public class ProjectionMakefileUpdater implements IProjectionListener { // we have to make sure that we disable first when getting an enable // message. projectionDisabled(); - - initialize(); - fParticipant= new ReconcilerParticipant(); + + initialize(); + fParticipant = new ReconcilerParticipant(); fEditor.addReconcilingParticipant(fParticipant); } - + @Override public void projectionDisabled() { - fCachedDocument= null; + fCachedDocument = null; if (fParticipant != null) { fEditor.addReconcilingParticipant(fParticipant); - fParticipant= null; + fParticipant = null; } } - + public void initialize() { - + if (!isInstalled()) return; - + initializePreferences(); - + try { - - IDocumentProvider provider= fEditor.getDocumentProvider(); - fCachedDocument= provider.getDocument(fEditor.getEditorInput()); - fAllowCollapsing= true; - - IWorkingCopyManager manager= AutomakeEditorFactory.getDefault().getWorkingCopyManager(); - fInput= manager.getWorkingCopy(fEditor.getEditorInput()); - + + IDocumentProvider provider = fEditor.getDocumentProvider(); + fCachedDocument = provider.getDocument(fEditor.getEditorInput()); + fAllowCollapsing = true; + + IWorkingCopyManager manager = AutomakeEditorFactory.getDefault().getWorkingCopyManager(); + fInput = manager.getWorkingCopy(fEditor.getEditorInput()); + if (fInput != null) { ProjectionAnnotationModel model = fEditor.getAdapter(ProjectionAnnotationModel.class); if (model != null) { @@ -159,10 +157,10 @@ public class ProjectionMakefileUpdater implements IProjectionListener { model.replaceAnnotations(null, additions); } } - + } finally { - fCachedDocument= null; - fAllowCollapsing= false; + fCachedDocument = null; + fAllowCollapsing = false; } } @@ -175,38 +173,38 @@ public class ProjectionMakefileUpdater implements IProjectionListener { } private Map<MakefileProjectionAnnotation, Position> computeAdditions(IParent parent) { - Map<MakefileProjectionAnnotation, Position> map= new HashMap<>(); + Map<MakefileProjectionAnnotation, Position> map = new HashMap<>(); computeAdditions(parent.getDirectives(), map); return map; } private void computeAdditions(IDirective[] elements, Map<MakefileProjectionAnnotation, Position> map) { - for (int i= 0; i < elements.length; i++) { - IDirective element= elements[i]; - + for (int i = 0; i < elements.length; i++) { + IDirective element = elements[i]; + computeAdditions(element, map); - + if (element instanceof IParent) { - IParent parent= (IParent) element; + IParent parent = (IParent) element; computeAdditions(parent.getDirectives(), map); } } } private void computeAdditions(IDirective element, Map<MakefileProjectionAnnotation, Position> map) { - - boolean createProjection= false; - + + boolean createProjection = false; + if (element instanceof IConditional) { - createProjection= true; + createProjection = true; } else if (element instanceof IMacroDefinition) { - createProjection= true; + createProjection = true; } else if (element instanceof IRule) { - createProjection= true; + createProjection = true; } - + if (createProjection) { - Position position= createProjectionPosition(element); + Position position = createProjectionPosition(element); if (position != null) { map.put(new MakefileProjectionAnnotation(element, fAllowCollapsing, true), position); } @@ -214,61 +212,60 @@ public class ProjectionMakefileUpdater implements IProjectionListener { } private Position createProjectionPosition(IDirective element) { - + if (fCachedDocument == null) return null; - - try { - int startLine= element.getStartLine() - 1; - int endLine= element.getEndLine() - 1; + + try { + int startLine = element.getStartLine() - 1; + int endLine = element.getEndLine() - 1; if (startLine != endLine) { - int offset= fCachedDocument.getLineOffset(startLine); - int endOffset= fCachedDocument.getLineOffset(endLine + 1); + int offset = fCachedDocument.getLineOffset(startLine); + int endOffset = fCachedDocument.getLineOffset(endLine + 1); return new Position(offset, endOffset - offset); } - + } catch (BadLocationException x) { } - + return null; } public void processReconcile() { if (!isInstalled()) return; - - ProjectionAnnotationModel model= fEditor.getAdapter(ProjectionAnnotationModel.class); + + ProjectionAnnotationModel model = fEditor.getAdapter(ProjectionAnnotationModel.class); if (model == null) return; - + try { - IDocumentProvider provider= fEditor.getDocumentProvider(); - fCachedDocument= provider.getDocument(fEditor.getEditorInput()); - fAllowCollapsing= false; - - Map<MakefileProjectionAnnotation, Position> additions= new HashMap<>(); - List<MakefileProjectionAnnotation> deletions= new ArrayList<>(); - List<MakefileProjectionAnnotation> updates= new ArrayList<>(); - - Map<MakefileProjectionAnnotation, Position> updated= computeAdditions((IParent) fInput); - Map<IDirective, List<MakefileProjectionAnnotation>> previous= createAnnotationMap(model); - - - Iterator<MakefileProjectionAnnotation> e= updated.keySet().iterator(); + IDocumentProvider provider = fEditor.getDocumentProvider(); + fCachedDocument = provider.getDocument(fEditor.getEditorInput()); + fAllowCollapsing = false; + + Map<MakefileProjectionAnnotation, Position> additions = new HashMap<>(); + List<MakefileProjectionAnnotation> deletions = new ArrayList<>(); + List<MakefileProjectionAnnotation> updates = new ArrayList<>(); + + Map<MakefileProjectionAnnotation, Position> updated = computeAdditions((IParent) fInput); + Map<IDirective, List<MakefileProjectionAnnotation>> previous = createAnnotationMap(model); + + Iterator<MakefileProjectionAnnotation> e = updated.keySet().iterator(); while (e.hasNext()) { - MakefileProjectionAnnotation annotation= e.next(); - IDirective element= annotation.getElement(); - Position position= updated.get(annotation); - - List<MakefileProjectionAnnotation> annotations= previous.get(element); + MakefileProjectionAnnotation annotation = e.next(); + IDirective element = annotation.getElement(); + Position position = updated.get(annotation); + + List<MakefileProjectionAnnotation> annotations = previous.get(element); if (annotations == null) { additions.put(annotation, position); } else { - Iterator<MakefileProjectionAnnotation> x= annotations.iterator(); + Iterator<MakefileProjectionAnnotation> x = annotations.iterator(); while (x.hasNext()) { - MakefileProjectionAnnotation a= x.next(); + MakefileProjectionAnnotation a = x.next(); if (annotation.isComment() == a.isComment()) { - Position p= model.getPosition(a); + Position p = model.getPosition(a); if (p != null && !position.equals(p)) { p.setOffset(position.getOffset()); p.setLength(position.getLength()); @@ -278,109 +275,109 @@ public class ProjectionMakefileUpdater implements IProjectionListener { break; } } - + if (annotations.isEmpty()) previous.remove(element); } } - + Iterator<List<MakefileProjectionAnnotation>> e2 = previous.values().iterator(); while (e.hasNext()) { - List<MakefileProjectionAnnotation> list= e2.next(); - int size= list.size(); - for (int i= 0; i < size; i++) + List<MakefileProjectionAnnotation> list = e2.next(); + int size = list.size(); + for (int i = 0; i < size; i++) deletions.add(list.get(i)); } match(model, deletions, additions, updates); - Annotation[] removals= new Annotation[deletions.size()]; + Annotation[] removals = new Annotation[deletions.size()]; deletions.toArray(removals); - Annotation[] changes= new Annotation[updates.size()]; + Annotation[] changes = new Annotation[updates.size()]; updates.toArray(changes); model.modifyAnnotations(removals, additions, changes); - + } finally { - fCachedDocument= null; - fAllowCollapsing= true; + fCachedDocument = null; + fAllowCollapsing = true; } } - private void match(ProjectionAnnotationModel model, List<MakefileProjectionAnnotation> deletions, + private void match(ProjectionAnnotationModel model, List<MakefileProjectionAnnotation> deletions, Map<MakefileProjectionAnnotation, Position> additions, List<MakefileProjectionAnnotation> changes) { if (deletions.isEmpty() || (additions.isEmpty() && changes.isEmpty())) return; - - List<MakefileProjectionAnnotation> newDeletions= new ArrayList<>(); - List<MakefileProjectionAnnotation> newChanges= new ArrayList<>(); - - Iterator<MakefileProjectionAnnotation> deletionIterator= deletions.iterator(); + + List<MakefileProjectionAnnotation> newDeletions = new ArrayList<>(); + List<MakefileProjectionAnnotation> newChanges = new ArrayList<>(); + + Iterator<MakefileProjectionAnnotation> deletionIterator = deletions.iterator(); outer: while (deletionIterator.hasNext()) { - MakefileProjectionAnnotation deleted= deletionIterator.next(); - Position deletedPosition= model.getPosition(deleted); + MakefileProjectionAnnotation deleted = deletionIterator.next(); + Position deletedPosition = model.getPosition(deleted); if (deletedPosition == null) continue; - - Iterator<MakefileProjectionAnnotation> changesIterator= changes.iterator(); + + Iterator<MakefileProjectionAnnotation> changesIterator = changes.iterator(); while (changesIterator.hasNext()) { - MakefileProjectionAnnotation changed= changesIterator.next(); + MakefileProjectionAnnotation changed = changesIterator.next(); if (deleted.isComment() == changed.isComment()) { - Position changedPosition= model.getPosition(changed); + Position changedPosition = model.getPosition(changed); if (changedPosition == null) continue; - + if (deletedPosition.getOffset() == changedPosition.getOffset()) { - + deletedPosition.setLength(changedPosition.getLength()); deleted.setElement(changed.getElement()); - + deletionIterator.remove(); newChanges.add(deleted); - + changesIterator.remove(); newDeletions.add(changed); - + continue outer; } } } - - Iterator<MakefileProjectionAnnotation> additionsIterator= additions.keySet().iterator(); + + Iterator<MakefileProjectionAnnotation> additionsIterator = additions.keySet().iterator(); while (additionsIterator.hasNext()) { - MakefileProjectionAnnotation added= additionsIterator.next(); + MakefileProjectionAnnotation added = additionsIterator.next(); if (deleted.isComment() == added.isComment()) { - Position addedPosition= additions.get(added); - + Position addedPosition = additions.get(added); + if (deletedPosition.getOffset() == addedPosition.getOffset()) { - + deletedPosition.setLength(addedPosition.getLength()); deleted.setElement(added.getElement()); - + deletionIterator.remove(); newChanges.add(deleted); - + additionsIterator.remove(); - + break; } } } } - + deletions.addAll(newDeletions); changes.addAll(newChanges); } private Map<IDirective, List<MakefileProjectionAnnotation>> createAnnotationMap(IAnnotationModel model) { - Map<IDirective, List<MakefileProjectionAnnotation>> map= new HashMap<>(); + Map<IDirective, List<MakefileProjectionAnnotation>> map = new HashMap<>(); Iterator<Annotation> e = model.getAnnotationIterator(); while (e.hasNext()) { Annotation annotation = e.next(); if (annotation instanceof MakefileProjectionAnnotation) { - MakefileProjectionAnnotation directive= (MakefileProjectionAnnotation) annotation; - List<MakefileProjectionAnnotation> list= map.get(directive.getElement()); + MakefileProjectionAnnotation directive = (MakefileProjectionAnnotation) annotation; + List<MakefileProjectionAnnotation> list = map.get(directive.getElement()); if (list == null) { - list= new ArrayList<>(2); + list = new ArrayList<>(2); map.put(directive.getElement(), list); } list.add(directive); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ResourceMarkerAnnotationModel.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ResourceMarkerAnnotationModel.java index a4cb072b0a3..da2c1e4e817 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ResourceMarkerAnnotationModel.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/ResourceMarkerAnnotationModel.java @@ -46,9 +46,9 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel class ResourceChangeListener implements IResourceChangeListener { @Override public void resourceChanged(IResourceChangeEvent e) { - IResourceDelta delta= e.getDelta(); + IResourceDelta delta = e.getDelta(); if (delta != null && fResource != null) { - IResourceDelta child= delta.findMember(fResource.getFullPath()); + IResourceDelta child = delta.findMember(fResource.getFullPath()); if (child != null) update(child.getMarkerDeltas()); } @@ -60,8 +60,7 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel /** The resource. */ private IResource fResource; /** The resource change listener. */ - private IResourceChangeListener fResourceChangeListener= new ResourceChangeListener(); - + private IResourceChangeListener fResourceChangeListener = new ResourceChangeListener(); /** * Creates a marker annotation model with the given resource as the source @@ -71,8 +70,8 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel */ public ResourceMarkerAnnotationModel(IResource resource) { Assert.isNotNull(resource); - fResource= resource; - fWorkspace= resource.getWorkspace(); + fResource = resource; + fWorkspace = resource.getWorkspace(); } @Override @@ -87,21 +86,21 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel */ protected void update(IMarkerDelta[] markerDeltas) { - if (markerDeltas.length == 0) + if (markerDeltas.length == 0) return; if (markerDeltas.length == 1) { - IMarkerDelta delta= markerDeltas[0]; + IMarkerDelta delta = markerDeltas[0]; switch (delta.getKind()) { - case IResourceDelta.ADDED : - addMarkerAnnotation(delta.getMarker()); - break; - case IResourceDelta.REMOVED : - removeMarkerAnnotation(delta.getMarker()); - break; - case IResourceDelta.CHANGED : - modifyMarkerAnnotation(delta.getMarker()); - break; + case IResourceDelta.ADDED: + addMarkerAnnotation(delta.getMarker()); + break; + case IResourceDelta.REMOVED: + removeMarkerAnnotation(delta.getMarker()); + break; + case IResourceDelta.CHANGED: + modifyMarkerAnnotation(delta.getMarker()); + break; } } else batchedUpdate(markerDeltas); @@ -115,39 +114,39 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel * @param markerDeltas the array of marker deltas */ private void batchedUpdate(IMarkerDelta[] markerDeltas) { - HashSet<IMarker> removedMarkers= new HashSet<>(markerDeltas.length); - HashSet<IMarker> modifiedMarkers= new HashSet<>(markerDeltas.length); + HashSet<IMarker> removedMarkers = new HashSet<>(markerDeltas.length); + HashSet<IMarker> modifiedMarkers = new HashSet<>(markerDeltas.length); - for (int i= 0; i < markerDeltas.length; i++) { - IMarkerDelta delta= markerDeltas[i]; + for (int i = 0; i < markerDeltas.length; i++) { + IMarkerDelta delta = markerDeltas[i]; switch (delta.getKind()) { - case IResourceDelta.ADDED: - addMarkerAnnotation(delta.getMarker()); - break; - case IResourceDelta.REMOVED: - removedMarkers.add(delta.getMarker()); - break; - case IResourceDelta.CHANGED: - modifiedMarkers.add(delta.getMarker()); - break; - } + case IResourceDelta.ADDED: + addMarkerAnnotation(delta.getMarker()); + break; + case IResourceDelta.REMOVED: + removedMarkers.add(delta.getMarker()); + break; + case IResourceDelta.CHANGED: + modifiedMarkers.add(delta.getMarker()); + break; + } } if (modifiedMarkers.isEmpty() && removedMarkers.isEmpty()) return; - Iterator<?> e= getAnnotationIterator(false); + Iterator<?> e = getAnnotationIterator(false); while (e.hasNext()) { - Object o= e.next(); + Object o = e.next(); if (o instanceof MarkerAnnotation) { - MarkerAnnotation a= (MarkerAnnotation)o; - IMarker marker= a.getMarker(); + MarkerAnnotation a = (MarkerAnnotation) o; + IMarker marker = a.getMarker(); if (removedMarkers.remove(marker)) removeAnnotation(a, false); if (modifiedMarkers.remove(marker)) { - Position p= createPositionFromMarker(marker); + Position p = createPositionFromMarker(marker); if (p != null) { a.update(); modifyAnnotationPosition(a, p, false); @@ -160,7 +159,7 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel } } - Iterator<IMarker> iter= modifiedMarkers.iterator(); + Iterator<IMarker> iter = modifiedMarkers.iterator(); while (iter.hasNext()) addMarkerAnnotation(iter.next()); } @@ -176,7 +175,7 @@ public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel @Override protected void deleteMarkers(final IMarker[] markers) throws CoreException { fWorkspace.run((IWorkspaceRunnable) monitor -> { - for (int i= 0; i < markers.length; ++i) { + for (int i = 0; i < markers.length; ++i) { markers[i].delete(); } }, null, IWorkspace.AVOID_UPDATE, null); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Rule.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Rule.java index 940ce565713..7cfb640b4be 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Rule.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Rule.java @@ -58,10 +58,10 @@ public abstract class Rule extends Parent implements IRule { @Override public boolean equals(Object r) { if (r instanceof Rule) - return ((Rule)r).getTarget().equals(getTarget()); + return ((Rule) r).getTarget().equals(getTarget()); return false; } - + @Override public int hashCode() { return getTarget().hashCode(); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/SelectionList.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/SelectionList.java index 395e687a4a2..12d741d28c9 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/SelectionList.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/SelectionList.java @@ -42,70 +42,76 @@ public class SelectionList extends Composite { private Object[] fElements; protected ILabelProvider fRenderer; private boolean fIgnoreCase; - + // Implementation details private String[] fRenderedStrings; - private int[] fFilteredElements; + private int[] fFilteredElements; private String fRememberedMatchText; // SWT widgets private Table fList; private Text fText; - + /** * Adds a selection change listener to this widget. */ public void addSelectionListener(SelectionListener listener) { fList.addSelectionListener(listener); } + private void createList(int style) { - fList= new Table(this, style); + fList = new Table(this, style); fList.setLayoutData(new GridData(GridData.FILL_BOTH)); fList.addDisposeListener(e -> fRenderer.dispose()); } + private void createText() { - fText= new Text(this, SWT.BORDER); - GridData spec= new GridData(); - spec.grabExcessVerticalSpace= false; - spec.grabExcessHorizontalSpace= true; - spec.horizontalAlignment= GridData.FILL; - spec.verticalAlignment= GridData.BEGINNING; + fText = new Text(this, SWT.BORDER); + GridData spec = new GridData(); + spec.grabExcessVerticalSpace = false; + spec.grabExcessHorizontalSpace = true; + spec.horizontalAlignment = GridData.FILL; + spec.verticalAlignment = GridData.BEGINNING; fText.setLayoutData(spec); Listener l = evt -> filter(false); fText.addListener(SWT.Modify, l); } + /** * Filters the list of elements according to the pattern entered * into the text entry field. */ public void filter(boolean forceUpdate) { - int k= 0; - String text= fText.getText(); + int k = 0; + String text = fText.getText(); if (!forceUpdate && text.equals(fRememberedMatchText)) return; - fRememberedMatchText= text; - StringMatcher matcher= new StringMatcher(text+"*", fIgnoreCase, false); //$NON-NLS-1$ - for (int i= 0; i < fElements.length; i++) { + fRememberedMatchText = text; + StringMatcher matcher = new StringMatcher(text + "*", fIgnoreCase, false); //$NON-NLS-1$ + for (int i = 0; i < fElements.length; i++) { if (matcher.match(fRenderedStrings[i])) { - fFilteredElements[k]= i; + fFilteredElements[k] = i; k++; } } - fFilteredElements[k]= -1; + fFilteredElements[k] = -1; updateListWidget(fFilteredElements, k); } + /** * Returns the currently used filter text. */ public String getFilter() { return fText.getText(); } + /** * Returns the selection indices. */ public int[] getSelectionIndices() { return fList.getSelectionIndices(); } + /** * Returns a list of selected elements. Note that the type of the elements * returned in the list are the same as the ones passed to the selection list @@ -114,73 +120,82 @@ public class SelectionList extends Composite { public List<Object> getSelection() { if (fList == null || fList.isDisposed() || fList.getSelectionCount() == 0) return new ArrayList<>(0); - int[] listSelection= fList.getSelectionIndices(); - List<Object> selected= new ArrayList<>(listSelection.length); - for (int i= 0; i < listSelection.length; i++) { + int[] listSelection = fList.getSelectionIndices(); + List<Object> selected = new ArrayList<>(listSelection.length); + for (int i = 0; i < listSelection.length; i++) { selected.add(fElements[fFilteredElements[listSelection[i]]]); } return selected; } + /** * Returns <code>true</code> when the list of elements is empty. */ public boolean isEmptyList() { return fElements == null || fElements.length == 0; } + /** * Creates new instance of the widget. */ public SelectionList(Composite parent, int style, ILabelProvider renderer, boolean ignoreCase) { super(parent, SWT.NONE); - fRenderer= renderer; - fIgnoreCase= ignoreCase; - GridLayout layout= new GridLayout(); - layout.marginHeight= 0; layout.marginWidth= 0; + fRenderer = renderer; + fIgnoreCase = ignoreCase; + GridLayout layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; //XXX: 1G9V58A: ITPUI:WIN2000 - Dialog.convert* methods should be static setLayout(layout); createText(); createList(style); } + /** * Removes a selection change listener to this widget. */ public void removeSelectionListener(SelectionListener listener) { fList.removeSelectionListener(listener); } + private String[] renderStrings() { - String[] strings= new String[fElements.length]; - for (int i= 0; i < strings.length; i++) { - strings[i]= fRenderer.getText(fElements[i]); + String[] strings = new String[fElements.length]; + for (int i = 0; i < strings.length; i++) { + strings[i] = fRenderer.getText(fElements[i]); } TwoArrayQuickSort.sort(strings, fElements, fIgnoreCase); return strings; } + /** * Select the pattern text. */ public void selectFilterText() { fText.selectAll(); } + /** * Sets the list of elements presented in the widget. */ public void setElements(List<Object> elements, boolean refilter) { // We copy the list since we sort it. if (elements == null) - fElements= new Object[0]; - else - fElements= elements.toArray(); - fFilteredElements= new int[fElements.length+1]; - fRenderedStrings= renderStrings(); + fElements = new Object[0]; + else + fElements = elements.toArray(); + fFilteredElements = new int[fElements.length + 1]; + fRenderedStrings = renderStrings(); if (refilter) - filter(true); + filter(true); } + @Override public void setEnabled(boolean enable) { super.setEnabled(enable); fText.setEnabled(enable); fList.setEnabled(enable); } + /** * Sets the filter pattern. Current only prefix filter pattern are supported. */ @@ -189,16 +204,19 @@ public class SelectionList extends Composite { if (refilter) filter(true); } + @Override public boolean setFocus() { return fText.setFocus(); } + @Override public void setFont(Font font) { super.setFont(font); fText.setFont(font); fList.setFont(font); } + /** * Selects the elements in the list determined by the given * selection indices. @@ -206,34 +224,35 @@ public class SelectionList extends Composite { protected void setSelection(int[] selection) { fList.setSelection(selection); } + private void updateListWidget(int[] indices, int size) { if (fList == null || fList.isDisposed()) return; fList.setRedraw(false); - int itemCount= fList.getItemCount(); + int itemCount = fList.getItemCount(); if (size < itemCount) { - fList.remove(0, itemCount-size-1); + fList.remove(0, itemCount - size - 1); } - TableItem[] items= fList.getItems(); - for (int i= 0; i < size; i++) { - TableItem ti= null; + TableItem[] items = fList.getItems(); + for (int i = 0; i < size; i++) { + TableItem ti = null; if (i < itemCount) { - ti= items[i]; + ti = items[i]; } else { - ti= new TableItem(fList, i); + ti = new TableItem(fList, i); } ti.setText(fRenderedStrings[indices[i]]); - Image img= fRenderer.getImage(fElements[indices[i]]); + Image img = fRenderer.getImage(fElements[indices[i]]); if (img != null) ti.setImage(img); } if (fList.getItemCount() > 0) { fList.setSelection(0); } - + fList.setRedraw(true); - Event event= new Event(); + Event event = new Event(); fList.notifyListeners(SWT.Selection, event); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/SelectionStatusDialog.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/SelectionStatusDialog.java index a2f18dd0e6a..abc4f9452d9 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/SelectionStatusDialog.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/SelectionStatusDialog.java @@ -33,40 +33,42 @@ import org.eclipse.ui.dialogs.SelectionDialog; * The status message must be passed over as StatusInfo object and can be * an error, warning or ok. The OK button is enabled / disabled depending * on the status. - */ + */ public abstract class SelectionStatusDialog extends SelectionDialog { - + private MessageLine fStatusLine; private IStatus fLastStatus; private Image fImage; private boolean fInitialSelectionSet; - private boolean fStatusLineAboveButtons= false; - - + private boolean fStatusLineAboveButtons = false; + /** * Compute the result and return it. */ protected abstract void computeResult(); + @Override protected void configureShell(Shell shell) { super.configureShell(shell); if (fImage != null) shell.setImage(fImage); } + @Override protected Control createButtonBar(Composite parent) { - Composite composite= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); + Composite composite = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); if (fStatusLineAboveButtons) { - layout.verticalSpacing= 0; + layout.verticalSpacing = 0; } else { - layout.numColumns= 2; + layout.numColumns = 2; } - layout.marginHeight= 0; layout.marginWidth= 0; + layout.marginHeight = 0; + layout.marginWidth = 0; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - fStatusLine= new MessageLine(composite); + + fStatusLine = new MessageLine(composite); fStatusLine.setAlignment(SWT.LEFT); fStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fStatusLine.setMessage(""); //$NON-NLS-1$ @@ -74,6 +76,7 @@ public abstract class SelectionStatusDialog extends SelectionDialog { super.createButtonBar(composite); return composite; } + @Override public void create() { super.create(); @@ -81,6 +84,7 @@ public abstract class SelectionStatusDialog extends SelectionDialog { updateStatus(fLastStatus); } } + /** * Returns the first element of the initial selection or <code>null<code> * if there isn't any initial selection. @@ -90,8 +94,9 @@ public abstract class SelectionStatusDialog extends SelectionDialog { List<?> result = getInitialElementSelections(); if (result == null || result.size() == 0) return null; - return result.get(0); + return result.get(0); } + /** * Returns the first element from the list of results. Returns <code>null</code> * if no element has been selected. @@ -100,35 +105,39 @@ public abstract class SelectionStatusDialog extends SelectionDialog { * returned. */ public Object getPrimaryResult() { - Object[] result= getResult(); + Object[] result = getResult(); if (result == null || result.length == 0) return null; - return result[0]; + return result[0]; } + public SelectionStatusDialog(Shell parent) { super(parent); - fInitialSelectionSet= false; + fInitialSelectionSet = false; } + @Override protected void okPressed() { computeResult(); super.okPressed(); } + /** * Sets the image for this dialog. * * @param image the dialog's image */ public void setImage(Image image) { - fImage= image; + fImage = image; } @SuppressWarnings("unchecked") protected void setInitialSelection(int position, Object element) { List<Object> l = getInitialElementSelections(); l.set(position, element); - fInitialSelectionSet= true; + fInitialSelectionSet = true; } + /** * Sets the initial selection to the given element. */ @@ -143,19 +152,22 @@ public abstract class SelectionStatusDialog extends SelectionDialog { setInitialSelections(new Object[0]); } } + @Override public void setInitialSelections(Object[] selectedElements) { super.setInitialSelections(selectedElements); - fInitialSelectionSet= true; + fInitialSelectionSet = true; } + /** * Sets a result element at the given position. */ protected void setResult(int position, Object element) { - Object[] result= getResult(); - result[position]= element; + Object[] result = getResult(); + result[position] = element; setResult(Arrays.asList(result)); } + /** * Controls whether status line appears to the left of the buttons (default) * or above them. @@ -164,26 +176,28 @@ public abstract class SelectionStatusDialog extends SelectionDialog { * <code>false</code> to the right */ public void setStatusLineAboveButtons(boolean aboveButtons) { - fStatusLineAboveButtons= aboveButtons; + fStatusLineAboveButtons = aboveButtons; } + /** * Update the status of the ok button to reflect the given status. Subclasses * may override this method to update additional buttons. */ protected void updateButtonsEnableState(IStatus status) { - Button okButton= getOkButton(); + Button okButton = getOkButton(); if (okButton != null && !okButton.isDisposed()) okButton.setEnabled(!status.matches(IStatus.ERROR)); } + /** * Update the dialog's status line to reflect the given status. It is safe to call * this method before the dialog has been opened. */ protected void updateStatus(IStatus status) { - fLastStatus= status; + fLastStatus = status; if (fStatusLine != null && !fStatusLine.isDisposed()) { - updateButtonsEnableState(status); - StatusTool.applyToStatusLine(fStatusLine, status); + updateButtonsEnableState(status); + StatusTool.applyToStatusLine(fStatusLine, status); } } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StaticTargetRule.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StaticTargetRule.java index e4c5e6fb3c1..9aa3b320ce9 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StaticTargetRule.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StaticTargetRule.java @@ -28,7 +28,8 @@ public class StaticTargetRule extends InferenceRule implements IInferenceRule { String targetPattern; String[] prereqPatterns; - public StaticTargetRule(Directive parent, Target target, String targetPattern, String[] prereqPatterns, Command[] commands) { + public StaticTargetRule(Directive parent, Target target, String targetPattern, String[] prereqPatterns, + Command[] commands) { super(parent, target, commands); this.targetPattern = targetPattern; this.prereqPatterns = prereqPatterns.clone(); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusInfo.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusInfo.java index 1d4f9f8d561..51f1bdc95e3 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusInfo.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusInfo.java @@ -23,8 +23,8 @@ import org.eclipse.core.runtime.IStatus; * a message describes the problem */ public class StatusInfo implements IStatus { - - public static final IStatus OK_STATUS= new StatusInfo(); + + public static final IStatus OK_STATUS = new StatusInfo(); private String fStatusMessage; private int fSeverity; @@ -41,76 +41,91 @@ public class StatusInfo implements IStatus { * @param severity The status severity: ERROR, WARNING, INFO and OK. * @param message The message of the status. Applies only for ERROR, * WARNING and INFO. - */ + */ public StatusInfo(int severity, String message) { - fStatusMessage= message; - fSeverity= severity; - } + fStatusMessage = message; + fSeverity = severity; + } @Override public IStatus[] getChildren() { return new IStatus[0]; } + @Override public int getCode() { return fSeverity; } + @Override public Throwable getException() { return null; } + @Override public String getMessage() { return fStatusMessage; } + @Override public String getPlugin() { return CUIPlugin.PLUGIN_ID; } + @Override public int getSeverity() { return fSeverity; } + public boolean isError() { return fSeverity == IStatus.ERROR; } + public boolean isInfo() { return fSeverity == IStatus.INFO; } + @Override public boolean isMultiStatus() { return false; } + @Override public boolean isOK() { return fSeverity == IStatus.OK; } + public boolean isWarning() { return fSeverity == IStatus.WARNING; } + @Override public boolean matches(int severityMask) { return (fSeverity & severityMask) != 0; } + public void setError(String errorMessage) { - fStatusMessage= errorMessage; - fSeverity= IStatus.ERROR; + fStatusMessage = errorMessage; + fSeverity = IStatus.ERROR; } + public void setInfo(String infoMessage) { - fStatusMessage= infoMessage; - fSeverity= IStatus.INFO; + fStatusMessage = infoMessage; + fSeverity = IStatus.INFO; } + public void setOK() { - fStatusMessage= null; - fSeverity= IStatus.OK; + fStatusMessage = null; + fSeverity = IStatus.OK; } + public void setWarning(String warningMessage) { - fStatusMessage= warningMessage; - fSeverity= IStatus.WARNING; + fStatusMessage = warningMessage; + fSeverity = IStatus.WARNING; } /** - * Returns a string representation of the status, suitable + * Returns a string representation of the status, suitable * for debugging purposes only. */ @Override diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusTool.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusTool.java index 27be912cbfd..677448a8b38 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusTool.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StatusTool.java @@ -22,23 +22,25 @@ public class StatusTool { * Applies the status to the status line of a dialog page */ public static void applyToStatusLine(MessageLine messageLine, IStatus status) { - String[] messages= getErrorMessages(status); + String[] messages = getErrorMessages(status); messageLine.setErrorMessage(messages[0]); messageLine.setMessage(messages[1]); } + /** * Applies the status to the status line of a dialog page */ public static void applyToStatusLine(DialogPage page, IStatus status) { - String[] messages= getErrorMessages(status); + String[] messages = getErrorMessages(status); page.setErrorMessage(messages[0]); page.setMessage(messages[1]); } + /** * Returns error-message / warning-message for a status */ public static String[] getErrorMessages(IStatus status) { - String message= status.getMessage(); + String message = status.getMessage(); if (status.matches(IStatus.ERROR) && !"".equals(message)) { //$NON-NLS-1$ return new String[] { message, null }; } else if (status.matches(IStatus.WARNING | IStatus.INFO)) { @@ -47,6 +49,7 @@ public class StatusTool { return new String[] { null, null }; } } + /** * Compare two IStatus. The more severe is returned: * An error is more severe than a warning, and a warning is more severe @@ -58,20 +61,21 @@ public class StatusTool { } return s2; } + /** * Finds the most severe status from a array of status * An error is more severe than a warning, and a warning is more severe * than ok. */ public static IStatus getMostSevere(IStatus[] status) { - IStatus max= null; - for (int i= 0; i < status.length; i++) { - IStatus curr= status[i]; + IStatus max = null; + for (int i = 0; i < status.length; i++) { + IStatus curr = status[i]; if (curr.matches(IStatus.ERROR)) { return curr; } if (max == null || curr.getSeverity() > max.getSeverity()) { - max= curr; + max = curr; } } return max; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StringMatcher.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StringMatcher.java index ba3a32d4d7a..749766412a5 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StringMatcher.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/StringMatcher.java @@ -27,33 +27,36 @@ public class StringMatcher { protected String fSegments[]; //the given pattern is split into * separated segments /* boundary value beyond which we don't need to search in the text */ - protected int fBound= 0; + protected int fBound = 0; - protected static final char fSingleWildCard= '\u0000'; + protected static final char fSingleWildCard = '\u0000'; public static class Position { int start; //inclusive int end; //exclusive + public Position(int start, int end) { - this.start= start; - this.end= end; + this.start = start; + this.end = end; } + public int getStart() { return start; } + public int getEnd() { return end; } } /** - * Find the first occurrence of the pattern between <code>start</code)(inclusive) - * and <code>end</code>(exclusive). - * @param text the String object to search in + * Find the first occurrence of the pattern between <code>start</code)(inclusive) + * and <code>end</code>(exclusive). + * @param text the String object to search in * @param start the starting index of the search range, inclusive * @param end the ending index of the search range, exclusive - * @return an <code>StringMatcher.Position</code> object that keeps the starting - * (inclusive) and ending positions (exclusive) of the first occurrence of the + * @return an <code>StringMatcher.Position</code> object that keeps the starting + * (inclusive) and ending positions (exclusive) of the first occurrence of the * pattern in the specified range of the text; return null if not found or subtext * is empty (start==end). A pair of zeros is returned if pattern is empty string * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc" @@ -64,41 +67,42 @@ public class StringMatcher { if (fPattern == null || text == null) throw new IllegalArgumentException(); - int tlen= text.length(); + int tlen = text.length(); if (start < 0) - start= 0; + start = 0; if (end > tlen) - end= tlen; + end = tlen; if (end < 0 || start >= end) return null; if (fLength == 0) return new Position(start, start); if (fIgnoreWildCards) { - int x= posIn(text, start, end); + int x = posIn(text, start, end); if (x < 0) return null; return new Position(x, x + fLength); } - int segCount= fSegments.length; + int segCount = fSegments.length; if (segCount == 0) //pattern contains only '*'(s) return new Position(start, end); - int curPos= start; - int matchStart= -1; - for (int i= 0; i < segCount && curPos < end; ++i) { - String current= fSegments[i]; - int nextMatch= regExpPosIn(text, curPos, end, current); + int curPos = start; + int matchStart = -1; + for (int i = 0; i < segCount && curPos < end; ++i) { + String current = fSegments[i]; + int nextMatch = regExpPosIn(text, curPos, end, current); if (nextMatch < 0) return null; if (i == 0) - matchStart= nextMatch; - curPos= nextMatch + current.length(); + matchStart = nextMatch; + curPos = nextMatch + current.length(); } return new Position(matchStart, curPos); } + /** - * StringMatcher constructor takes in a String object that is a simple + * StringMatcher constructor takes in a String object that is a simple * pattern which may contain * for 0 and many characters and * ? for exactly one character. Also takes as parameter a boolean object * specifying if case should be ignored @@ -108,15 +112,16 @@ public class StringMatcher { public StringMatcher(String aPattern, boolean ignoreCase) { this(aPattern, ignoreCase, false); } + /** - * StringMatcher constructor takes in a String object that is a simple + * StringMatcher constructor takes in a String object that is a simple * pattern which may contain * for 0 and many characters and - * ? for exactly one character. + * ? for exactly one character. * - * Literal '*' and '?' characters must be escaped in the pattern + * Literal '*' and '?' characters must be escaped in the pattern * e.g., "\*" means literal "*", etc. * - * Escaping any other character (including the escape character itself), + * Escaping any other character (including the escape character itself), * just results in that character in the pattern. * e.g., "\a" means "a" and "\\" means "\" * @@ -129,15 +134,15 @@ public class StringMatcher { * (everything is taken literally). */ public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards) { - fIgnoreCase= ignoreCase; - fIgnoreWildCards= ignoreWildCards; - fLength= aPattern.length(); + fIgnoreCase = ignoreCase; + fIgnoreWildCards = ignoreWildCards; + fLength = aPattern.length(); /* convert case */ if (fIgnoreCase) { - fPattern= aPattern.toUpperCase(); + fPattern = aPattern.toUpperCase(); } else { - fPattern= aPattern; + fPattern = aPattern; } if (fIgnoreWildCards) { @@ -146,13 +151,14 @@ public class StringMatcher { parseWildCards(); } } + /** - * Given the starting (inclusive) and the ending (exclusive) poisitions in the - * <code>text</code>, determine if the given substring matches with aPattern + * Given the starting (inclusive) and the ending (exclusive) poisitions in the + * <code>text</code>, determine if the given substring matches with aPattern * @return true if the specified portion of the text matches the pattern - * @param text a String object that contains the substring to match + * @param text a String object that contains the substring to match * @param start marks the starting position (inclusive) of the substring - * @param end marks the ending index (exclusive) of the substring + * @param end marks the ending index (exclusive) of the substring */ public boolean match(String text, int start, int end) { if (null == fPattern || null == text) @@ -163,7 +169,7 @@ public class StringMatcher { if (fIgnoreWildCards) return fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength); - int segCount= fSegments.length; + int segCount = fSegments.length; if (segCount == 0) //pattern contains only '*'(s) or empty pattern return true; if (start == end) @@ -171,19 +177,19 @@ public class StringMatcher { if (fLength == 0) return start == end; - int tlen= text.length(); + int tlen = text.length(); if (start < 0) - start= 0; + start = 0; if (end > tlen) - end= tlen; + end = tlen; - int tCurPos= start; - int bound= end - fBound; + int tCurPos = start; + int bound = end - fBound; if (bound < 0) return false; - int i= 0; - String current= fSegments[i]; - int segLength= current.length(); + int i = 0; + String current = fSegments[i]; + int segLength = current.length(); /* process first segment */ if (!fHasLeadingStar) { @@ -191,99 +197,102 @@ public class StringMatcher { return false; } ++i; - tCurPos= tCurPos + segLength; + tCurPos = tCurPos + segLength; } /* process middle segments */ for (; i < segCount && tCurPos <= bound; ++i) { - current= fSegments[i]; + current = fSegments[i]; int currentMatch; - int k= current.indexOf(fSingleWildCard); + int k = current.indexOf(fSingleWildCard); if (k < 0) { - currentMatch= textPosIn(text, tCurPos, end, current); + currentMatch = textPosIn(text, tCurPos, end, current); if (currentMatch < 0) return false; } else { - currentMatch= regExpPosIn(text, tCurPos, end, current); + currentMatch = regExpPosIn(text, tCurPos, end, current); if (currentMatch < 0) return false; } - tCurPos= currentMatch + current.length(); + tCurPos = currentMatch + current.length(); } /* process final segment */ if (!fHasTrailingStar && tCurPos != end) { - int clen= current.length(); + int clen = current.length(); return regExpRegionMatches(text, end - clen, current, 0, clen); } return i == segCount; } + /** - * match the given <code>text</code> with the pattern + * match the given <code>text</code> with the pattern * @return true if matched eitherwise false - * @param text a String object + * @param text a String object */ public boolean match(String text) { return match(text, 0, text.length()); } + /** * This method parses the given pattern into segments seperated by wildcard '*' characters. * Since wildcards are not being used in this case, the pattern consists of a single segment. */ private void parseNoWildCards() { - fSegments= new String[1]; - fSegments[0]= fPattern; - fBound= fLength; + fSegments = new String[1]; + fSegments[0] = fPattern; + fBound = fLength; } + /** * This method parses the given pattern into segments seperated by wildcard '*' characters. */ private void parseWildCards() { if (fPattern.startsWith("*")) //$NON-NLS-1$ - fHasLeadingStar= true; + fHasLeadingStar = true; if (fPattern.endsWith("*")) { //$NON-NLS-1$ /* make sure it's not an escaped wildcard */ if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') { - fHasTrailingStar= true; + fHasTrailingStar = true; } } Vector<String> temp = new Vector<>(); - int pos= 0; - StringBuilder buf= new StringBuilder(); + int pos = 0; + StringBuilder buf = new StringBuilder(); while (pos < fLength) { - char c= fPattern.charAt(pos++); + char c = fPattern.charAt(pos++); switch (c) { - case '\\' : - if (pos >= fLength) { - buf.append(c); + case '\\': + if (pos >= fLength) { + buf.append(c); + } else { + char next = fPattern.charAt(pos++); + /* if it's an escape sequence */ + if (next == '*' || next == '?' || next == '\\') { + buf.append(next); } else { - char next= fPattern.charAt(pos++); - /* if it's an escape sequence */ - if (next == '*' || next == '?' || next == '\\') { - buf.append(next); - } else { - /* not an escape sequence, just insert literally */ - buf.append(c); - buf.append(next); - } - } - break; - case '*' : - if (buf.length() > 0) { - /* new segment */ - temp.addElement(buf.toString()); - fBound += buf.length(); - buf.setLength(0); + /* not an escape sequence, just insert literally */ + buf.append(c); + buf.append(next); } - break; - case '?' : - /* append special character representing single match wildcard */ - buf.append(fSingleWildCard); - break; - default : - buf.append(c); + } + break; + case '*': + if (buf.length() > 0) { + /* new segment */ + temp.addElement(buf.toString()); + fBound += buf.length(); + buf.setLength(0); + } + break; + case '?': + /* append special character representing single match wildcard */ + buf.append(fSingleWildCard); + break; + default: + buf.append(c); } } @@ -293,44 +302,46 @@ public class StringMatcher { fBound += buf.length(); } - fSegments= new String[temp.size()]; + fSegments = new String[temp.size()]; temp.copyInto(fSegments); } - /** + + /** * @param text a string which contains no wildcard * @param start the starting index in the text for search, inclusive * @param end the stopping point of search, exclusive - * @return the starting index in the text of the pattern , or -1 if not found + * @return the starting index in the text of the pattern , or -1 if not found */ protected int posIn(String text, int start, int end) { //no wild card in pattern - int max= end - fLength; + int max = end - fLength; if (!fIgnoreCase) { - int i= text.indexOf(fPattern, start); + int i = text.indexOf(fPattern, start); if (i == -1 || i > max) return -1; return i; } - for (int i= start; i <= max; ++i) { + for (int i = start; i <= max; ++i) { if (text.regionMatches(true, i, fPattern, 0, fLength)) return i; } return -1; } - /** + + /** * @param text a simple regular expression that may only contain '?'(s) * @param start the starting index in the text for search, inclusive * @param end the stopping point of search, exclusive * @param p a simple regular expression that may contains '?' - * @return the starting index in the text of the pattern , or -1 if not found + * @return the starting index in the text of the pattern , or -1 if not found */ protected int regExpPosIn(String text, int start, int end, String p) { - int plen= p.length(); + int plen = p.length(); - int max= end - plen; - for (int i= start; i <= max; ++i) { + int max = end - plen; + for (int i = start; i <= max; ++i) { if (regExpRegionMatches(text, i, p, 0, plen)) return i; } @@ -339,8 +350,8 @@ public class StringMatcher { protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) { while (plen-- > 0) { - char tchar= text.charAt(tStart++); - char pchar= p.charAt(pStart++); + char tchar = text.charAt(tStart++); + char pchar = p.charAt(pStart++); /* process wild cards */ if (!fIgnoreWildCards) { @@ -352,7 +363,7 @@ public class StringMatcher { if (pchar == tchar) continue; if (fIgnoreCase) { - char tc= Character.toUpperCase(tchar); + char tc = Character.toUpperCase(tchar); if (tc == pchar) continue; } @@ -360,26 +371,27 @@ public class StringMatcher { } return true; } - /** + + /** * @param text the string to match * @param start the starting index in the text for search, inclusive * @param end the stopping point of search, exclusive * @param p a string that has no wildcard - * @return the starting index in the text of the pattern , or -1 if not found + * @return the starting index in the text of the pattern , or -1 if not found */ protected int textPosIn(String text, int start, int end, String p) { - int plen= p.length(); - int max= end - plen; + int plen = p.length(); + int max = end - plen; if (!fIgnoreCase) { - int i= text.indexOf(p, start); + int i = text.indexOf(p, start); if (i == -1 || i > max) return -1; return i; } - for (int i= 0; i <= max; ++i) { + for (int i = 0; i <= max; ++i) { if (text.regionMatches(true, i, p, 0, plen)) return i; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TargetRule.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TargetRule.java index 124ab78ea18..b1e6b5f4702 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TargetRule.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TargetRule.java @@ -21,15 +21,15 @@ import org.eclipse.cdt.make.core.makefile.ITargetRule; * statement : rule | macro_definition | comments | empty * rule : inference_rule | target_rule * inference_rule : target ':' <nl> ( <tab> command <nl> ) + - * target_rule : target [ ( target ) * ] ':' [ ( prerequisite ) * ] [ ';' command ] <nl> + * target_rule : target [ ( target ) * ] ':' [ ( prerequisite ) * ] [ ';' command ] <nl> [ ( <tab> prefix_command command ) * ] - * macro_definition : string '=' (string)* + * macro_definition : string '=' (string)* * comments : '#' (string) * * empty : <nl> * command : string <nl> * target : string * prefix_command : '-' | '@' | '+' - * internal_macro : "$<" | "$*" | "$@" | "$?" | "$%" + * internal_macro : "$<" | "$*" | "$@" | "$?" | "$%" */ public class TargetRule extends Rule implements ITargetRule { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TargetVariable.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TargetVariable.java index aaae510e109..21ab48eb3c8 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TargetVariable.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TargetVariable.java @@ -24,7 +24,8 @@ public class TargetVariable extends GNUVariableDef { boolean override; - public TargetVariable(Directive parent, String target, String name, StringBuffer value, boolean override, int type) { + public TargetVariable(Directive parent, String target, String name, StringBuffer value, boolean override, + int type) { super(parent, target, name, value, type); this.override = override; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TwoArrayQuickSort.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TwoArrayQuickSort.java index dbec276fc01..719ab5f9d99 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TwoArrayQuickSort.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/TwoArrayQuickSort.java @@ -16,59 +16,60 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; import org.eclipse.core.runtime.Assert; - /** * Quick sort to sort two arrays in parallel. */ public class TwoArrayQuickSort { - private static void internalSort(String[] keys, Object[] values, int left, int right, boolean ignoreCase) { - - int originalLeft= left; - int originalRight= right; - - String mid= keys[(left + right) >>> 1]; - do { - while (smaller(keys[left], mid, ignoreCase)) { - left++; - } - while (smaller(mid, keys[right], ignoreCase)) { - right--; - } - if (left <= right) { - String tmp= keys[left]; - keys[left]= keys[right]; - keys[right]= tmp; - - Object tmp2= values[left]; - values[left]= values[right]; - values[right]= tmp2; - - left++; - right--; - } + private static void internalSort(String[] keys, Object[] values, int left, int right, boolean ignoreCase) { + + int originalLeft = left; + int originalRight = right; + + String mid = keys[(left + right) >>> 1]; + do { + while (smaller(keys[left], mid, ignoreCase)) { + left++; + } + while (smaller(mid, keys[right], ignoreCase)) { + right--; + } + if (left <= right) { + String tmp = keys[left]; + keys[left] = keys[right]; + keys[right] = tmp; + + Object tmp2 = values[left]; + values[left] = values[right]; + values[right] = tmp2; + + left++; + right--; + } } while (left <= right); - + if (originalLeft < right) { - internalSort(keys , values, originalLeft, right, ignoreCase); - } + internalSort(keys, values, originalLeft, right, ignoreCase); + } if (left < originalRight) { - internalSort(keys, values, left, originalRight, ignoreCase); - } + internalSort(keys, values, left, originalRight, ignoreCase); + } } + private static boolean smaller(String left, String right, boolean ignoreCase) { if (ignoreCase) return left.compareToIgnoreCase(right) < 0; - return left.compareTo(right) < 0; + return left.compareTo(right) < 0; } + /** * Sorts keys and values in parallel. */ - public static void sort(String[] keys, Object[] values, boolean ignoreCase) { + public static void sort(String[] keys, Object[] values, boolean ignoreCase) { if (keys != null && values != null) { Assert.isTrue(keys.length == values.length); if (keys.length > 1) - internalSort(keys, values, 0, keys.length - 1, ignoreCase); + internalSort(keys, values, 0, keys.length - 1, ignoreCase); } else { if (keys != null || values != null) Assert.isTrue(false, "Either keys or values in null"); //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Util.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Util.java index 3df8aacefe2..e97fcfae7a4 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Util.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/Util.java @@ -41,7 +41,7 @@ public class Util { } public static boolean isSpace(char c) { - return (c == ' ' || c == '\t' || c == '\r' || c == '\n'); + return (c == ' ' || c == '\t' || c == '\r' || c == '\n'); } public static int indexOf(String line, char c) { @@ -61,7 +61,7 @@ public class Util { char ch = line.charAt(i); if (ch == '(' && prev == '$' && pprev != '\\') { paren++; - } else if (ch == '{' && prev == '$' && pprev != '\\') { + } else if (ch == '{' && prev == '$' && pprev != '\\') { bracket++; } else if (ch == ')' && prev != '\\') { if (paren > 0) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/VariableDefinition.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/VariableDefinition.java index c5d5036c5b1..3da36aaf781 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/VariableDefinition.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/VariableDefinition.java @@ -17,7 +17,7 @@ import org.eclipse.cdt.make.core.makefile.gnu.IVariableDefinition; /** */ -public class VariableDefinition extends MacroDefinition implements IVariableDefinition { +public class VariableDefinition extends MacroDefinition implements IVariableDefinition { /** * ? is Conditional @@ -37,7 +37,7 @@ public class VariableDefinition extends MacroDefinition implements IVariableDefi } public VariableDefinition(Directive parent, String name, StringBuffer value, int type) { - this(parent, "", name, value, type); //$NON-NLS-1$ + this(parent, "", name, value, type); //$NON-NLS-1$ } public VariableDefinition(Directive parent, String target, String name, StringBuffer value, int type) { @@ -91,12 +91,12 @@ public class VariableDefinition extends MacroDefinition implements IVariableDefi public boolean isSimplyExpanded() { return type == TYPE_SIMPLE_EXPAND; } - + @Override public boolean isConditional() { return type == TYPE_CONDITIONAL; } - + @Override public boolean isAppend() { return type == TYPE_APPEND; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/WordPartDetector.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/WordPartDetector.java index fafa1bde367..e9d8004d2a6 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/WordPartDetector.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/WordPartDetector.java @@ -18,9 +18,9 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; - + /** - * Used to scan and detect for SQL keywords + * Used to scan and detect for SQL keywords */ public class WordPartDetector { String wordPart = ""; //$NON-NLS-1$ @@ -28,7 +28,7 @@ public class WordPartDetector { /** * WordPartDetector. - * @param viewer is a text viewer + * @param viewer is a text viewer * @param documentOffset into the SQL document */ public WordPartDetector(ITextViewer viewer, int documentOffset) { @@ -36,13 +36,13 @@ public class WordPartDetector { } /** - * + * * @param doc * @param documentOffset */ public WordPartDetector(IDocument doc, int documentOffset) { offset = documentOffset - 1; - int endOffset = documentOffset; + int endOffset = documentOffset; try { IRegion region = doc.getLineInformationOfOffset(documentOffset); int top = region.getOffset(); @@ -51,8 +51,8 @@ public class WordPartDetector { offset--; } while (endOffset < bottom && isMakefileLetter(doc.getChar(endOffset))) { - endOffset++; - } + endOffset++; + } //we've been one step too far : increase the offset offset++; wordPart = doc.get(offset, endOffset - offset); @@ -64,7 +64,7 @@ public class WordPartDetector { public static boolean inMacro(ITextViewer viewer, int offset) { return inMacro(viewer.getDocument(), offset); } - + public static boolean inMacro(IDocument document, int offset) { boolean isMacro = false; // Try to figure out if we are in a Macro. @@ -84,12 +84,11 @@ public class WordPartDetector { return isMacro; } - @Override public String toString() { return wordPart; } - + public int getOffset() { return offset; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/WorkingCopyManager.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/WorkingCopyManager.java index b1929168a46..ea29dff6a28 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/WorkingCopyManager.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/editors/automake/WorkingCopyManager.java @@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.autotools.ui.editors.automake; - import java.util.HashMap; import java.util.Map; @@ -25,13 +24,12 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.ui.IEditorInput; - /** * This working copy manager works together with a given compilation unit document provider and * additionally offers to "overwrite" the working copy provided by this document provider. */ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyManagerExtension { - + private IMakefileDocumentProvider fDocumentProvider; private Map<IEditorInput, IMakefile> fMap; private boolean fIsShuttingDown; @@ -39,59 +37,59 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana /** * Creates a new working copy manager that co-operates with the given * compilation unit document provider. - * + * * @param provider the provider */ public WorkingCopyManager(IMakefileDocumentProvider provider) { Assert.isNotNull(provider); - fDocumentProvider= provider; + fDocumentProvider = provider; } @Override public void connect(IEditorInput input) throws CoreException { fDocumentProvider.connect(input); } - + @Override public void disconnect(IEditorInput input) { fDocumentProvider.disconnect(input); } - + @Override public void shutdown() { if (!fIsShuttingDown) { - fIsShuttingDown= true; + fIsShuttingDown = true; try { if (fMap != null) { fMap.clear(); - fMap= null; + fMap = null; } fDocumentProvider.shutdown(); } finally { - fIsShuttingDown= false; + fIsShuttingDown = false; } } } @Override public IMakefile getWorkingCopy(IEditorInput input) { - IMakefile unit= fMap == null ? null : (IMakefile) fMap.get(input); + IMakefile unit = fMap == null ? null : (IMakefile) fMap.get(input); return unit != null ? unit : fDocumentProvider.getWorkingCopy(input); } - + @Override public void setWorkingCopy(IEditorInput input, IMakefile workingCopy) { if (fDocumentProvider.getDocument(input) != null) { if (fMap == null) - fMap= new HashMap<>(); + fMap = new HashMap<>(); fMap.put(input, workingCopy); } } - + @Override public void removeWorkingCopy(IEditorInput input) { fMap.remove(input); if (fMap.isEmpty()) - fMap= null; + fMap = null; } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AbstractEditorPreferencePage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AbstractEditorPreferencePage.java index 7ff2d863cdd..4ed3f92a270 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AbstractEditorPreferencePage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AbstractEditorPreferencePage.java @@ -46,64 +46,64 @@ import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.osgi.service.prefs.BackingStoreException; - /** * AbstraceMakeEditorPreferencePage */ public abstract class AbstractEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { OverlayPreferenceStore fOverlayStore; - - Map<Button, String> fCheckBoxes= new HashMap<>(); - private SelectionListener fCheckBoxListener= new SelectionListener() { + + Map<Button, String> fCheckBoxes = new HashMap<>(); + private SelectionListener fCheckBoxListener = new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { } + @Override public void widgetSelected(SelectionEvent e) { - Button button= (Button) e.widget; + Button button = (Button) e.widget; fOverlayStore.setValue(fCheckBoxes.get(button), button.getSelection()); } }; - - Map<Text, String> fTextFields= new HashMap<>(); + + Map<Text, String> fTextFields = new HashMap<>(); private ModifyListener fTextFieldListener = e -> { Text text = (Text) e.widget; fOverlayStore.setValue(fTextFields.get(text), text.getText()); }; - private Map<Text, Object> fNumberFields= new HashMap<>(); + private Map<Text, Object> fNumberFields = new HashMap<>(); private ModifyListener fNumberFieldListener = e -> numberFieldChanged((Text) e.widget); - + public AbstractEditorPreferencePage() { super(); setPreferenceStore(AutotoolsPlugin.getDefault().getPreferenceStore()); - fOverlayStore= createOverlayStore(); + fOverlayStore = createOverlayStore(); } - + protected abstract OverlayPreferenceStore createOverlayStore(); - + @Override public void init(IWorkbench workbench) { } - + protected void initializeFields() { - Map<Button, String> checkBoxes= getCheckBoxes(); - Map<Text, String> textFields= getTextFields(); - Iterator<Button> e= checkBoxes.keySet().iterator(); + Map<Button, String> checkBoxes = getCheckBoxes(); + Map<Text, String> textFields = getTextFields(); + Iterator<Button> e = checkBoxes.keySet().iterator(); while (e.hasNext()) { - Button b= e.next(); - String key= checkBoxes.get(b); + Button b = e.next(); + String key = checkBoxes.get(b); b.setSelection(getOverlayStore().getBoolean(key)); } - + Iterator<Text> e2 = textFields.keySet().iterator(); while (e.hasNext()) { - Text t= e2.next(); - String key= textFields.get(t); + Text t = e2.next(); + String key = textFields.get(t); t.setText(getOverlayStore().getString(key)); - } + } } - + @Override public boolean performOk() { getOverlayStore().propagate(); @@ -116,27 +116,27 @@ public abstract class AbstractEditorPreferencePage extends PreferencePage implem } return true; } - + protected OverlayPreferenceStore getOverlayStore() { return fOverlayStore; } - + protected OverlayPreferenceStore setOverlayStore() { return fOverlayStore; } - + protected Map<Button, String> getCheckBoxes() { return fCheckBoxes; } - + protected Map<Text, String> getTextFields() { return fTextFields; } - + protected Map<Text, Object> getNumberFields() { return fNumberFields; } - + @Override protected void performDefaults() { getOverlayStore().loadDefaults(); @@ -144,48 +144,49 @@ public abstract class AbstractEditorPreferencePage extends PreferencePage implem handleDefaults(); super.performDefaults(); } - + protected abstract void handleDefaults(); - + @Override public void dispose() { if (getOverlayStore() != null) { getOverlayStore().stop(); - fOverlayStore= null; + fOverlayStore = null; } super.dispose(); } - - protected Button addCheckBox(Composite parent, String labelText, String key, int indentation) { - Button checkBox= new Button(parent, SWT.CHECK); + + protected Button addCheckBox(Composite parent, String labelText, String key, int indentation) { + Button checkBox = new Button(parent, SWT.CHECK); checkBox.setText(labelText); checkBox.setFont(parent.getFont()); - - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.horizontalIndent= indentation; - gd.horizontalSpan= 2; + + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent = indentation; + gd.horizontalSpan = 2; checkBox.setLayoutData(gd); checkBox.addSelectionListener(fCheckBoxListener); - + getCheckBoxes().put(checkBox, key); - + return checkBox; } - - protected Control addTextField(Composite composite, String labelText, String key, int textLimit, int indentation, String[] errorMessages) { - Font font= composite.getFont(); - - Label label= new Label(composite, SWT.NONE); + + protected Control addTextField(Composite composite, String labelText, String key, int textLimit, int indentation, + String[] errorMessages) { + Font font = composite.getFont(); + + Label label = new Label(composite, SWT.NONE); label.setText(labelText); label.setFont(font); - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.horizontalIndent= indentation; + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent = indentation; label.setLayoutData(gd); - - Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE); - textControl.setFont(font); - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.widthHint= convertWidthInCharsToPixels(textLimit + 1); + + Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE); + textControl.setFont(font); + gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.widthHint = convertWidthInCharsToPixels(textLimit + 1); textControl.setLayoutData(gd); textControl.setTextLimit(textLimit); getTextFields().put(textControl, key); @@ -195,44 +196,44 @@ public abstract class AbstractEditorPreferencePage extends PreferencePage implem } else { textControl.addModifyListener(fTextFieldListener); } - + return textControl; } - + void numberFieldChanged(Text textControl) { - String number= textControl.getText(); - IStatus status= validatePositiveNumber(number, (String[])getNumberFields().get(textControl)); + String number = textControl.getText(); + IStatus status = validatePositiveNumber(number, (String[]) getNumberFields().get(textControl)); if (!status.matches(IStatus.ERROR)) { getOverlayStore().setValue(getTextFields().get(textControl), number); } updateStatus(status); } - + private IStatus validatePositiveNumber(String number, String[] errorMessages) { - StatusInfo status= new StatusInfo(); + StatusInfo status = new StatusInfo(); if (number.length() == 0) { status.setError(errorMessages[0]); } else { try { - int value= Integer.parseInt(number); + int value = Integer.parseInt(number); if (value < 0) - status.setError(MessageFormat.format(errorMessages[1], new Object[]{number})); //$NON-NLS-1$ + status.setError(MessageFormat.format(errorMessages[1], new Object[] { number })); //$NON-NLS-1$ } catch (NumberFormatException e) { - status.setError(MessageFormat.format(errorMessages[1], new Object[]{number})); //$NON-NLS-1$ + status.setError(MessageFormat.format(errorMessages[1], new Object[] { number })); //$NON-NLS-1$ } } return status; } - + private void updateStatus(IStatus status) { if (!status.matches(IStatus.ERROR)) { - Set<Text> keys= getNumberFields().keySet(); + Set<Text> keys = getNumberFields().keySet(); for (Iterator<Text> iter = keys.iterator(); iter.hasNext();) { Text text = iter.next(); - IStatus s= validatePositiveNumber(text.getText(), (String[])getNumberFields().get(text)); - status= s.getSeverity() > status.getSeverity() ? s : status; + IStatus s = validatePositiveNumber(text.getText(), (String[]) getNumberFields().get(text)); + status = s.getSeverity() > status.getSeverity() ? s : status; } - } + } setValid(!status.matches(IStatus.ERROR)); applyToStatusLine(this, status); } @@ -241,47 +242,48 @@ public abstract class AbstractEditorPreferencePage extends PreferencePage implem * Applies the status to the status line of a dialog page. */ private void applyToStatusLine(DialogPage page, IStatus status) { - String message= status.getMessage(); + String message = status.getMessage(); switch (status.getSeverity()) { - case IStatus.OK: - page.setMessage(message, IMessageProvider.NONE); - page.setErrorMessage(null); - break; - case IStatus.WARNING: - page.setMessage(message, IMessageProvider.WARNING); - page.setErrorMessage(null); - break; - case IStatus.INFO: - page.setMessage(message, IMessageProvider.INFORMATION); - page.setErrorMessage(null); - break; - default: - if (message.length() == 0) { - message= null; - } - page.setMessage(null); - page.setErrorMessage(message); - break; + case IStatus.OK: + page.setMessage(message, IMessageProvider.NONE); + page.setErrorMessage(null); + break; + case IStatus.WARNING: + page.setMessage(message, IMessageProvider.WARNING); + page.setErrorMessage(null); + break; + case IStatus.INFO: + page.setMessage(message, IMessageProvider.INFORMATION); + page.setErrorMessage(null); + break; + default: + if (message.length() == 0) { + message = null; + } + page.setMessage(null); + page.setErrorMessage(message); + break; } } - + /** * Returns an array of size 2: * - first element is of type <code>Label</code> * - second element is of type <code>Text</code> * Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls. */ - protected Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, String[] errorMessages) { - Label labelControl= new Label(composite, SWT.NONE); + protected Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, + int indentation, String[] errorMessages) { + Label labelControl = new Label(composite, SWT.NONE); labelControl.setText(label); labelControl.setFont(composite.getFont()); - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.horizontalIndent= indentation; + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent = indentation; labelControl.setLayoutData(gd); - - Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE); - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.widthHint= convertWidthInCharsToPixels(textLimit + 1); + + Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.widthHint = convertWidthInCharsToPixels(textLimit + 1); textControl.setLayoutData(gd); textControl.setTextLimit(textLimit); textControl.setFont(composite.getFont()); @@ -292,18 +294,18 @@ public abstract class AbstractEditorPreferencePage extends PreferencePage implem } else { textControl.addModifyListener(fTextFieldListener); } - - return new Control[]{labelControl, textControl}; + + return new Control[] { labelControl, textControl }; } - + protected String loadPreviewContentFromFile(String filename) { String line; - String separator= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - StringBuilder buffer= new StringBuilder(512); - BufferedReader reader= null; + String separator = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + StringBuilder buffer = new StringBuilder(512); + BufferedReader reader = null; try { - reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename))); - while ((line= reader.readLine()) != null) { + reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename))); + while ((line = reader.readLine()) != null) { buffer.append(line); buffer.append(separator); } @@ -311,7 +313,10 @@ public abstract class AbstractEditorPreferencePage extends PreferencePage implem AutotoolsUIPlugin.log(io); } finally { if (reader != null) { - try { reader.close(); } catch (IOException e) {} + try { + reader.close(); + } catch (IOException e) { + } } } return buffer.toString(); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutoconfEditorPreferencePage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutoconfEditorPreferencePage.java index 253b0d769e7..424e1ee087b 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutoconfEditorPreferencePage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutoconfEditorPreferencePage.java @@ -46,40 +46,38 @@ import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.ui.model.WorkbenchViewerComparator; - - /** * MakeEditorPreferencePage * The page for setting the editor options. */ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { - private static String[] fACVersions = {"2.13", "2.59", "2.61", "2.68"}; + private static String[] fACVersions = { "2.13", "2.59", "2.61", "2.68" }; public static final String LATEST_AC_VERSION = fACVersions[fACVersions.length - 1]; - - private static String[] fAMVersions = {"1.4-p6", "1.9.5", "1.9.6", "1.11.1"}; + + private static String[] fAMVersions = { "1.4-p6", "1.9.5", "1.9.6", "1.11.1" }; public static final String LATEST_AM_VERSION = fAMVersions[fAMVersions.length - 1]; - + /** The keys of the overlay store. */ private String[][] fSyntaxColorListModel; private TableViewer fHighlightingColorListViewer; - private final List<HighlightingColorListItem> fHighlightingColorList= new ArrayList<>(5); + private final List<HighlightingColorListItem> fHighlightingColorList = new ArrayList<>(5); ColorEditor fSyntaxForegroundColorEditor; Button fBoldCheckBox; Button fItalicCheckBox; - + // folding protected Button fFoldingCheckbox; - + // version protected Combo fACVersionCombo; protected Combo fAMVersionCombo; - + /** * Item in the highlighting color list. - * + * * @since 3.0 */ private static class HighlightingColorListItem { @@ -93,52 +91,53 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { private String fItalicKey; /** Item color */ private Color fItemColor; - + /** * Initialize the item with the given values. - * + * * @param displayName the display name * @param colorKey the color preference key * @param boldKey the bold preference key * @param italicKey the italic preference key * @param itemColor the item color */ - public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, Color itemColor) { - fDisplayName= displayName; - fColorKey= colorKey; - fBoldKey= boldKey; - fItalicKey= italicKey; - fItemColor= itemColor; + public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, + Color itemColor) { + fDisplayName = displayName; + fColorKey = colorKey; + fBoldKey = boldKey; + fItalicKey = italicKey; + fItemColor = itemColor; } - + /** * @return the bold preference key */ public String getBoldKey() { return fBoldKey; } - + /** * @return the bold preference key */ public String getItalicKey() { return fItalicKey; } - + /** * @return the color preference key */ public String getColorKey() { return fColorKey; } - + /** * @return the display name */ public String getDisplayName() { return fDisplayName; } - + /** * @return the item color */ @@ -149,19 +148,19 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { /** * Color list label provider. - * + * * @since 3.0 */ private static class ColorListLabelProvider extends LabelProvider implements IColorProvider { @Override public String getText(Object element) { - return ((HighlightingColorListItem)element).getDisplayName(); + return ((HighlightingColorListItem) element).getDisplayName(); } - + @Override public Color getForeground(Object element) { - return ((HighlightingColorListItem)element).getItemColor(); + return ((HighlightingColorListItem) element).getItemColor(); } @Override @@ -169,10 +168,10 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { return null; } } - + /** * Color list content provider. - * + * * @since 3.0 */ private static class ColorListContentProvider implements IStructuredContentProvider { @@ -180,7 +179,7 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { @Override @SuppressWarnings("unchecked") public Object[] getElements(Object inputElement) { - return ((List<Object>)inputElement).toArray(); + return ((List<Object>) inputElement).toArray(); } @Override @@ -191,11 +190,9 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } } - - /** - * + * */ public AutoconfEditorPreferencePage() { super(); @@ -203,98 +200,115 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { @Override protected OverlayPreferenceStore createOverlayStore() { - fSyntaxColorListModel= new String[][] { - {AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_comment"), ColorManager.AUTOCONF_COMMENT_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_acmacro"), ColorManager.AUTOCONF_ACMACRO_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_ammacro"), ColorManager.AUTOCONF_AMMACRO_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_code_seq"), ColorManager.AUTOCONF_CODESEQ_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_keyword"), ColorManager.AUTOCONF_KEYWORD_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_var_ref"), ColorManager.AUTOCONF_VAR_REF_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_var_set"), ColorManager.AUTOCONF_VAR_SET_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_default"), ColorManager.AUTOCONF_DEFAULT_COLOR, null}, //$NON-NLS-1$ - }; + fSyntaxColorListModel = new String[][] { + { AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_comment"), //$NON-NLS-1$ + ColorManager.AUTOCONF_COMMENT_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_acmacro"), //$NON-NLS-1$ + ColorManager.AUTOCONF_ACMACRO_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_ammacro"), //$NON-NLS-1$ + ColorManager.AUTOCONF_AMMACRO_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_code_seq"), //$NON-NLS-1$ + ColorManager.AUTOCONF_CODESEQ_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_keyword"), //$NON-NLS-1$ + ColorManager.AUTOCONF_KEYWORD_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_var_ref"), //$NON-NLS-1$ + ColorManager.AUTOCONF_VAR_REF_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_var_set"), //$NON-NLS-1$ + ColorManager.AUTOCONF_VAR_SET_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconf_editor_default"), //$NON-NLS-1$ + ColorManager.AUTOCONF_DEFAULT_COLOR, null }, }; List<OverlayPreferenceStore.OverlayKey> overlayKeys = new ArrayList<>(); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_CONDITIONAL)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_MACRODEF)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_RULE)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION)); - - for (int i= 0; i < fSyntaxColorListModel.length; i++) { - String colorKey= fSyntaxColorListModel[i][1]; + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, + AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, + AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_CONDITIONAL)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, + AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_MACRODEF)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, + AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_RULE)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, + AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, + AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION)); + + for (int i = 0; i < fSyntaxColorListModel.length; i++) { + String colorKey = fSyntaxColorListModel[i][1]; addTextKeyToCover(overlayKeys, colorKey); } - - OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; + + OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; overlayKeys.toArray(keys); return new OverlayPreferenceStore(getPreferenceStore(), keys); } private void addTextKeyToCover(List<OverlayPreferenceStore.OverlayKey> overlayKeys, String mainKey) { overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, + mainKey + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, + mainKey + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)); } @Override protected Control createContents(Composite parent) { - AutotoolsUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.MAKE_EDITOR_PREFERENCE_PAGE); + AutotoolsUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), + IMakeHelpContextIds.MAKE_EDITOR_PREFERENCE_PAGE); getOverlayStore().load(); getOverlayStore().start(); - - TabFolder folder= new TabFolder(parent, SWT.NONE); - folder.setLayout(new TabFolderLayout()); + + TabFolder folder = new TabFolder(parent, SWT.NONE); + folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); - - TabItem item= new TabItem(folder, SWT.NONE); + + TabItem item = new TabItem(folder, SWT.NONE); item.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.syntax")); //$NON-NLS-1$ item.setControl(createSyntaxPage(folder)); - - item= new TabItem(folder, SWT.NONE); + + item = new TabItem(folder, SWT.NONE); item.setText(AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.folding")); //$NON-NLS-1$ item.setControl(createFoldingTabContent(folder)); - + // Allow end-user to select which version of autoconf to use for hover help // and syntax checking of macros. - item= new TabItem(folder, SWT.NONE); + item = new TabItem(folder, SWT.NONE); item.setText(AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.version")); //$NON-NLS-1$ item.setControl(createVersionTabContent(folder)); - + initialize(); - + applyDialogFont(folder); return folder; } private void initialize() { - + initializeFields(); - - for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++) { - fHighlightingColorList.add( - new HighlightingColorListItem (fSyntaxColorListModel[i][0], fSyntaxColorListModel[i][1], - fSyntaxColorListModel[i][1] + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX, - fSyntaxColorListModel[i][1] + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, null)); + + for (int i = 0, n = fSyntaxColorListModel.length; i < n; i++) { + fHighlightingColorList.add(new HighlightingColorListItem(fSyntaxColorListModel[i][0], + fSyntaxColorListModel[i][1], + fSyntaxColorListModel[i][1] + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX, + fSyntaxColorListModel[i][1] + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, null)); } fHighlightingColorListViewer.setInput(fHighlightingColorList); - fHighlightingColorListViewer.setSelection(new StructuredSelection(fHighlightingColorListViewer.getElementAt(0))); + fHighlightingColorListViewer + .setSelection(new StructuredSelection(fHighlightingColorListViewer.getElementAt(0))); - for (int i=0, n= fACVersions.length; i < n; i++) { + for (int i = 0, n = fACVersions.length; i < n; i++) { fACVersionCombo.setItem(i, fACVersions[i]); } - + initializeFolding(); initializeACVersion(); initializeAMVersion(); } void initializeFolding() { - boolean enabled= getOverlayStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED); - fFoldingCheckbox.setSelection(enabled); + boolean enabled = getOverlayStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED); + fFoldingCheckbox.setSelection(enabled); } - + void initializeACVersion() { // FIXME: What do we do here? There is no PreferenceConstants value for this. // Perhaps we should be using our own overlay store. @@ -330,8 +344,8 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { } void initializeDefaultFolding() { - boolean enabled= getOverlayStore().getDefaultBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED); - fFoldingCheckbox.setSelection(enabled); + boolean enabled = getOverlayStore().getDefaultBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED); + fFoldingCheckbox.setSelection(enabled); } @Override @@ -339,65 +353,66 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { handleSyntaxColorListSelection(); initializeDefaultFolding(); } - + private Control createSyntaxPage(Composite parent) { - - Composite colorComposite= new Composite(parent, SWT.NONE); + + Composite colorComposite = new Composite(parent, SWT.NONE); colorComposite.setLayout(new GridLayout()); - Label label= new Label(colorComposite, SWT.LEFT); + Label label = new Label(colorComposite, SWT.LEFT); label.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.Foreground")); //$NON-NLS-1$ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - Composite editorComposite= new Composite(colorComposite, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; - layout.marginHeight= 0; - layout.marginWidth= 0; + Composite editorComposite = new Composite(colorComposite, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginHeight = 0; + layout.marginWidth = 0; editorComposite.setLayout(layout); - GridData gd= new GridData(GridData.FILL_BOTH); - editorComposite.setLayoutData(gd); + GridData gd = new GridData(GridData.FILL_BOTH); + editorComposite.setLayoutData(gd); - fHighlightingColorListViewer= new TableViewer(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); + fHighlightingColorListViewer = new TableViewer(editorComposite, + SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); fHighlightingColorListViewer.setLabelProvider(new ColorListLabelProvider()); fHighlightingColorListViewer.setContentProvider(new ColorListContentProvider()); fHighlightingColorListViewer.setComparator(new WorkbenchViewerComparator()); - gd= new GridData(GridData.FILL_BOTH); - gd.heightHint= convertHeightInCharsToPixels(5); + gd = new GridData(GridData.FILL_BOTH); + gd.heightHint = convertHeightInCharsToPixels(5); fHighlightingColorListViewer.getControl().setLayoutData(gd); - - Composite stylesComposite= new Composite(editorComposite, SWT.NONE); - layout= new GridLayout(); - layout.marginHeight= 0; - layout.marginWidth= 0; - layout.numColumns= 2; + + Composite stylesComposite = new Composite(editorComposite, SWT.NONE); + layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.numColumns = 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - label= new Label(stylesComposite, SWT.LEFT); + + label = new Label(stylesComposite, SWT.LEFT); label.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.color")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label.setLayoutData(gd); - fSyntaxForegroundColorEditor= new ColorEditor(stylesComposite); - Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton(); - gd= new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalAlignment= GridData.BEGINNING; + fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite); + Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton(); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; foregroundColorButton.setLayoutData(gd); - - fBoldCheckBox= new Button(stylesComposite, SWT.CHECK); + + fBoldCheckBox = new Button(stylesComposite, SWT.CHECK); fBoldCheckBox.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.bold")); //$NON-NLS-1$ - gd= new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalAlignment= GridData.BEGINNING; - gd.horizontalSpan= 2; + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; + gd.horizontalSpan = 2; fBoldCheckBox.setLayoutData(gd); - - fItalicCheckBox= new Button(stylesComposite, SWT.CHECK); + + fItalicCheckBox = new Button(stylesComposite, SWT.CHECK); fItalicCheckBox.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.italic")); //$NON-NLS-1$ - gd= new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalAlignment= GridData.BEGINNING; - gd.horizontalSpan= 2; + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; + gd.horizontalSpan = 2; fItalicCheckBox.setLayoutData(gd); fHighlightingColorListViewer.addSelectionChangedListener(event -> handleSyntaxColorListSelection()); @@ -405,137 +420,137 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { foregroundColorButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - HighlightingColorListItem item= getHighlightingColorListItem(); - PreferenceConverter.setValue(getOverlayStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue()); + HighlightingColorListItem item = getHighlightingColorListItem(); + PreferenceConverter.setValue(getOverlayStore(), item.getColorKey(), + fSyntaxForegroundColorEditor.getColorValue()); } }); fBoldCheckBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - HighlightingColorListItem item= getHighlightingColorListItem(); + HighlightingColorListItem item = getHighlightingColorListItem(); getOverlayStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection()); } }); - + fItalicCheckBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - HighlightingColorListItem item= getHighlightingColorListItem(); + HighlightingColorListItem item = getHighlightingColorListItem(); getOverlayStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection()); } }); - + return colorComposite; } - private Composite createFoldingTabContent(TabFolder folder) { - Composite composite= new Composite(folder, SWT.NULL); + Composite composite = new Composite(folder, SWT.NULL); // assume parent page uses griddata - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL); composite.setLayoutData(gd); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; + GridLayout layout = new GridLayout(); + layout.numColumns = 2; //PixelConverter pc= new PixelConverter(composite); //layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2; composite.setLayout(layout); - - + /* check box for new editors */ - fFoldingCheckbox= new Button(composite, SWT.CHECK); + fFoldingCheckbox = new Button(composite, SWT.CHECK); fFoldingCheckbox.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.foldingenable")); //$NON-NLS-1$ - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); + gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fFoldingCheckbox.setLayoutData(gd); fFoldingCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - boolean enabled= fFoldingCheckbox.getSelection(); + boolean enabled = fFoldingCheckbox.getSelection(); getOverlayStore().setValue(AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED, enabled); } }); - + return composite; } private Composite createVersionTabContent(TabFolder folder) { - Composite composite= new Composite(folder, SWT.NULL); + Composite composite = new Composite(folder, SWT.NULL); // assume parent page uses griddata - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL); composite.setLayoutData(gd); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; + GridLayout layout = new GridLayout(); + layout.numColumns = 2; //PixelConverter pc= new PixelConverter(composite); //layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2; composite.setLayout(layout); - - + /* check box for new editors */ - fACVersionCombo= new Combo(composite, SWT.CHECK | SWT.DROP_DOWN | SWT.READ_ONLY); + fACVersionCombo = new Combo(composite, SWT.CHECK | SWT.DROP_DOWN | SWT.READ_ONLY); fACVersionCombo.setItems(fACVersions); fACVersionCombo.select(fACVersions.length - 1); - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); + gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fACVersionCombo.setLayoutData(gd); fACVersionCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - int index = fACVersionCombo.getSelectionIndex(); - getOverlayStore().setValue(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION, fACVersionCombo.getItem(index)); + int index = fACVersionCombo.getSelectionIndex(); + getOverlayStore().setValue(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION, + fACVersionCombo.getItem(index)); } }); - - Label label= new Label(composite, SWT.LEFT); + + Label label = new Label(composite, SWT.LEFT); label.setText(AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.autoconfVersion")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label.setLayoutData(gd); - + /* check box for new editors */ - fAMVersionCombo= new Combo(composite, SWT.CHECK | SWT.DROP_DOWN | SWT.READ_ONLY); + fAMVersionCombo = new Combo(composite, SWT.CHECK | SWT.DROP_DOWN | SWT.READ_ONLY); fAMVersionCombo.setItems(fAMVersions); fAMVersionCombo.select(fAMVersions.length - 1); - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); + gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fAMVersionCombo.setLayoutData(gd); fAMVersionCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - int index = fAMVersionCombo.getSelectionIndex(); - getOverlayStore().setValue(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION, fAMVersionCombo.getItem(index)); + int index = fAMVersionCombo.getSelectionIndex(); + getOverlayStore().setValue(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION, + fAMVersionCombo.getItem(index)); } }); - - Label label2= new Label(composite, SWT.LEFT); + + Label label2 = new Label(composite, SWT.LEFT); label2.setText(AutotoolsPreferencesMessages.getString("AutoconfEditorPreferencePage.automakeVersion")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label2.setLayoutData(gd); return composite; } void handleSyntaxColorListSelection() { - HighlightingColorListItem item= getHighlightingColorListItem(); - RGB rgb= PreferenceConverter.getColor(getOverlayStore(), item.getColorKey()); - fSyntaxForegroundColorEditor.setColorValue(rgb); + HighlightingColorListItem item = getHighlightingColorListItem(); + RGB rgb = PreferenceConverter.getColor(getOverlayStore(), item.getColorKey()); + fSyntaxForegroundColorEditor.setColorValue(rgb); fBoldCheckBox.setSelection(getOverlayStore().getBoolean(item.getBoldKey())); fItalicCheckBox.setSelection(getOverlayStore().getBoolean(item.getItalicKey())); } - + /** * Returns the current highlighting color list item. - * + * * @return the current highlighting color list item * @since 3.0 */ HighlightingColorListItem getHighlightingColorListItem() { - IStructuredSelection selection= (IStructuredSelection) fHighlightingColorListViewer.getSelection(); + IStructuredSelection selection = (IStructuredSelection) fHighlightingColorListViewer.getSelection(); return (HighlightingColorListItem) selection.getFirstElement(); } /** * @param preferenceStore */ - public static void initDefaults(IPreferenceStore prefs) { + public static void initDefaults(IPreferenceStore prefs) { // Makefile Editor color preferences PreferenceConverter.setDefault(prefs, ColorManager.AUTOCONF_COMMENT_COLOR, ColorManager.AUTOCONF_COMMENT_RGB); PreferenceConverter.setDefault(prefs, ColorManager.AUTOCONF_DEFAULT_COLOR, ColorManager.AUTOCONF_DEFAULT_RGB); @@ -545,7 +560,8 @@ public class AutoconfEditorPreferencePage extends AbstractEditorPreferencePage { PreferenceConverter.setDefault(prefs, ColorManager.AUTOCONF_ACMACRO_COLOR, ColorManager.AUTOCONF_ACMACRO_RGB); PreferenceConverter.setDefault(prefs, ColorManager.AUTOCONF_AMMACRO_COLOR, ColorManager.AUTOCONF_AMMACRO_RGB); PreferenceConverter.setDefault(prefs, ColorManager.AUTOCONF_CODESEQ_COLOR, ColorManager.AUTOCONF_CODESEQ_RGB); - prefs.setDefault(ColorManager.AUTOCONF_CODESEQ_COLOR + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, true); + prefs.setDefault(ColorManager.AUTOCONF_CODESEQ_COLOR + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, + true); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutomakeEditorPreferencePage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutomakeEditorPreferencePage.java index 6bd50ff883f..c5c5aad6d8d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutomakeEditorPreferencePage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutomakeEditorPreferencePage.java @@ -45,8 +45,6 @@ import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.ui.model.WorkbenchViewerComparator; - - /** * MakeEditorPreferencePage * The page for setting the editor options. @@ -57,18 +55,18 @@ public class AutomakeEditorPreferencePage extends AbstractEditorPreferencePage { private String[][] fSyntaxColorListModel; private TableViewer fHighlightingColorListViewer; - private final List<HighlightingColorListItem> fHighlightingColorList= new ArrayList<>(5); + private final List<HighlightingColorListItem> fHighlightingColorList = new ArrayList<>(5); ColorEditor fSyntaxForegroundColorEditor; Button fBoldCheckBox; Button fItalicCheckBox; - + // folding protected Button fFoldingCheckbox; - + /** * Item in the highlighting color list. - * + * * @since 3.0 */ private static class HighlightingColorListItem { @@ -82,52 +80,53 @@ public class AutomakeEditorPreferencePage extends AbstractEditorPreferencePage { private String fItalicKey; /** Item color */ private Color fItemColor; - + /** * Initialize the item with the given values. - * + * * @param displayName the display name * @param colorKey the color preference key * @param boldKey the bold preference key * @param italicKey the italic preference key * @param itemColor the item color */ - public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, Color itemColor) { - fDisplayName= displayName; - fColorKey= colorKey; - fBoldKey= boldKey; - fItalicKey= italicKey; - fItemColor= itemColor; + public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, + Color itemColor) { + fDisplayName = displayName; + fColorKey = colorKey; + fBoldKey = boldKey; + fItalicKey = italicKey; + fItemColor = itemColor; } - + /** * @return the bold preference key */ public String getBoldKey() { return fBoldKey; } - + /** * @return the bold preference key */ public String getItalicKey() { return fItalicKey; } - + /** * @return the color preference key */ public String getColorKey() { return fColorKey; } - + /** * @return the display name */ public String getDisplayName() { return fDisplayName; } - + /** * @return the item color */ @@ -138,19 +137,19 @@ public class AutomakeEditorPreferencePage extends AbstractEditorPreferencePage { /** * Color list label provider. - * + * * @since 3.0 */ private static class ColorListLabelProvider extends LabelProvider implements IColorProvider { @Override public String getText(Object element) { - return ((HighlightingColorListItem)element).getDisplayName(); + return ((HighlightingColorListItem) element).getDisplayName(); } - + @Override public Color getForeground(Object element) { - return ((HighlightingColorListItem)element).getItemColor(); + return ((HighlightingColorListItem) element).getItemColor(); } @Override @@ -158,10 +157,10 @@ public class AutomakeEditorPreferencePage extends AbstractEditorPreferencePage { return null; } } - + /** * Color list content provider. - * + * * @since 3.0 */ private static class ColorListContentProvider implements IStructuredContentProvider { @@ -169,7 +168,7 @@ public class AutomakeEditorPreferencePage extends AbstractEditorPreferencePage { @Override @SuppressWarnings("unchecked") public Object[] getElements(Object inputElement) { - return ((List<Object>)inputElement).toArray(); + return ((List<Object>) inputElement).toArray(); } @Override @@ -180,11 +179,9 @@ public class AutomakeEditorPreferencePage extends AbstractEditorPreferencePage { public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } } - - /** - * + * */ public AutomakeEditorPreferencePage() { super(); @@ -192,85 +189,98 @@ public class AutomakeEditorPreferencePage extends AbstractEditorPreferencePage { @Override protected OverlayPreferenceStore createOverlayStore() { - fSyntaxColorListModel= new String[][] { - {AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_comment"), ColorManager.MAKE_COMMENT_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_macro_ref"), ColorManager.MAKE_MACRO_REF_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_macro_def"), ColorManager.MAKE_MACRO_DEF_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_function"), ColorManager.MAKE_FUNCTION_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_keyword"), ColorManager.MAKE_KEYWORD_COLOR, null}, //$NON-NLS-1$ - {AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_default"), ColorManager.MAKE_DEFAULT_COLOR, null}, //$NON-NLS-1$ - }; - ArrayList<OverlayPreferenceStore.OverlayKey> overlayKeys= new ArrayList<>(); - - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_CONDITIONAL)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_MACRODEF)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_RULE)); - - for (int i= 0; i < fSyntaxColorListModel.length; i++) { - String colorKey= fSyntaxColorListModel[i][1]; + fSyntaxColorListModel = new String[][] { + { AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_comment"), //$NON-NLS-1$ + ColorManager.MAKE_COMMENT_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_macro_ref"), //$NON-NLS-1$ + ColorManager.MAKE_MACRO_REF_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_macro_def"), //$NON-NLS-1$ + ColorManager.MAKE_MACRO_DEF_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_function"), //$NON-NLS-1$ + ColorManager.MAKE_FUNCTION_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_keyword"), //$NON-NLS-1$ + ColorManager.MAKE_KEYWORD_COLOR, null }, + { AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.makefile_editor_default"), //$NON-NLS-1$ + ColorManager.MAKE_DEFAULT_COLOR, null }, }; + ArrayList<OverlayPreferenceStore.OverlayKey> overlayKeys = new ArrayList<>(); + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, + AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, + AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_CONDITIONAL)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, + AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_MACRODEF)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, + AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_RULE)); + + for (int i = 0; i < fSyntaxColorListModel.length; i++) { + String colorKey = fSyntaxColorListModel[i][1]; addTextKeyToCover(overlayKeys, colorKey); } - - OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; + + OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; overlayKeys.toArray(keys); return new OverlayPreferenceStore(getPreferenceStore(), keys); } private void addTextKeyToCover(List<OverlayPreferenceStore.OverlayKey> overlayKeys, String mainKey) { overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, mainKey + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, + mainKey + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, + mainKey + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX)); } @Override protected Control createContents(Composite parent) { - AutotoolsUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.MAKE_EDITOR_PREFERENCE_PAGE); + AutotoolsUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), + IMakeHelpContextIds.MAKE_EDITOR_PREFERENCE_PAGE); getOverlayStore().load(); getOverlayStore().start(); - - TabFolder folder= new TabFolder(parent, SWT.NONE); - folder.setLayout(new TabFolderLayout()); + + TabFolder folder = new TabFolder(parent, SWT.NONE); + folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); - - TabItem item= new TabItem(folder, SWT.NONE); + + TabItem item = new TabItem(folder, SWT.NONE); item.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.syntax")); //$NON-NLS-1$ item.setControl(createSyntaxPage(folder)); - - item= new TabItem(folder, SWT.NONE); + + item = new TabItem(folder, SWT.NONE); item.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.folding")); //$NON-NLS-1$ item.setControl(createFoldingTabContent(folder)); - + initialize(); - + applyDialogFont(folder); return folder; } private void initialize() { - + initializeFields(); - - for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++) { - fHighlightingColorList.add( - new HighlightingColorListItem (fSyntaxColorListModel[i][0], fSyntaxColorListModel[i][1], - fSyntaxColorListModel[i][1] + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX, - fSyntaxColorListModel[i][1] + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, null)); + + for (int i = 0, n = fSyntaxColorListModel.length; i < n; i++) { + fHighlightingColorList.add(new HighlightingColorListItem(fSyntaxColorListModel[i][0], + fSyntaxColorListModel[i][1], + fSyntaxColorListModel[i][1] + AutotoolsEditorPreferenceConstants.EDITOR_BOLD_SUFFIX, + fSyntaxColorListModel[i][1] + AutotoolsEditorPreferenceConstants.EDITOR_ITALIC_SUFFIX, null)); } fHighlightingColorListViewer.setInput(fHighlightingColorList); - fHighlightingColorListViewer.setSelection(new StructuredSelection(fHighlightingColorListViewer.getElementAt(0))); + fHighlightingColorListViewer + .setSelection(new StructuredSelection(fHighlightingColorListViewer.getElementAt(0))); initializeFolding(); } void initializeFolding() { - boolean enabled= getOverlayStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED); - fFoldingCheckbox.setSelection(enabled); + boolean enabled = getOverlayStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED); + fFoldingCheckbox.setSelection(enabled); } void initializeDefaultFolding() { - boolean enabled= getOverlayStore().getDefaultBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED); - fFoldingCheckbox.setSelection(enabled); + boolean enabled = getOverlayStore().getDefaultBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED); + fFoldingCheckbox.setSelection(enabled); } @Override @@ -278,65 +288,66 @@ public class AutomakeEditorPreferencePage extends AbstractEditorPreferencePage { handleSyntaxColorListSelection(); initializeDefaultFolding(); } - + private Control createSyntaxPage(Composite parent) { - - Composite colorComposite= new Composite(parent, SWT.NONE); + + Composite colorComposite = new Composite(parent, SWT.NONE); colorComposite.setLayout(new GridLayout()); - Label label= new Label(colorComposite, SWT.LEFT); + Label label = new Label(colorComposite, SWT.LEFT); label.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.Foreground")); //$NON-NLS-1$ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - Composite editorComposite= new Composite(colorComposite, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; - layout.marginHeight= 0; - layout.marginWidth= 0; + Composite editorComposite = new Composite(colorComposite, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginHeight = 0; + layout.marginWidth = 0; editorComposite.setLayout(layout); - GridData gd= new GridData(GridData.FILL_BOTH); - editorComposite.setLayoutData(gd); + GridData gd = new GridData(GridData.FILL_BOTH); + editorComposite.setLayoutData(gd); - fHighlightingColorListViewer= new TableViewer(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); + fHighlightingColorListViewer = new TableViewer(editorComposite, + SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); fHighlightingColorListViewer.setLabelProvider(new ColorListLabelProvider()); fHighlightingColorListViewer.setContentProvider(new ColorListContentProvider()); fHighlightingColorListViewer.setComparator(new WorkbenchViewerComparator()); - gd= new GridData(GridData.FILL_BOTH); - gd.heightHint= convertHeightInCharsToPixels(5); + gd = new GridData(GridData.FILL_BOTH); + gd.heightHint = convertHeightInCharsToPixels(5); fHighlightingColorListViewer.getControl().setLayoutData(gd); - - Composite stylesComposite= new Composite(editorComposite, SWT.NONE); - layout= new GridLayout(); - layout.marginHeight= 0; - layout.marginWidth= 0; - layout.numColumns= 2; + + Composite stylesComposite = new Composite(editorComposite, SWT.NONE); + layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.numColumns = 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - label= new Label(stylesComposite, SWT.LEFT); + + label = new Label(stylesComposite, SWT.LEFT); label.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.color")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label.setLayoutData(gd); - fSyntaxForegroundColorEditor= new ColorEditor(stylesComposite); - Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton(); - gd= new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalAlignment= GridData.BEGINNING; + fSyntaxForegroundColorEditor = new ColorEditor(stylesComposite); + Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton(); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; foregroundColorButton.setLayoutData(gd); - - fBoldCheckBox= new Button(stylesComposite, SWT.CHECK); + + fBoldCheckBox = new Button(stylesComposite, SWT.CHECK); fBoldCheckBox.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.bold")); //$NON-NLS-1$ - gd= new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalAlignment= GridData.BEGINNING; - gd.horizontalSpan= 2; + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; + gd.horizontalSpan = 2; fBoldCheckBox.setLayoutData(gd); - - fItalicCheckBox= new Button(stylesComposite, SWT.CHECK); + + fItalicCheckBox = new Button(stylesComposite, SWT.CHECK); fItalicCheckBox.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.italic")); //$NON-NLS-1$ - gd= new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalAlignment= GridData.BEGINNING; - gd.horizontalSpan= 2; + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; + gd.horizontalSpan = 2; fItalicCheckBox.setLayoutData(gd); fHighlightingColorListViewer.addSelectionChangedListener(event -> handleSyntaxColorListSelection()); @@ -344,89 +355,88 @@ public class AutomakeEditorPreferencePage extends AbstractEditorPreferencePage { foregroundColorButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - HighlightingColorListItem item= getHighlightingColorListItem(); - PreferenceConverter.setValue(getOverlayStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue()); + HighlightingColorListItem item = getHighlightingColorListItem(); + PreferenceConverter.setValue(getOverlayStore(), item.getColorKey(), + fSyntaxForegroundColorEditor.getColorValue()); } }); fBoldCheckBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - HighlightingColorListItem item= getHighlightingColorListItem(); + HighlightingColorListItem item = getHighlightingColorListItem(); getOverlayStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection()); } }); - + fItalicCheckBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - HighlightingColorListItem item= getHighlightingColorListItem(); + HighlightingColorListItem item = getHighlightingColorListItem(); getOverlayStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection()); } }); - + return colorComposite; } - private Composite createFoldingTabContent(TabFolder folder) { - Composite composite= new Composite(folder, SWT.NULL); + Composite composite = new Composite(folder, SWT.NULL); // assume parent page uses griddata - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL); composite.setLayoutData(gd); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; + GridLayout layout = new GridLayout(); + layout.numColumns = 2; //PixelConverter pc= new PixelConverter(composite); //layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2; composite.setLayout(layout); - - + /* check box for new editors */ - fFoldingCheckbox= new Button(composite, SWT.CHECK); + fFoldingCheckbox = new Button(composite, SWT.CHECK); fFoldingCheckbox.setText(AutotoolsPreferencesMessages.getString("AutomakeEditorPreferencePage.foldingenable")); //$NON-NLS-1$ - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); + gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fFoldingCheckbox.setLayoutData(gd); fFoldingCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - boolean enabled= fFoldingCheckbox.getSelection(); + boolean enabled = fFoldingCheckbox.getSelection(); getOverlayStore().setValue(AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED, enabled); } }); - + return composite; } void handleSyntaxColorListSelection() { - HighlightingColorListItem item= getHighlightingColorListItem(); - RGB rgb= PreferenceConverter.getColor(getOverlayStore(), item.getColorKey()); - fSyntaxForegroundColorEditor.setColorValue(rgb); + HighlightingColorListItem item = getHighlightingColorListItem(); + RGB rgb = PreferenceConverter.getColor(getOverlayStore(), item.getColorKey()); + fSyntaxForegroundColorEditor.setColorValue(rgb); fBoldCheckBox.setSelection(getOverlayStore().getBoolean(item.getBoldKey())); fItalicCheckBox.setSelection(getOverlayStore().getBoolean(item.getItalicKey())); } - + /** * Returns the current highlighting color list item. - * + * * @return the current highlighting color list item * @since 3.0 */ HighlightingColorListItem getHighlightingColorListItem() { - IStructuredSelection selection= (IStructuredSelection) fHighlightingColorListViewer.getSelection(); + IStructuredSelection selection = (IStructuredSelection) fHighlightingColorListViewer.getSelection(); return (HighlightingColorListItem) selection.getFirstElement(); } /** * @param preferenceStore */ - public static void initDefaults(IPreferenceStore prefs) { + public static void initDefaults(IPreferenceStore prefs) { // Makefile Editor color preferences PreferenceConverter.setDefault(prefs, ColorManager.MAKE_COMMENT_COLOR, ColorManager.MAKE_COMMENT_RGB); PreferenceConverter.setDefault(prefs, ColorManager.MAKE_DEFAULT_COLOR, ColorManager.MAKE_DEFAULT_RGB); PreferenceConverter.setDefault(prefs, ColorManager.MAKE_FUNCTION_COLOR, ColorManager.MAKE_FUNCTION_RGB); PreferenceConverter.setDefault(prefs, ColorManager.MAKE_KEYWORD_COLOR, ColorManager.MAKE_KEYWORD_RGB); PreferenceConverter.setDefault(prefs, ColorManager.MAKE_MACRO_DEF_COLOR, ColorManager.MAKE_MACRO_DEF_RGB); - PreferenceConverter.setDefault(prefs, ColorManager.MAKE_MACRO_REF_COLOR, ColorManager.MAKE_MACRO_REF_RGB); + PreferenceConverter.setDefault(prefs, ColorManager.MAKE_MACRO_REF_COLOR, ColorManager.MAKE_MACRO_REF_RGB); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsEditorPreferenceConstants.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsEditorPreferenceConstants.java index 412eab5d5f8..f25e4f793dd 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsEditorPreferenceConstants.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsEditorPreferenceConstants.java @@ -23,7 +23,7 @@ import org.eclipse.jface.preference.IPreferenceStore; public class AutotoolsEditorPreferenceConstants { /** - * + * */ private AutotoolsEditorPreferenceConstants() { } @@ -34,19 +34,18 @@ public class AutotoolsEditorPreferenceConstants { */ public static final String CURRENT_LINE_COLOR = "org.eclipse.cdt.autotools.ui.automake.currentLineHightlightColor"; //$NON-NLS-1$ public static final String LINE_NUMBER_RULER_COLOR = "org.eclipse.cdt.autotools.ui.automake.lineNumberForegroundColor"; //$NON-NLS-1$ - public static final String PRINT_MARGIN_COLOR = "org.eclipse.cdt.autotools.ui.automake.printMarginColor"; //$NON-NLS-1$ - + public static final String PRINT_MARGIN_COLOR = "org.eclipse.cdt.autotools.ui.automake.printMarginColor"; //$NON-NLS-1$ + /** * Preference key suffix for bold text style preference keys. - * + * */ - public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$ + public static final String EDITOR_BOLD_SUFFIX = "_bold"; //$NON-NLS-1$ /** * Preference key suffix for italic text style preference keys. */ - public static final String EDITOR_ITALIC_SUFFIX= "_italic"; //$NON-NLS-1$ - + public static final String EDITOR_ITALIC_SUFFIX = "_italic"; //$NON-NLS-1$ public static final String EDITOR_FOLDING_MACRODEF = "editor_folding_default_macrodef"; //$NON-NLS-1$ @@ -59,11 +58,11 @@ public class AutotoolsEditorPreferenceConstants { public static final String EDITOR_FOLDING_LOOP = "editor_folding_default_loop"; //$NON-NLS-1$ public static final String EDITOR_FOLDING_ENABLED = "editor_folding_enabled"; //$NON-NLS-1$ - + public static final String AUTOCONF_VERSION = "autoconf_version"; - + public static final String AUTOMAKE_VERSION = "automake_version"; - + public static void initializeDefaultValues(IPreferenceStore store) { store.setDefault(AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED, false); @@ -72,8 +71,10 @@ public class AutotoolsEditorPreferenceConstants { store.setDefault(AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_CASE, true); store.setDefault(AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_CONDITIONAL, true); store.setDefault(AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_LOOP, true); - store.setDefault(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION, AutoconfEditorPreferencePage.LATEST_AC_VERSION); - store.setDefault(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION, AutoconfEditorPreferencePage.LATEST_AM_VERSION); + store.setDefault(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION, + AutoconfEditorPreferencePage.LATEST_AC_VERSION); + store.setDefault(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION, + AutoconfEditorPreferencePage.LATEST_AM_VERSION); } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsPreferencePage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsPreferencePage.java index 1ec952ed5b0..18b3eb3df54 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsPreferencePage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsPreferencePage.java @@ -22,7 +22,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; - public class AutotoolsPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { private static final String PREF_BUILD_TARGET_IN_BACKGROUND = "MakeTargetPrefs.buildTargetInBackground"; //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsPreferencesMessages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsPreferencesMessages.java index a8e22d3d346..b0bb4ccda93 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsPreferencesMessages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/AutotoolsPreferencesMessages.java @@ -23,7 +23,7 @@ import java.util.ResourceBundle; public class AutotoolsPreferencesMessages { /** - * + * */ private AutotoolsPreferencesMessages() { } @@ -38,6 +38,6 @@ public class AutotoolsPreferencesMessages { } catch (NullPointerException e) { return '#' + key + '#'; } - } + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/ColorEditor.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/ColorEditor.java index 2ab1753c7e2..f313168cbfd 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/ColorEditor.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/ColorEditor.java @@ -34,38 +34,38 @@ import org.eclipse.swt.widgets.Display; * A "button" of a certain color determined by the color picker */ public class ColorEditor { - + private Point fExtent; Image fImage; RGB fColorValue; Color fColor; Button fButton; - + public ColorEditor(Composite parent) { - - fButton= new Button(parent, SWT.PUSH); - fExtent= computeImageSize(parent); - fImage= new Image(parent.getDisplay(), fExtent.x, fExtent.y); - - GC gc= new GC(fImage); + + fButton = new Button(parent, SWT.PUSH); + fExtent = computeImageSize(parent); + fImage = new Image(parent.getDisplay(), fExtent.x, fExtent.y); + + GC gc = new GC(fImage); gc.setBackground(fButton.getBackground()); gc.fillRectangle(0, 0, fExtent.x, fExtent.y); gc.dispose(); - + fButton.setImage(fImage); fButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { - ColorDialog colorDialog= new ColorDialog(fButton.getShell()); + ColorDialog colorDialog = new ColorDialog(fButton.getShell()); colorDialog.setRGB(fColorValue); RGB newColor = colorDialog.open(); if (newColor != null) { - fColorValue= newColor; + fColorValue = newColor; updateColorImage(); } } }); - + fButton.addDisposeListener(event -> { if (fImage != null) { fImage.dispose(); @@ -77,44 +77,44 @@ public class ColorEditor { } }); } - + public RGB getColorValue() { return fColorValue; } - + public void setColorValue(RGB rgb) { - fColorValue= rgb; + fColorValue = rgb; updateColorImage(); } - + public Button getButton() { return fButton; } - + protected void updateColorImage() { - - Display display= fButton.getDisplay(); - - GC gc= new GC(fImage); + + Display display = fButton.getDisplay(); + + GC gc = new GC(fImage); gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4); - + if (fColor != null) fColor.dispose(); - - fColor= new Color(display, fColorValue); + + fColor = new Color(display, fColorValue); gc.setBackground(fColor); gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5); gc.dispose(); - + fButton.setImage(fImage); } - + protected Point computeImageSize(Control window) { - GC gc= new GC(window); - Font f= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); + GC gc = new GC(window); + Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); gc.setFont(f); - int height= gc.getFontMetrics().getHeight(); + int height = gc.getFontMetrics().getHeight(); gc.dispose(); return new Point(height * 3 - 6, height); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/ColorManager.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/ColorManager.java index deb3a08dcaa..6bda2e046d7 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/ColorManager.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/ColorManager.java @@ -24,14 +24,14 @@ import org.eclipse.swt.widgets.Display; public class ColorManager implements ISharedTextColors { - public static final String MAKE_COMMENT_COLOR ="org.eclipse.cdt.autotools.ui.automake.editor.comment"; //$NON-NLS-1$ + public static final String MAKE_COMMENT_COLOR = "org.eclipse.cdt.autotools.ui.automake.editor.comment"; //$NON-NLS-1$ public static final String MAKE_KEYWORD_COLOR = "org.eclipse.cdt.autotools.ui.automake.editor.keyword"; //$NON-NLS-1$ public static final String MAKE_FUNCTION_COLOR = "org.eclipse.cdt.autotools.ui.automake.editor.function"; //$NON-NLS-1$ public static final String MAKE_MACRO_REF_COLOR = "org.eclipse.cdt.autotools.ui.automake.editor.macro_ref"; //$NON-NLS-1$ public static final String MAKE_MACRO_DEF_COLOR = "org.eclipse.cdt.autotools.ui.automake.editor.macro_def"; //$NON-NLS-1$ public static final String MAKE_DEFAULT_COLOR = "org.eclipse.cdt.autotools.ui.automake.editor.default"; //$NON-NLS-1$ - public static final String AUTOCONF_COMMENT_COLOR ="org.eclipse.cdt.autotools.ui.autoconf.editor.comment"; //$NON-NLS-1$ + public static final String AUTOCONF_COMMENT_COLOR = "org.eclipse.cdt.autotools.ui.autoconf.editor.comment"; //$NON-NLS-1$ public static final String AUTOCONF_KEYWORD_COLOR = "org.eclipse.cdt.autotools.ui.autoconf.editor.keyword"; //$NON-NLS-1$ public static final String AUTOCONF_VAR_REF_COLOR = "org.eclipse.cdt.autotools.ui.autoconf.editor.var_ref"; //$NON-NLS-1$ public static final String AUTOCONF_VAR_SET_COLOR = "org.eclipse.cdt.autotools.ui.autoconf.editor.var_set"; //$NON-NLS-1$ @@ -57,13 +57,13 @@ public class ColorManager implements ISharedTextColors { public static final RGB AUTOCONF_DEFAULT_RGB = new RGB(0, 0, 0); private static ColorManager fgColorManager; - + private ColorManager() { } - + public static ColorManager getDefault() { if (fgColorManager == null) { - fgColorManager= new ColorManager(); + fgColorManager = new ColorManager(); } return fgColorManager; } @@ -74,7 +74,7 @@ public class ColorManager implements ISharedTextColors { public void dispose() { Iterator<Color> e = fColorTable.values().iterator(); while (e.hasNext()) - e.next().dispose(); + e.next().dispose(); } @Override diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/OverlayPreferenceStore.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/OverlayPreferenceStore.java index 13c276bf540..d925c14ef9d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/OverlayPreferenceStore.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/OverlayPreferenceStore.java @@ -25,208 +25,206 @@ import org.eclipse.jface.util.PropertyChangeEvent; /** * An overlaying preference store. */ -class OverlayPreferenceStore implements IPreferenceStore { - - +class OverlayPreferenceStore implements IPreferenceStore { + public static final class TypeDescriptor { TypeDescriptor() { } } - - public static final TypeDescriptor BOOLEAN= new TypeDescriptor(); - public static final TypeDescriptor DOUBLE= new TypeDescriptor(); - public static final TypeDescriptor FLOAT= new TypeDescriptor(); - public static final TypeDescriptor INT= new TypeDescriptor(); - public static final TypeDescriptor LONG= new TypeDescriptor(); - public static final TypeDescriptor STRING= new TypeDescriptor(); - + + public static final TypeDescriptor BOOLEAN = new TypeDescriptor(); + public static final TypeDescriptor DOUBLE = new TypeDescriptor(); + public static final TypeDescriptor FLOAT = new TypeDescriptor(); + public static final TypeDescriptor INT = new TypeDescriptor(); + public static final TypeDescriptor LONG = new TypeDescriptor(); + public static final TypeDescriptor STRING = new TypeDescriptor(); + public static class OverlayKey { - + TypeDescriptor fDescriptor; String fKey; - + public OverlayKey(TypeDescriptor descriptor, String key) { - fDescriptor= descriptor; - fKey= key; + fDescriptor = descriptor; + fKey = key; } } - + private class PropertyListener implements IPropertyChangeListener { - + @Override public void propertyChange(PropertyChangeEvent event) { - OverlayKey key= findOverlayKey(event.getProperty()); + OverlayKey key = findOverlayKey(event.getProperty()); if (key != null) - propagateProperty(fParent, key, fStore); + propagateProperty(fParent, key, fStore); } } - - + IPreferenceStore fParent; IPreferenceStore fStore; private OverlayKey[] fOverlayKeys; - + private PropertyListener fPropertyListener; - - + public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) { - fParent= parent; - fOverlayKeys= overlayKeys; - fStore= new PreferenceStore(); + fParent = parent; + fOverlayKeys = overlayKeys; + fStore = new PreferenceStore(); } - + OverlayKey findOverlayKey(String key) { - for (int i= 0; i < fOverlayKeys.length; i++) { + for (int i = 0; i < fOverlayKeys.length; i++) { if (fOverlayKeys[i].fKey.equals(key)) return fOverlayKeys[i]; } return null; } - + private boolean covers(String key) { return (findOverlayKey(key) != null); } - + void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { - + if (orgin.isDefault(key.fKey)) { if (!target.isDefault(key.fKey)) target.setToDefault(key.fKey); return; } - - TypeDescriptor d= key.fDescriptor; + + TypeDescriptor d = key.fDescriptor; if (BOOLEAN == d) { - - boolean originValue= orgin.getBoolean(key.fKey); - boolean targetValue= target.getBoolean(key.fKey); + + boolean originValue = orgin.getBoolean(key.fKey); + boolean targetValue = target.getBoolean(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); - + } else if (DOUBLE == d) { - - double originValue= orgin.getDouble(key.fKey); - double targetValue= target.getDouble(key.fKey); + + double originValue = orgin.getDouble(key.fKey); + double targetValue = target.getDouble(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); - + } else if (FLOAT == d) { - - float originValue= orgin.getFloat(key.fKey); - float targetValue= target.getFloat(key.fKey); + + float originValue = orgin.getFloat(key.fKey); + float targetValue = target.getFloat(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); - + } else if (INT == d) { - int originValue= orgin.getInt(key.fKey); - int targetValue= target.getInt(key.fKey); + int originValue = orgin.getInt(key.fKey); + int targetValue = target.getInt(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (LONG == d) { - long originValue= orgin.getLong(key.fKey); - long targetValue= target.getLong(key.fKey); + long originValue = orgin.getLong(key.fKey); + long targetValue = target.getLong(key.fKey); if (targetValue != originValue) target.setValue(key.fKey, originValue); } else if (STRING == d) { - String originValue= orgin.getString(key.fKey); - String targetValue= target.getString(key.fKey); + String originValue = orgin.getString(key.fKey); + String targetValue = target.getString(key.fKey); if (targetValue != null && originValue != null && !targetValue.equals(originValue)) target.setValue(key.fKey, originValue); } } - + public void propagate() { - for (int i= 0; i < fOverlayKeys.length; i++) + for (int i = 0; i < fOverlayKeys.length; i++) propagateProperty(fStore, fOverlayKeys[i], fParent); } - - private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) { - TypeDescriptor d= key.fDescriptor; + + private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, + boolean forceInitialization) { + TypeDescriptor d = key.fDescriptor; if (BOOLEAN == d) { - + if (forceInitialization) target.setValue(key.fKey, true); target.setValue(key.fKey, orgin.getBoolean(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey)); - + } else if (DOUBLE == d) { - + if (forceInitialization) target.setValue(key.fKey, 1.0D); target.setValue(key.fKey, orgin.getDouble(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey)); - + } else if (FLOAT == d) { - + if (forceInitialization) target.setValue(key.fKey, 1.0F); target.setValue(key.fKey, orgin.getFloat(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey)); - + } else if (INT == d) { - + if (forceInitialization) target.setValue(key.fKey, 1); target.setValue(key.fKey, orgin.getInt(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey)); - + } else if (LONG == d) { - + if (forceInitialization) target.setValue(key.fKey, 1L); target.setValue(key.fKey, orgin.getLong(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey)); - + } else if (STRING == d) { - + if (forceInitialization) target.setValue(key.fKey, "1"); //$NON-NLS-1$ target.setValue(key.fKey, orgin.getString(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); - + } } - + public void load() { - for (int i= 0; i < fOverlayKeys.length; i++) + for (int i = 0; i < fOverlayKeys.length; i++) loadProperty(fParent, fOverlayKeys[i], fStore, true); } - + public void loadDefaults() { - for (int i= 0; i < fOverlayKeys.length; i++) + for (int i = 0; i < fOverlayKeys.length; i++) setToDefault(fOverlayKeys[i].fKey); } - + public void start() { if (fPropertyListener == null) { - fPropertyListener= new PropertyListener(); + fPropertyListener = new PropertyListener(); fParent.addPropertyChangeListener(fPropertyListener); } } - + public void stop() { - if (fPropertyListener != null) { + if (fPropertyListener != null) { fParent.removePropertyChangeListener(fPropertyListener); - fPropertyListener= null; + fPropertyListener = null; } } - + @Override public void addPropertyChangeListener(IPropertyChangeListener listener) { fStore.addPropertyChangeListener(listener); } - + @Override public void removePropertyChangeListener(IPropertyChangeListener listener) { fStore.removePropertyChangeListener(listener); } - + @Override public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { fStore.firePropertyChangeEvent(name, oldValue, newValue); @@ -236,7 +234,7 @@ class OverlayPreferenceStore implements IPreferenceStore { public boolean contains(String name) { return fStore.contains(name); } - + @Override public boolean getBoolean(String name) { return fStore.getBoolean(name); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/StatusInfo.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/StatusInfo.java index 1b0a453770e..01e74b7cb07 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/StatusInfo.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/StatusInfo.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.autotools.ui.AutotoolsUIPlugin; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IStatus; - /** * A settable IStatus. * Can be an error, warning, info or ok. For error, info and warning states, @@ -43,8 +42,8 @@ public class StatusInfo implements IStatus { * WARNING and INFO. */ public StatusInfo(int severity, String message) { - fStatusMessage= message; - fSeverity= severity; + fStatusMessage = message; + fSeverity = severity; } /** @@ -87,8 +86,8 @@ public class StatusInfo implements IStatus { */ public void setError(String errorMessage) { Assert.isNotNull(errorMessage); - fStatusMessage= errorMessage; - fSeverity= IStatus.ERROR; + fStatusMessage = errorMessage; + fSeverity = IStatus.ERROR; } /** @@ -97,8 +96,8 @@ public class StatusInfo implements IStatus { */ public void setWarning(String warningMessage) { Assert.isNotNull(warningMessage); - fStatusMessage= warningMessage; - fSeverity= IStatus.WARNING; + fStatusMessage = warningMessage; + fSeverity = IStatus.WARNING; } /** @@ -107,16 +106,16 @@ public class StatusInfo implements IStatus { */ public void setInfo(String infoMessage) { Assert.isNotNull(infoMessage); - fStatusMessage= infoMessage; - fSeverity= IStatus.INFO; + fStatusMessage = infoMessage; + fSeverity = IStatus.INFO; } /** * Sets the status to OK. */ public void setOK() { - fStatusMessage= null; - fSeverity= IStatus.OK; + fStatusMessage = null; + fSeverity = IStatus.OK; } /* diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/TabFolderLayout.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/TabFolderLayout.java index ca9eeaf31bb..2635eda3084 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/TabFolderLayout.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/preferences/TabFolderLayout.java @@ -24,33 +24,33 @@ import org.eclipse.swt.widgets.Layout; public class TabFolderLayout extends Layout { @Override - protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) { + protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) return new Point(wHint, hHint); - - Control [] children = composite.getChildren (); + + Control[] children = composite.getChildren(); int count = children.length; int maxWidth = 0, maxHeight = 0; - for (int i=0; i<count; i++) { - Control child = children [i]; - Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache); - maxWidth = Math.max (maxWidth, pt.x); - maxHeight = Math.max (maxHeight, pt.y); + for (int i = 0; i < count; i++) { + Control child = children[i]; + Point pt = child.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache); + maxWidth = Math.max(maxWidth, pt.x); + maxHeight = Math.max(maxHeight, pt.y); } - + if (wHint != SWT.DEFAULT) - maxWidth= wHint; + maxWidth = wHint; if (hHint != SWT.DEFAULT) - maxHeight= hHint; - - return new Point(maxWidth, maxHeight); - + maxHeight = hHint; + + return new Point(maxWidth, maxHeight); + } - + @Override - protected void layout (Composite composite, boolean flushCache) { - Rectangle rect= composite.getClientArea(); - + protected void layout(Composite composite, boolean flushCache) { + Rectangle rect = composite.getClientArea(); + Control[] children = composite.getChildren(); for (int i = 0; i < children.length; i++) { children[i].setBounds(rect); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AbstractConfigurePropertyOptionsPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AbstractConfigurePropertyOptionsPage.java index c6d7847e7a9..debf4c401a8 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AbstractConfigurePropertyOptionsPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AbstractConfigurePropertyOptionsPage.java @@ -18,8 +18,7 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.PropertyChangeEvent; -public abstract class AbstractConfigurePropertyOptionsPage extends - FieldEditorPreferencePage { +public abstract class AbstractConfigurePropertyOptionsPage extends FieldEditorPreferencePage { private boolean dirty = false; private String name; @@ -28,16 +27,16 @@ public abstract class AbstractConfigurePropertyOptionsPage extends this(GRID); this.name = name; } - + protected String getName() { return name; } - + protected AbstractConfigurePropertyOptionsPage(int style) { super(style); noDefaultAndApplyButton(); } - + @Override protected void createFieldEditors() { // Get the preference store for the build settings @@ -50,17 +49,26 @@ public abstract class AbstractConfigurePropertyOptionsPage extends */ @Override public void propertyChange(PropertyChangeEvent event) { - super.propertyChange(event); + super.propertyChange(event); if (event.getProperty().equals(FieldEditor.VALUE)) { - setDirty(true); + setDirty(true); } } - public void setDirty(boolean b) { dirty = b; } - public boolean isDirty() { return dirty; } - public void storeSettings() { super.performOk(); } + public void setDirty(boolean b) { + dirty = b; + } + + public boolean isDirty() { + return dirty; + } + + public void storeSettings() { + super.performOk(); + } public abstract void updateFields(); + public abstract void setValues(); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsBuildPropertyPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsBuildPropertyPage.java index 28ea082098d..b394401485e 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsBuildPropertyPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsBuildPropertyPage.java @@ -30,7 +30,6 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; - public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { private String TRUE = "true"; //$NON-NLS-1$ @@ -41,14 +40,14 @@ public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { private String CLEAN_MAKETARGET_TOOLTIP = "CleanMakeTarget.tooltip"; //$NON-NLS-1$ private String AUTO_BUILDNAME_LABEL = "AutoBuildName.label"; //$NON-NLS-1$ private String AUTO_BUILDNAME_TOOLTIP = "AutoBuildName.tooltip"; //$NON-NLS-1$ - + protected Button fCleanDelete; protected Button fCleanMake; protected Button fAutoName; - protected Text fCleanMakeTarget; + protected Text fCleanMakeTarget; private IProject getProject() { - return (IProject)getCfg().getManagedProject().getOwner(); + return (IProject) getCfg().getManagedProject().getOwner(); } @Override @@ -59,50 +58,53 @@ public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { @Override public void createControls(Composite parent) { super.createControls(parent); - Composite composite= usercomp; + Composite composite = usercomp; // assume parent page uses griddata - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL); + GridData gd = new GridData( + GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL); composite.setLayoutData(gd); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; + GridLayout layout = new GridLayout(); + layout.numColumns = 2; //PixelConverter pc= new PixelConverter(composite); //layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2; composite.setLayout(layout); - + Group g = new Group(composite, SWT.SHADOW_ETCHED_IN); g.setText(AutotoolsPropertyMessages.getString("CleanBehavior.title")); - gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); + gd = new GridData( + GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; g.setLayoutData(gd); - layout= new GridLayout(); - layout.numColumns= 2; + layout = new GridLayout(); + layout.numColumns = 2; g.setLayout(layout); - + fCleanDelete = new Button(g, SWT.RADIO); fCleanDelete.setText(AutotoolsPropertyMessages.getString(CLEAN_DELETE_LABEL)); - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; gd.horizontalSpan = 2; fCleanDelete.setLayoutData(gd); fCleanMake = new Button(g, SWT.RADIO); fCleanMake.setText(AutotoolsPropertyMessages.getString(CLEAN_MAKE_LABEL)); - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; gd.horizontalSpan = 2; fCleanMake.setLayoutData(gd); - + Label label = new Label(g, SWT.LEFT); label.setText(AutotoolsPropertyMessages.getString(CLEAN_MAKETARGET_LABEL)); - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label.setLayoutData(gd); - + fCleanMakeTarget = new Text(g, SWT.SINGLE | SWT.BORDER); fCleanMakeTarget.setText(AutotoolsPropertyConstants.CLEAN_MAKE_TARGET_DEFAULT); fCleanMakeTarget.setToolTipText(AutotoolsPropertyMessages.getString(CLEAN_MAKETARGET_TOOLTIP)); - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); + gd = new GridData( + GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); fCleanMakeTarget.setLayoutData(gd); - + fCleanDelete.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -111,7 +113,7 @@ public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { fCleanMakeTarget.setEnabled(false); } }); - + fCleanMake.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -120,21 +122,21 @@ public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { fCleanMakeTarget.setEnabled(true); } }); - + fCleanMakeTarget.addModifyListener(e -> { if (fCleanMakeTarget.getText().isEmpty()) { // FIXME: should probably issue warning here, but how? } }); - + fAutoName = new Button(composite, SWT.LEFT | SWT.CHECK); fAutoName.setText(AutotoolsPropertyMessages.getString(AUTO_BUILDNAME_LABEL)); fAutoName.setToolTipText(AutotoolsPropertyMessages.getString(AUTO_BUILDNAME_TOOLTIP)); - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; gd.horizontalSpan = 2; fAutoName.setLayoutData(gd); - + initialize(); } @@ -143,7 +145,7 @@ public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { IProject project = getProject(); if (fCleanDelete.getSelection()) { try { - project.setPersistentProperty(AutotoolsPropertyConstants.CLEAN_DELETE, TRUE); + project.setPersistentProperty(AutotoolsPropertyConstants.CLEAN_DELETE, TRUE); } catch (CoreException ce) { // FIXME: what can we do here? } @@ -159,10 +161,10 @@ public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { // FIXME: what can we do here? } } - + if (fAutoName.getSelection()) { try { - project.setPersistentProperty(AutotoolsPropertyConstants.AUTO_BUILD_NAME, TRUE); + project.setPersistentProperty(AutotoolsPropertyConstants.AUTO_BUILD_NAME, TRUE); } catch (CoreException ce) { // FIXME: what can we do here? } @@ -180,7 +182,7 @@ public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { protected void performApply(ICResourceDescription src, ICResourceDescription dst) { performOK(); } - + @Override protected void performDefaults() { fCleanDelete.setSelection(false); @@ -189,12 +191,12 @@ public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { fCleanMakeTarget.setEnabled(true); fAutoName.setEnabled(true); } - + @Override public void updateData(ICResourceDescription cfgd) { // what to do here? } - + @Override public void updateButtons() { // what to do here? @@ -227,11 +229,11 @@ public class AutotoolsBuildPropertyPage extends AbstractCBuildPropertyTab { fCleanMake.setSelection(false); fCleanMakeTarget.setEnabled(false); } - + if (autoName == null || autoName.equals(TRUE)) fAutoName.setSelection(true); else fAutoName.setSelection(false); } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsCategoryPropertyOptionPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsCategoryPropertyOptionPage.java index 7481ad2574c..2c3984c67e0 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsCategoryPropertyOptionPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsCategoryPropertyOptionPage.java @@ -40,49 +40,57 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -public class AutotoolsCategoryPropertyOptionPage extends - AbstractConfigurePropertyOptionsPage { +public class AutotoolsCategoryPropertyOptionPage extends AbstractConfigurePropertyOptionsPage { private static final int MARGIN = 3; private String catName = ""; private IAConfiguration cfg; + // Label class for a preference page. static class LabelFieldEditor extends FieldEditor { private String fTitle; private Label fTitleLabel; - public LabelFieldEditor( Composite parent, String title ) { + public LabelFieldEditor(Composite parent, String title) { fTitle = title; - this.createControl( parent ); + this.createControl(parent); } @Override - protected void adjustForNumColumns( int numColumns ) { - ((GridData)fTitleLabel.getLayoutData()).horizontalSpan = 2; + protected void adjustForNumColumns(int numColumns) { + ((GridData) fTitleLabel.getLayoutData()).horizontalSpan = 2; } @Override - protected void doFillIntoGrid( Composite parent, int numColumns ) { - fTitleLabel = new Label( parent, SWT.WRAP ); - fTitleLabel.setText( fTitle ); + protected void doFillIntoGrid(Composite parent, int numColumns) { + fTitleLabel = new Label(parent, SWT.WRAP); + fTitleLabel.setText(fTitle); GridData gd = new GridData(); gd.verticalAlignment = SWT.TOP; gd.grabExcessHorizontalSpace = false; gd.horizontalSpan = 2; - fTitleLabel.setLayoutData( gd ); + fTitleLabel.setLayoutData(gd); } @Override - public int getNumberOfControls() { return 1; } + public int getNumberOfControls() { + return 1; + } + /** * The label field editor is only used to present a text label on a preference page. */ @Override - protected void doLoad() {} + protected void doLoad() { + } + @Override - protected void doLoadDefault() {} + protected void doLoadDefault() { + } + @Override - protected void doStore() {} + protected void doStore() { + } } static class VariableListEditor extends ListEditor { @@ -304,19 +312,19 @@ public class AutotoolsCategoryPropertyOptionPage extends }; private List<FieldEditor> fieldEditors; - + public AutotoolsCategoryPropertyOptionPage(ToolListElement element, IAConfiguration cfg) { - super(element.getName()); - this.catName = element.getName(); - this.cfg = cfg; - fieldEditors = new ArrayList<>(); + super(element.getName()); + this.catName = element.getName(); + this.cfg = cfg; + fieldEditors = new ArrayList<>(); } @Override protected void createFieldEditors() { super.createFieldEditors(); Composite parent = getFieldEditorParent(); - + // Add margin parent.setLayout(new GridLayout(1, false)); Composite area = new Composite(parent, SWT.NONE); @@ -326,8 +334,8 @@ public class AutotoolsCategoryPropertyOptionPage extends gl.marginRight = MARGIN; area.setLayout(gl); area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); - -// FontMetrics fm = AbstractCPropertyTab.getFontMetrics(parent); + + // FontMetrics fm = AbstractCPropertyTab.getFontMetrics(parent); AutotoolsConfiguration.Option[] options = AutotoolsConfiguration.getChildOptions(catName); for (int i = 0; i < options.length; ++i) { AutotoolsConfiguration.Option option = options[i]; @@ -369,29 +377,29 @@ public class AutotoolsCategoryPropertyOptionPage extends public void updateFields() { setValues(); } - + @Override public void setValues() { for (int i = 0; i < fieldEditors.size(); ++i) { fieldEditors.get(i).load(); } } - + @Override public void propertyChange(PropertyChangeEvent event) { // allow superclass to handle as well super.propertyChange(event); if (event.getSource() instanceof StringFieldEditor) { - StringFieldEditor f = (StringFieldEditor)event.getSource(); + StringFieldEditor f = (StringFieldEditor) event.getSource(); cfg.setOption(f.getPreferenceName(), f.getStringValue()); } else if (event.getSource() instanceof BooleanFieldEditor) { - BooleanFieldEditor b = (BooleanFieldEditor)event.getSource(); + BooleanFieldEditor b = (BooleanFieldEditor) event.getSource(); cfg.setOption(b.getPreferenceName(), Boolean.toString(b.getBooleanValue())); } else if (event.getSource() instanceof VariableListEditor) { VariableListEditor v = (VariableListEditor) event.getSource(); cfg.setOption(v.getPreferenceName(), v.getVariablesValue()); } } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePrefStore.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePrefStore.java index 194ebffce19..4630aa371b9 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePrefStore.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePrefStore.java @@ -28,7 +28,7 @@ public class AutotoolsConfigurePrefStore implements IPreferenceStore { public final static String EMPTY_STRING = ""; public final static String ALL_OPTIONS_ID = EMPTY_STRING; - + private static AutotoolsConfigurePrefStore instance = null; private ToolListElement selectedElement; private IAConfiguration cfg; @@ -38,18 +38,18 @@ public class AutotoolsConfigurePrefStore implements IPreferenceStore { private AutotoolsConfigurePrefStore() { // private constructor } - + public static AutotoolsConfigurePrefStore getInstance() { if (instance == null) instance = new AutotoolsConfigurePrefStore(); return instance; } - + public void setSelection(IAConfiguration cfg, ToolListElement element) { this.cfg = cfg; selectedElement = element; } - + @Override public void addPropertyChangeListener(IPropertyChangeListener listener) { listenerList.add(listener); @@ -61,16 +61,13 @@ public class AutotoolsConfigurePrefStore implements IPreferenceStore { } @Override - public void firePropertyChangeEvent(String name, Object oldValue, - Object newValue) { + public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { Object[] listeners = listenerList.getListeners(); - if (listeners.length > 0 && (oldValue == null || !oldValue.equals(newValue))) - { + if (listeners.length > 0 && (oldValue == null || !oldValue.equals(newValue))) { PropertyChangeEvent pe = new PropertyChangeEvent(this, name, oldValue, newValue); - for (int i = 0; i < listeners.length; ++i) - { - IPropertyChangeListener l = (IPropertyChangeListener)listeners[i]; - l.propertyChange( pe ); + for (int i = 0; i < listeners.length; ++i) { + IPropertyChangeListener l = (IPropertyChangeListener) listeners[i]; + l.propertyChange(pe); } } } @@ -78,8 +75,8 @@ public class AutotoolsConfigurePrefStore implements IPreferenceStore { @Override public boolean getBoolean(String name) { IConfigureOption option = cfg.getOption(name); - if (option != null && (option.getType() == IConfigureOption.BIN || - option.getType() == IConfigureOption.FLAGVALUE)) { + if (option != null + && (option.getType() == IConfigureOption.BIN || option.getType() == IConfigureOption.FLAGVALUE)) { return Boolean.parseBoolean(option.getValue()); } // otherwise punt @@ -172,39 +169,50 @@ public class AutotoolsConfigurePrefStore implements IPreferenceStore { protected void setDirty(boolean isdirty) { this.isdirty = isdirty; } - + @Override - public void setDefault(String name, double value) {} + public void setDefault(String name, double value) { + } @Override - public void setDefault(String name, float value) {} + public void setDefault(String name, float value) { + } @Override - public void setDefault(String name, int value) {} + public void setDefault(String name, int value) { + } @Override - public void setDefault(String name, long value) {} + public void setDefault(String name, long value) { + } @Override - public void setDefault(String name, String defaultObject) {} + public void setDefault(String name, String defaultObject) { + } @Override - public void setDefault(String name, boolean value) {} + public void setDefault(String name, boolean value) { + } @Override - public void setToDefault(String name) {} + public void setToDefault(String name) { + } @Override - public void setValue(String name, double value) {} + public void setValue(String name, double value) { + } @Override - public void setValue(String name, float value) {} + public void setValue(String name, float value) { + } @Override - public void setValue(String name, int value) {} + public void setValue(String name, int value) { + } @Override - public void setValue(String name, long value) {} + public void setValue(String name, long value) { + } @Override public void setValue(String name, String value) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePropertyPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePropertyPage.java index e31ed118aef..219b1c43a5e 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePropertyPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePropertyPage.java @@ -22,12 +22,12 @@ import org.eclipse.cdt.ui.newui.AbstractPage; public class AutotoolsConfigurePropertyPage extends AbstractPage { private ICConfigurationDescription cfgd; - + @Override protected boolean isSingle() { return true; } - + /** * Default constructor */ @@ -38,7 +38,7 @@ public class AutotoolsConfigurePropertyPage extends AbstractPage { public ICConfigurationDescription getCfgd() { return cfgd; } - + public void getAllConfigurationData() { ICConfigurationDescription[] cfgds = getCfgsEditable(); for (int i = 0; i < cfgds.length; ++i) { @@ -48,11 +48,11 @@ public class AutotoolsConfigurePropertyPage extends AbstractPage { CConfigurationData data = cfgds[i].getConfigurationData(); } } - + public IAConfiguration getConfiguration(ICConfigurationDescription cfgd) { return AutotoolsConfigurationManager.getInstance().getTmpConfiguration(getProject(), cfgd); } - + @Override protected void cfgChanged(ICConfigurationDescription cfgd) { this.cfgd = cfgd; @@ -60,4 +60,3 @@ public class AutotoolsConfigurePropertyPage extends AbstractPage { super.cfgChanged(cfgd); } } - diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePropertyTab.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePropertyTab.java index 414ca2708c9..03a985a6636 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePropertyTab.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsConfigurePropertyTab.java @@ -67,47 +67,47 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab } private IAConfiguration getAutotoolsCfg() { - AutotoolsConfigurePropertyPage ap = (AutotoolsConfigurePropertyPage)page; + AutotoolsConfigurePropertyPage ap = (AutotoolsConfigurePropertyPage) page; // We call getConfigurationData() to get the name because if the configuration has been renamed, // it will cause the option value handler to clone the IAConfiguration return ap.getConfiguration(icfgd); } private void syncClones() { - AutotoolsConfigurePropertyPage ap = (AutotoolsConfigurePropertyPage)page; + AutotoolsConfigurePropertyPage ap = (AutotoolsConfigurePropertyPage) page; // We call getConfigurationData() to get the name because if the configuration has been renamed, // it will cause the option value handler to clone the IAConfiguration ap.getAllConfigurationData(); } - + @Override public IPreferenceStore getPreferenceStore() { return settingsStore; } - + @Override public void createControls(Composite parent) { AutotoolsConfigurationManager.getInstance().clearTmpConfigurations(page.getProject()); syncClones(); - + super.createControls(parent); - Composite composite= usercomp; - + Composite composite = usercomp; + settingsStore = AutotoolsConfigurePrefStore.getInstance(); configToPageListMap = new HashMap<>(); - + // assume parent page uses griddata - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL - | GridData.FILL_VERTICAL); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL + | GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); composite.setLayoutData(gd); - GridLayout layout= new GridLayout(); + GridLayout layout = new GridLayout(); composite.setLayout(layout); - + // Create the sash form sashForm = new SashForm(usercomp, SWT.NONE); sashForm.setOrientation(SWT.HORIZONTAL); sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); - + layout = new GridLayout(2, true); layout.marginHeight = 5; sashForm.setLayout(layout); @@ -116,7 +116,7 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab } private void createSelectionArea(Composite parent) { - fTree = new TreeViewer(parent, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER); + fTree = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); fTree.addSelectionChangedListener(event -> handleOptionSelection()); fTree.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); // Create a temporary default AutotoolsConfiguration to use for label info @@ -128,29 +128,28 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); containerSC.setExpandHorizontal(true); containerSC.setExpandVertical(true); - + // Add a container for the build settings page settingsPageContainer = new Composite(containerSC, SWT.NONE); settingsPageContainer.setLayout(new PageLayout()); containerSC.setContent(settingsPageContainer); -// containerSC.setMinSize(settingsPageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT)); + // containerSC.setMinSize(settingsPageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT)); settingsPageContainer.layout(); } - + private void setValues() { /* * This method updates the context of the build property pages * - Which configuration/resource configuration is selected * - Which tool/option category is selected - * + * * It is called: * - When a property page becomes visible * - When the user changes the configuration selection * - When the user changes the "exclude" setting for a resource */ - - + IConfiguration icfg = getCfg(icfgd.getConfiguration()); if (icfg instanceof IMultiConfiguration) { fTree.setInput(null); @@ -160,7 +159,7 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab } IAConfiguration currCfg = getAutotoolsCfg(); - + // Create the Tree Viewer content provider if first time if (listprovider == null) { listprovider = new ToolListContentProvider(); @@ -169,22 +168,23 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab // Update the selected configuration and the Tree Viewer ToolListElement[] newElements; - + fTree.setInput(currCfg); fTree.getControl().setEnabled(true); - newElements = (ToolListElement[])listprovider.getElements(currCfg); + newElements = (ToolListElement[]) listprovider.getElements(currCfg); fTree.expandAll(); - + selectedElement = newElements[0]; fTree.setSelection(new StructuredSelection(selectedElement), true); - + } private void handleOptionSelection() { // Get the selection from the tree list - if (fTree == null) return; + if (fTree == null) + return; IStructuredSelection selection = (IStructuredSelection) fTree.getSelection(); - ToolListElement element = (ToolListElement)selection.getFirstElement(); + ToolListElement element = (ToolListElement) selection.getFirstElement(); if (element != null) { displayPageForElement(element); } @@ -193,21 +193,21 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab if (sb != null && sb.isVisible()) { settingsPageContainer.pack(true); containerSC.setMinSize(settingsPageContainer.getSize()); - ((AbstractPage)page).resize(); + ((AbstractPage) page).resize(); } } private void displayPageForElement(ToolListElement element) { selectedElement = element; settingsStore.setSelection(getAutotoolsCfg(), selectedElement); - + AbstractConfigurePropertyOptionsPage oldPage = currentSettingsPage; currentSettingsPage = null; // Create a new settings page if necessary List<AbstractConfigurePropertyOptionsPage> pages = getPagesForConfig(); ListIterator<AbstractConfigurePropertyOptionsPage> iter = pages.listIterator(); - + while (iter.hasNext()) { AbstractConfigurePropertyOptionsPage page = iter.next(); if (page.getName().equals(element.getName())) { @@ -217,12 +217,9 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab } if (currentSettingsPage == null) { if (element.getType() == IConfigureOption.TOOL) { - currentSettingsPage = new AutotoolsToolPropertyOptionPage( - element, getAutotoolsCfg()); - } - else { - currentSettingsPage = new AutotoolsCategoryPropertyOptionPage( - element, getAutotoolsCfg()); + currentSettingsPage = new AutotoolsToolPropertyOptionPage(element, getAutotoolsCfg()); + } else { + currentSettingsPage = new AutotoolsCategoryPropertyOptionPage(element, getAutotoolsCfg()); } pages.add(currentSettingsPage); currentSettingsPage.setContainer(this); @@ -230,7 +227,7 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab currentSettingsPage.createControl(settingsPageContainer); } } - + // Make all the other pages invisible Control[] children = settingsPageContainer.getChildren(); Control currentControl = currentSettingsPage.getControl(); @@ -240,33 +237,34 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab } currentSettingsPage.setVisible(true); currentSettingsPage.updateFields(); - - if (oldPage != null && oldPage != currentSettingsPage) + + if (oldPage != null && oldPage != currentSettingsPage) oldPage.setVisible(false); // Set the size of the scrolled area containerSC.setMinSize(currentSettingsPage.computeSize()); settingsPageContainer.layout(); - + } /** * Answers the list of settings pages for the selected configuration */ private List<AbstractConfigurePropertyOptionsPage> getPagesForConfig() { - if (getCfg() == null) return null; + if (getCfg() == null) + return null; List<AbstractConfigurePropertyOptionsPage> pages = configToPageListMap.get(getCfg().getName()); if (pages == null) { pages = new ArrayList<>(); - configToPageListMap.put(getCfg().getName(), pages); + configToPageListMap.put(getCfg().getName(), pages); } return pages; } - + @Override protected void performOK() { ICConfigurationDescription[] cfgs = page.getCfgsEditable(); - AutotoolsConfigurePropertyPage ap = (AutotoolsConfigurePropertyPage)page; + AutotoolsConfigurePropertyPage ap = (AutotoolsConfigurePropertyPage) page; Map<String, IAConfiguration> cfgList = new HashMap<>(); for (int i = 0; i < cfgs.length; ++i) { ICConfigurationDescription cd = cfgs[i]; @@ -277,12 +275,12 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab AutotoolsConfigurationManager.getInstance().replaceProjectConfigurations(project, cfgList, cfgs); AutotoolsConfigurationManager.getInstance().clearTmpConfigurations(project); } - + @Override protected void performCancel() { AutotoolsConfigurationManager.getInstance().clearTmpConfigurations(page.getProject()); } - + @Override protected void performApply(ICResourceDescription src, ICResourceDescription dst) { IProject project = page.getProject(); @@ -291,26 +289,32 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab // deletions. AutotoolsConfigurationManager.getInstance().applyConfigs(project.getName(), cfgs); } - + @Override protected void performDefaults() { IAConfiguration cfg = getAutotoolsCfg(); cfg.setDefaultOptions(); setValues(); } - + @Override protected void updateData(ICResourceDescription rd) { - if (rd == null) return; + if (rd == null) + return; icfgd = rd.getConfiguration(); setValues(); } - + // IPreferencePageContainer methods @Override - public void updateButtons() {} + public void updateButtons() { + } + @Override - public void updateMessage() {} + public void updateMessage() { + } + @Override - public void updateTitle() {} + public void updateTitle() { + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsEditorPropertyTab.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsEditorPropertyTab.java index 1aced2e73bb..72d2963bc60 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsEditorPropertyTab.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsEditorPropertyTab.java @@ -27,7 +27,6 @@ import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; - public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab { protected Combo fACVersionCombo; @@ -42,43 +41,43 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab { @Override public void createControls(Composite parent) { super.createControls(parent); - Composite composite= usercomp; - + Composite composite = usercomp; + // assume parent page uses griddata - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL); composite.setLayoutData(gd); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; + GridLayout layout = new GridLayout(); + layout.numColumns = 2; //PixelConverter pc= new PixelConverter(composite); //layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2; composite.setLayout(layout); - + project = page.getProject(); - + /* check box for new editors */ - fACVersionCombo= new Combo(composite, SWT.CHECK | SWT.DROP_DOWN | SWT.READ_ONLY); + fACVersionCombo = new Combo(composite, SWT.CHECK | SWT.DROP_DOWN | SWT.READ_ONLY); fACVersionCombo.setItems(AutotoolsPropertyConstants.fACVersions); fACVersionCombo.select(AutotoolsPropertyConstants.fACVersions.length - 1); - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); + gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fACVersionCombo.setLayoutData(gd); - - Label label= new Label(composite, SWT.LEFT); + + Label label = new Label(composite, SWT.LEFT); label.setText(AutotoolsPropertyMessages.getString("ACEditor.autoconfVersion")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label.setLayoutData(gd); - + /* check box for new editors */ - fAMVersionCombo= new Combo(composite, SWT.CHECK | SWT.DROP_DOWN | SWT.READ_ONLY); + fAMVersionCombo = new Combo(composite, SWT.CHECK | SWT.DROP_DOWN | SWT.READ_ONLY); fAMVersionCombo.setItems(AutotoolsPropertyConstants.fAMVersions); fAMVersionCombo.select(AutotoolsPropertyConstants.fAMVersions.length - 1); - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); + gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); fAMVersionCombo.setLayoutData(gd); - - Label label2= new Label(composite, SWT.LEFT); + + Label label2 = new Label(composite, SWT.LEFT); label2.setText(AutotoolsPropertyMessages.getString("ACEditor.automakeVersion")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label2.setLayoutData(gd); initialize(); @@ -101,7 +100,8 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab { if (!acVerSelected.equals(acVer)) { changed = true; try { - project.setPersistentProperty(AutotoolsPropertyConstants.AUTOCONF_VERSION, fACVersionCombo.getItem(index)); + project.setPersistentProperty(AutotoolsPropertyConstants.AUTOCONF_VERSION, + fACVersionCombo.getItem(index)); } catch (CoreException ce) { // Not much we can do at this point } @@ -112,7 +112,8 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab { if (!amVerSelected.equals(amVer)) { changed = true; try { - project.setPersistentProperty(AutotoolsPropertyConstants.AUTOMAKE_VERSION, fAMVersionCombo.getItem(index)); + project.setPersistentProperty(AutotoolsPropertyConstants.AUTOMAKE_VERSION, + fAMVersionCombo.getItem(index)); } catch (CoreException ce) { // Not much we can do here either } @@ -121,19 +122,21 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab { // Notify any Autoconf editors that are open for this project that macro versioning // has changed. if (changed) - AutotoolsPropertyManager.getDefault().notifyPropertyListeners(project, AutotoolsPropertyConstants.AUTOCONF_MACRO_VERSIONING); + AutotoolsPropertyManager.getDefault().notifyPropertyListeners(project, + AutotoolsPropertyConstants.AUTOCONF_MACRO_VERSIONING); } - + @Override protected void performApply(ICResourceDescription src, ICResourceDescription dst) { performOK(); } - + @Override public void performDefaults() { // For default Autoconf and Automake versions, use the setting from the // Autotools preference dialog. - String version = AutotoolsPlugin.getDefault().getPreferenceStore().getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION); + String version = AutotoolsPlugin.getDefault().getPreferenceStore() + .getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION); String[] items = fACVersionCombo.getItems(); // Try and find which list item matches the current preference stored and // select it in the list. @@ -146,7 +149,8 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab { i = items.length - 1; fACVersionCombo.select(i); - version = AutotoolsPlugin.getDefault().getPreferenceStore().getString(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION); + version = AutotoolsPlugin.getDefault().getPreferenceStore() + .getString(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION); items = fAMVersionCombo.getItems(); // Try and find which list item matches the current preference stored and // select it in the list @@ -158,12 +162,12 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab { i = items.length - 1; fAMVersionCombo.select(i); } - + @Override public void updateData(ICResourceDescription cfgd) { // Nothing to do } - + @Override public void updateButtons() { // Nothing to do @@ -173,13 +177,14 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab { initializeACVersion(); initializeAMVersion(); } - + void initializeACVersion() { String version = ""; try { version = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOCONF_VERSION); if (version == null) - version = AutotoolsPlugin.getDefault().getPreferenceStore().getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION); + version = AutotoolsPlugin.getDefault().getPreferenceStore() + .getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION); } catch (CoreException e) { // do nothing } @@ -195,13 +200,14 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab { i = items.length - 1; fACVersionCombo.select(i); } - + void initializeAMVersion() { String version = ""; try { version = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOMAKE_VERSION); if (version == null) - version = AutotoolsPlugin.getDefault().getPreferenceStore().getString(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION); + version = AutotoolsPlugin.getDefault().getPreferenceStore() + .getString(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION); } catch (CoreException e) { // do nothing } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsGeneralPropertyPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsGeneralPropertyPage.java index 144beccddf4..26f44999ad1 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsGeneralPropertyPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsGeneralPropertyPage.java @@ -18,8 +18,10 @@ public class AutotoolsGeneralPropertyPage extends AbstractPage { protected boolean isSingle() { return false; } - + @Override - protected boolean showsConfig() { return false; } + protected boolean showsConfig() { + return false; + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsHeadPropertyPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsHeadPropertyPage.java index 9d23736b606..8d2d6a2f34d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsHeadPropertyPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsHeadPropertyPage.java @@ -20,6 +20,8 @@ public class AutotoolsHeadPropertyPage extends AbstractPage { } @Override - protected boolean showsConfig() { return false; } + protected boolean showsConfig() { + return false; + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsPropertyManager.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsPropertyManager.java index 9e2a4107fd3..3f19a7112a7 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsPropertyManager.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsPropertyManager.java @@ -23,20 +23,19 @@ public class AutotoolsPropertyManager implements IPropertyChangeManager { private static volatile AutotoolsPropertyManager fInstance; private Map<IProject, ListenerList<IProjectPropertyListener>> projectList; - + private AutotoolsPropertyManager() { projectList = new HashMap<>(); } - + public static AutotoolsPropertyManager getDefault() { if (fInstance == null) fInstance = new AutotoolsPropertyManager(); return fInstance; } - + @Override - public synchronized void addProjectPropertyListener(IProject project, - IProjectPropertyListener listener) { + public synchronized void addProjectPropertyListener(IProject project, IProjectPropertyListener listener) { ListenerList<IProjectPropertyListener> list = projectList.get(project); if (list == null) { list = new ListenerList<>(); @@ -51,14 +50,13 @@ public class AutotoolsPropertyManager implements IPropertyChangeManager { if (list != null) { Object[] listeners = list.getListeners(); for (int i = 0; i < listeners.length; ++i) { - ((IProjectPropertyListener)listeners[i]).handleProjectPropertyChanged(project, property); + ((IProjectPropertyListener) listeners[i]).handleProjectPropertyChanged(project, property); } } } @Override - public synchronized void removeProjectPropertyListener(IProject project, - IProjectPropertyListener listener) { + public synchronized void removeProjectPropertyListener(IProject project, IProjectPropertyListener listener) { ListenerList<IProjectPropertyListener> list = projectList.get(project); if (list != null) list.remove(listener); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsPropertyMessages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsPropertyMessages.java index df2ff9ae412..5d6b203977a 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsPropertyMessages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsPropertyMessages.java @@ -23,7 +23,7 @@ import java.util.ResourceBundle; public class AutotoolsPropertyMessages { /** - * + * */ private AutotoolsPropertyMessages() { } @@ -38,6 +38,6 @@ public class AutotoolsPropertyMessages { } catch (NullPointerException e) { return '#' + key + '#'; } - } + } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsToolPropertyOptionPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsToolPropertyOptionPage.java index 97997d56af0..c982fc7969f 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsToolPropertyOptionPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsToolPropertyOptionPage.java @@ -26,17 +26,16 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; -public class AutotoolsToolPropertyOptionPage extends - AbstractConfigurePropertyOptionsPage { +public class AutotoolsToolPropertyOptionPage extends AbstractConfigurePropertyOptionsPage { private static final int MARGIN = 3; private String toolName = ""; private IAConfiguration cfg; - + public AutotoolsToolPropertyOptionPage(ToolListElement element, IAConfiguration cfg) { - super(element.getName()); - this.toolName = element.getName(); - this.cfg = cfg; + super(element.getName()); + this.toolName = element.getName(); + this.cfg = cfg; } @Override @@ -53,11 +52,9 @@ public class AutotoolsToolPropertyOptionPage extends area.setLayout(gl); area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); FontMetrics fm = AbstractCPropertyTab.getFontMetrics(area); - commandStringField = new StringFieldEditor(toolName, - ConfigureMessages.getString(COMMAND), - area); + commandStringField = new StringFieldEditor(toolName, ConfigureMessages.getString(COMMAND), area); commandStringField.setEmptyStringAllowed(false); - GridData gd = ((GridData)commandStringField.getTextControl(area).getLayoutData()); + GridData gd = ((GridData) commandStringField.getTextControl(area).getLayoutData()); gd.grabExcessHorizontalSpace = true; gd.minimumWidth = Dialog.convertWidthInCharsToPixels(fm, 3); addField(commandStringField); @@ -65,7 +62,7 @@ public class AutotoolsToolPropertyOptionPage extends allOptionFieldEditor = new MultiLineTextFieldEditor(AutotoolsConfigurePrefStore.ALL_OPTIONS_ID, ConfigureMessages.getString(ALL_OPTIONS), area); allOptionFieldEditor.getTextControl(area).setEditable(false); -// gd = ((GridData)allOptionFieldEditor.getTextControl().getLayoutData()); + // gd = ((GridData)allOptionFieldEditor.getTextControl().getLayoutData()); gd.grabExcessHorizontalSpace = true; gd.minimumWidth = Dialog.convertWidthInCharsToPixels(fm, 20); addField(allOptionFieldEditor); @@ -87,22 +84,22 @@ public class AutotoolsToolPropertyOptionPage extends public void updateFields() { allOptionFieldEditor.load(); } - + @Override - public void setValues(){ + public void setValues() { commandStringField.load(); updateFields(); } - + @Override public void propertyChange(PropertyChangeEvent event) { // allow superclass to handle as well super.propertyChange(event); - if(event.getSource() == commandStringField){ + if (event.getSource() == commandStringField) { cfg.setOption(toolName, commandStringField.getStringValue()); updateFields(); } } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsToolsPropertyTab.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsToolsPropertyTab.java index 6a7fa3c8fdb..39931cc1419 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsToolsPropertyTab.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/AutotoolsToolsPropertyTab.java @@ -33,7 +33,7 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { public static final String DEFAULT_AUTOHEADER = "autoheader"; //$NON-NLS-1$ public static final String DEFAULT_AUTORECONF = "autoreconf"; //$NON-NLS-1$ public static final String DEFAULT_LIBTOOLIZE = "libtoolize"; //$NON-NLS-1$ - + protected Text fAclocalPath; protected Text fAutomakePath; protected Text fAutoconfPath; @@ -42,11 +42,10 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { protected Text fLibtoolizePath; private IProject project; - private IProject getProject() { return page.getProject(); } - + @Override public boolean canBeVisible() { return true; @@ -55,89 +54,96 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { @Override public void createControls(Composite parent) { super.createControls(parent); - Composite composite= usercomp; - + Composite composite = usercomp; + // assume parent page uses griddata - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL); + GridData gd = new GridData( + GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL); composite.setLayoutData(gd); - GridLayout layout= new GridLayout(); - layout.numColumns= 2; + GridLayout layout = new GridLayout(); + layout.numColumns = 2; //PixelConverter pc= new PixelConverter(composite); //layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2; composite.setLayout(layout); - + project = getProject(); - - Label label= new Label(composite, SWT.LEFT); + + Label label = new Label(composite, SWT.LEFT); label.setText(AutotoolsPropertyMessages.getString("Autotools.aclocalPath")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label.setLayoutData(gd); - + /* text window for aclocal path */ fAclocalPath = new Text(composite, SWT.BORDER | SWT.SINGLE); fAclocalPath.setToolTipText(AutotoolsPropertyMessages.getString("Autotools.aclocalPath.tooltip")); //$NON-NLS-1$ - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); + gd = new GridData( + GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); fAclocalPath.setLayoutData(gd); - - Label label2= new Label(composite, SWT.LEFT); + + Label label2 = new Label(composite, SWT.LEFT); label2.setText(AutotoolsPropertyMessages.getString("Autotools.automakePath")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label2.setLayoutData(gd); - + /* text window for automake path */ fAutomakePath = new Text(composite, SWT.BORDER | SWT.SINGLE); fAutomakePath.setToolTipText(AutotoolsPropertyMessages.getString("Autotools.automakePath.tooltip")); //$NON-NLS-1# - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); + gd = new GridData( + GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); fAutomakePath.setLayoutData(gd); - + Label label3 = new Label(composite, SWT.LEFT); label3.setText(AutotoolsPropertyMessages.getString("Autotools.autoconfPath")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label3.setLayoutData(gd); - + /* text window for autoconf path */ fAutoconfPath = new Text(composite, SWT.BORDER | SWT.SINGLE); fAutoconfPath.setToolTipText(AutotoolsPropertyMessages.getString("Autotools.autoconfPath.tooltip")); //$NON-NLS-1$ - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); + gd = new GridData( + GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); fAutoconfPath.setLayoutData(gd); - Label label4= new Label(composite, SWT.LEFT); + Label label4 = new Label(composite, SWT.LEFT); label4.setText(AutotoolsPropertyMessages.getString("Autotools.autoheaderPath")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label4.setLayoutData(gd); - + /* text window for autoheader path */ fAutoheaderPath = new Text(composite, SWT.BORDER | SWT.SINGLE); fAutoheaderPath.setToolTipText(AutotoolsPropertyMessages.getString("Autotools.autoheaderPath.tooltip")); //$NON-NLS-1$ - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); + gd = new GridData( + GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); fAutoheaderPath.setLayoutData(gd); - Label label5= new Label(composite, SWT.LEFT); + Label label5 = new Label(composite, SWT.LEFT); label5.setText(AutotoolsPropertyMessages.getString("Autotools.autoreconfPath")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label5.setLayoutData(gd); - + /* text window for autoreconf path */ fAutoreconfPath = new Text(composite, SWT.BORDER | SWT.SINGLE); fAutoreconfPath.setToolTipText(AutotoolsPropertyMessages.getString("Autotools.autoreconfPath.tooltip")); //$NON-NLS-1$ - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); + gd = new GridData( + GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); fAutoreconfPath.setLayoutData(gd); - Label label6= new Label(composite, SWT.LEFT); + Label label6 = new Label(composite, SWT.LEFT); label6.setText(AutotoolsPropertyMessages.getString("Autotools.libtoolizePath")); //$NON-NLS-1$ - gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; label6.setLayoutData(gd); - + /* text window for libtoolize path */ fLibtoolizePath = new Text(composite, SWT.BORDER | SWT.SINGLE); fLibtoolizePath.setToolTipText(AutotoolsPropertyMessages.getString("Autotools.libtoolizePath.tooltip")); //$NON-NLS-1$ - gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); + gd = new GridData( + GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); fLibtoolizePath.setLayoutData(gd); initialize(); @@ -165,7 +171,7 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { // Not much we can do at this point } } - + try { automakePath = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOMAKE_TOOL); } catch (CoreException e1) { @@ -180,7 +186,7 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { // Not much we can do at this point } } - + try { autoconfPath = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOCONF_TOOL); } catch (CoreException e1) { @@ -225,7 +231,7 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { // Not much we can do at this point } } - + try { libtoolizePath = project.getPersistentProperty(AutotoolsPropertyConstants.LIBTOOLIZE_TOOL); } catch (CoreException e1) { @@ -241,12 +247,12 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { } } } - + @Override protected void performApply(ICResourceDescription src, ICResourceDescription dst) { performOK(); } - + @Override public void performDefaults() { // For default tool settings, simply default the base tool names @@ -257,12 +263,12 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { fAutoreconfPath.setText(DEFAULT_AUTORECONF); fLibtoolizePath.setText(DEFAULT_LIBTOOLIZE); } - + @Override public void updateData(ICResourceDescription cfgd) { // Nothing to do } - + @Override public void updateButtons() { // Nothing to do @@ -275,38 +281,38 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { String autoheaderPath = null; String autoreconfPath = null; String libtoolizePath = null; - + try { aclocalPath = project.getPersistentProperty(AutotoolsPropertyConstants.ACLOCAL_TOOL); } catch (CoreException e1) { // do nothing } - + if (aclocalPath == null) aclocalPath = DEFAULT_ACLOCAL; - + fAclocalPath.setText(aclocalPath); - + try { automakePath = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOMAKE_TOOL); } catch (CoreException e1) { // do nothing } - + if (automakePath == null) automakePath = DEFAULT_AUTOMAKE; - + fAutomakePath.setText(automakePath); - + try { autoconfPath = project.getPersistentProperty(AutotoolsPropertyConstants.AUTOCONF_TOOL); } catch (CoreException e1) { // do nothing } - + if (autoconfPath == null) autoconfPath = DEFAULT_AUTOCONF; - + fAutoconfPath.setText(autoconfPath); try { @@ -314,10 +320,10 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { } catch (CoreException e1) { // do nothing } - + if (autoheaderPath == null) autoheaderPath = DEFAULT_AUTOHEADER; - + fAutoheaderPath.setText(autoheaderPath); try { @@ -325,10 +331,10 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { } catch (CoreException e1) { // do nothing } - + if (autoreconfPath == null) autoreconfPath = DEFAULT_AUTORECONF; - + fAutoreconfPath.setText(autoreconfPath); try { @@ -336,11 +342,11 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab { } catch (CoreException e1) { // do nothing } - + if (libtoolizePath == null) libtoolizePath = DEFAULT_LIBTOOLIZE; - + fLibtoolizePath.setText(libtoolizePath); } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/IProjectPropertyListener.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/IProjectPropertyListener.java index c1cd3fb6840..d1ed4deee31 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/IProjectPropertyListener.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/IProjectPropertyListener.java @@ -19,10 +19,10 @@ public interface IProjectPropertyListener { /** * Handler for property changes - * + * * @param project the project to which the property changed * @param property the name of the property changed */ void handleProjectPropertyChanged(IProject project, String property); - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/IPropertyChangeManager.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/IPropertyChangeManager.java index d63c30f6985..1f257e76e87 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/IPropertyChangeManager.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/IPropertyChangeManager.java @@ -19,25 +19,25 @@ public interface IPropertyChangeManager { /** * Add a project property listener for given project. - * + * * @param project the project to which the listener is interested * @param listener the listener to notify */ void addProjectPropertyListener(IProject project, IProjectPropertyListener listener); - + /** * Remove a project property listener. - * + * * @param listener the listener to remove */ void removeProjectPropertyListener(IProject project, IProjectPropertyListener listener); - + /** * Notify all listeners of project that a property has changed. - * + * * @param project the project for which the property has changed * @param property the property that has changed */ void notifyPropertyListeners(IProject project, String property); - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListContentProvider.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListContentProvider.java index bc3107b7a35..e127fafd03a 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListContentProvider.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListContentProvider.java @@ -23,7 +23,7 @@ import org.eclipse.jface.viewers.Viewer; public class ToolListContentProvider implements ITreeContentProvider { private ToolListElement[] elements; - + private ToolListElement[] createElements() { ArrayList<ToolListElement> toolList = new ArrayList<>(); AutotoolsConfiguration.Option[] options = AutotoolsConfiguration.getTools(); @@ -32,8 +32,7 @@ public class ToolListContentProvider implements ITreeContentProvider { String optName = opt.getName(); ToolListElement tool = new ToolListElement(optName, IConfigureOption.TOOL); toolList.add(tool); - AutotoolsConfiguration.Option[] categories = - AutotoolsConfiguration.getChildOptions(optName); + AutotoolsConfiguration.Option[] categories = AutotoolsConfiguration.getChildOptions(optName); for (int j = 0; j < categories.length; ++j) { String catName = categories[j].getName(); ToolListElement newItem = new ToolListElement(catName, IConfigureOption.CATEGORY); @@ -42,23 +41,23 @@ public class ToolListContentProvider implements ITreeContentProvider { } return toolList.toArray(new ToolListElement[toolList.size()]); } - + @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof AutotoolsConfiguration) { return elements.clone(); } - return ((ToolListElement)parentElement).getChildren(); + return ((ToolListElement) parentElement).getChildren(); } @Override public Object getParent(Object element) { - return ((ToolListElement)element).getParent(); + return ((ToolListElement) element).getParent(); } @Override public boolean hasChildren(Object element) { - return ((ToolListElement)element).hasChildren(); + return ((ToolListElement) element).hasChildren(); } @Override diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListElement.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListElement.java index e28d5968d31..f6ac847665f 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListElement.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListElement.java @@ -17,43 +17,43 @@ import java.util.ArrayList; import java.util.List; public class ToolListElement { - + private List<ToolListElement> children; private ToolListElement parent; private String name; private int type; - + public ToolListElement(String name, int type) { this.name = name; this.type = type; this.children = new ArrayList<>(); } - + public void setParent(ToolListElement p) { parent = p; } - + public ToolListElement getParent() { return parent; } - + public String getName() { return name; } - + public int getType() { return type; } - + public void addChild(ToolListElement e) { children.add(e); e.setParent(this); } - + public boolean hasChildren() { return children.size() > 0; } - + public Object[] getChildren() { return children.toArray(); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListLabelProvider.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListLabelProvider.java index 67f555fd4bd..2522184b653 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListLabelProvider.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/properties/ToolListLabelProvider.java @@ -22,42 +22,42 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ResourceManager; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; - + public class ToolListLabelProvider extends LabelProvider { private final Image IMG_TOOL = AutotoolsUIPluginImages.get(AutotoolsUIPluginImages.IMG_CFG_TOOL); private final Image IMG_CAT = AutotoolsUIPluginImages.get(AutotoolsUIPluginImages.IMG_CFG_CATEGORY); - private static final String ERROR_UNKNOWN_ELEMENT = "ConfigurePropertyPage.error.Unknown_tree_element"; //$NON-NLS-1$ + private static final String ERROR_UNKNOWN_ELEMENT = "ConfigurePropertyPage.error.Unknown_tree_element"; //$NON-NLS-1$ private ImageDescriptor descriptor = null; private ResourceManager manager = null; private IAConfiguration cfg = null; - + public ToolListLabelProvider(IAConfiguration cfg) { this.cfg = cfg; } - + public IAConfiguration getCfg() { return cfg; } - + public void setCfg(IAConfiguration cfg) { this.cfg = cfg; } - + @Override public Image getImage(Object element) { if (!(element instanceof ToolListElement)) { throw unknownElement(element); } Image defaultImage = IMG_CAT; - ToolListElement toolListElement = (ToolListElement)element; + ToolListElement toolListElement = (ToolListElement) element; IConfigureOption cat = cfg.getOption(toolListElement.getName()); - + if (cat == null) { defaultImage = IMG_TOOL; } - - // Use default icon for display + + // Use default icon for display return defaultImage; } @@ -66,13 +66,12 @@ public class ToolListLabelProvider extends LabelProvider { if (!(element instanceof ToolListElement)) { throw unknownElement(element); } - ToolListElement toolListElement = (ToolListElement)element; + ToolListElement toolListElement = (ToolListElement) element; IConfigureOption cat = cfg.getOption(toolListElement.getName()); - + if (cat == null) { return toolListElement.getName(); - } - else { + } else { return cat.getDescription(); } } @@ -81,15 +80,15 @@ public class ToolListLabelProvider extends LabelProvider { return new RuntimeException(UIMessages.getFormattedString(ERROR_UNKNOWN_ELEMENT, element.getClass().getName())); } - /** - * Disposing any images that were allocated for it. - * - * @since 3.0 - */ - @Override + /** + * Disposing any images that were allocated for it. + * + * @since 3.0 + */ + @Override public void dispose() { - if (descriptor != null && manager != null) { - manager.destroyImage(descriptor); - } - }; + if (descriptor != null && manager != null) { + manager.destroyImage(descriptor); + } + }; } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfPrototype.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfPrototype.java index a287239e714..6a11736264d 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfPrototype.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfPrototype.java @@ -22,46 +22,46 @@ public class AutoconfPrototype { protected List<Integer> minParms; protected List<Integer> maxParms; protected List<List<String>> parmList; - + public AutoconfPrototype() { numPrototypes = 0; minParms = new ArrayList<>(); maxParms = new ArrayList<>(); parmList = new ArrayList<>(); } - + public String getName() { return name; } - + public void setName(String newName) { name = newName; } - + public int getNumPrototypes() { return numPrototypes; } - + public void setNumPrototypes(int num) { numPrototypes = num; } - + public int getMinParms(int prototypeNum) { return minParms.get(prototypeNum).intValue(); } - + public void setMinParms(int prototypeNum, int value) { minParms.add(prototypeNum, Integer.valueOf(value)); } - + public int getMaxParms(int prototypeNum) { return maxParms.get(prototypeNum).intValue(); } - + public void setMaxParms(int prototypeNum, int value) { maxParms.add(prototypeNum, Integer.valueOf(value)); } - + public String getParmName(int prototypeNum, int parmNum) { List<String> parms = parmList.get(prototypeNum); return parms.get(parmNum); @@ -74,13 +74,12 @@ public class AutoconfPrototype { if (parmList.size() == prototypeNum) { parms = new ArrayList<>(); parmList.add(parms); - } - else + } else parms = parmList.get(prototypeNum); if (parms.size() == parmNum) - parms.add(value); + parms.add(value); else parms.set(parmNum, value); } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfTextHover.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfTextHover.java index 6bfd9673450..341c267d8e3 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfTextHover.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/AutoconfTextHover.java @@ -71,7 +71,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; - public class AutoconfTextHover implements ITextHover, ITextHoverExtension { public static final String LOCAL_AUTOCONF_MACROS_DOC_NAME = "macros/acmacros"; @@ -81,16 +80,20 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { private static class AutotoolsHoverDoc { public Document[] documents = new Document[2]; + public AutotoolsHoverDoc(Document acDocument, Document amDocument) { this.documents[0] = acDocument; this.documents[1] = amDocument; } + public Document getAcDocument() { return documents[0]; } + public Document getAmDocument() { return documents[1]; } + public Document[] getDocuments() { return documents; } @@ -106,37 +109,35 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { private static IBindingService fBindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class); public static String getAutoconfMacrosDocName(String version) { - return AUTOCONF_MACROS_DOC_NAME + "-" //$NON-NLS-1$ - + version - + ".xml"; //$NON-NLS-1$ + return AUTOCONF_MACROS_DOC_NAME + "-" //$NON-NLS-1$ + + version + ".xml"; //$NON-NLS-1$ } public static String getLocalAutoconfMacrosDocName(String version) { - return LOCAL_AUTOCONF_MACROS_DOC_NAME + "-" //$NON-NLS-1$ - + version - + ".xml"; //$NON-NLS-1$ + return LOCAL_AUTOCONF_MACROS_DOC_NAME + "-" //$NON-NLS-1$ + + version + ".xml"; //$NON-NLS-1$ } /* Get the preferences default for the autoconf macros document name. */ public static String getDefaultAutoconfMacrosVer() { - return AutotoolsPlugin.getDefault().getPreferenceStore().getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION); + return AutotoolsPlugin.getDefault().getPreferenceStore() + .getString(AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION); } public static String getAutomakeMacrosDocName(String version) { - return AUTOMAKE_MACROS_DOC_NAME + "-" //$NON-NLS-1$ - + version - + ".xml"; //$NON-NLS-1$ + return AUTOMAKE_MACROS_DOC_NAME + "-" //$NON-NLS-1$ + + version + ".xml"; //$NON-NLS-1$ } - + public static String getLocalAutomakeMacrosDocName(String version) { - return LOCAL_AUTOMAKE_MACROS_DOC_NAME + "-" //$NON-NLS-1$ - + version - + ".xml"; //$NON-NLS-1$ + return LOCAL_AUTOMAKE_MACROS_DOC_NAME + "-" //$NON-NLS-1$ + + version + ".xml"; //$NON-NLS-1$ } - + /* Get the preferences default for the autoconf macros document name. */ public static String getDefaultAutomakeMacrosVer() { - return AutotoolsPlugin.getDefault().getPreferenceStore().getString(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION); + return AutotoolsPlugin.getDefault().getPreferenceStore() + .getString(AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION); } protected static Document getACDoc(String acDocVer) { @@ -178,18 +179,17 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { if (docStream != null) docStream.close(); } - } catch (FileNotFoundException|MalformedURLException|URISyntaxException e) { + } catch (FileNotFoundException | MalformedURLException | URISyntaxException e) { AutotoolsPlugin.log(e); } acDocument = doc; - } - catch (IOException ioe) { + } catch (IOException ioe) { } } acHoverDocs.put(acDocVer, acDocument); return acDocument; } - + protected static Document getAMDoc(String amDocVer) { Document amDocument = null; if (amHoverDocs == null) { @@ -229,12 +229,11 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { if (docStream != null) docStream.close(); } - } catch (FileNotFoundException|MalformedURLException|URISyntaxException e) { + } catch (FileNotFoundException | MalformedURLException | URISyntaxException e) { AutotoolsPlugin.log(e); } amDocument = doc; - } - catch (IOException ioe) { + } catch (IOException ioe) { } } amHoverDocs.put(amDocVer, amDocument); @@ -245,7 +244,7 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { String acDocVer = getDefaultAutoconfMacrosVer(); String amDocVer = getDefaultAutomakeMacrosVer(); if (input instanceof IFileEditorInput) { - IFileEditorInput fe = (IFileEditorInput)input; + IFileEditorInput fe = (IFileEditorInput) input; IFile f = fe.getFile(); IProject p = f.getProject(); try { @@ -328,7 +327,7 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { } buffer.append(prototype).append("</I>)<br>"); //$NON-NLS-1$ } - if (nodeName.equals("synopsis")) { //$NON-NLS-1$ + if (nodeName.equals("synopsis")) { //$NON-NLS-1$ Node textNode = n.getLastChild(); buffer.append("<br><B>Synopsis:</B> "); buffer.append(textNode.getNodeValue()); @@ -344,13 +343,13 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { return null; } - + public static AutoconfMacro[] getMacroList(AutoconfEditor editor) { IEditorInput input = editor.getEditorInput(); AutotoolsHoverDoc hoverdoc = getHoverDoc(input); return getMacroList(hoverdoc); } - + private static AutoconfMacro[] getMacroList(AutotoolsHoverDoc hoverdoc) { if (acHoverMacros == null) { acHoverMacros = new HashMap<>(); @@ -433,7 +432,7 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { ++prototypeCount; int parmCount = 0; int minParmCount = -1; - p.setNumPrototypes(prototypeCount + 1); + p.setNumPrototypes(prototypeCount + 1); NodeList varList = n.getChildNodes(); for (int j = 0; j < varList.getLength(); ++j) { Node v = varList.item(j); @@ -445,9 +444,8 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { String parm = parmNode.getNodeValue(); // Check for first optional parameter which means // we know the minimum number of parameters needed. - if (minParmCount < 0 && (parm.charAt(0) == '[' || - parm.startsWith("..."))) - minParmCount = parmCount - 1; + if (minParmCount < 0 && (parm.charAt(0) == '[' || parm.startsWith("..."))) + minParmCount = parmCount - 1; // Old style documentation sometimes had '[' in // prototypes so look for one at end of a parm too. else if (minParmCount < 0 && parm.endsWith("[")) @@ -493,8 +491,7 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { * region for the whole selection. */ Point selectedRange = textViewer.getSelectedRange(); - if (selectedRange.x >= 0 && selectedRange.y > 0 - && offset >= selectedRange.x + if (selectedRange.x >= 0 && selectedRange.y > 0 && offset >= selectedRange.x && offset <= selectedRange.x + selectedRange.y) return new Region(selectedRange.x, selectedRange.y); else { @@ -526,7 +523,8 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { if (fBindingService == null) return null; - String keySequence= fBindingService.getBestActiveBindingFormattedFor(IAutotoolEditorActionDefinitionIds.SHOW_TOOLTIP); + String keySequence = fBindingService + .getBestActiveBindingFormattedFor(IAutotoolEditorActionDefinitionIds.SHOW_TOOLTIP); if (keySequence == null) return null; @@ -540,24 +538,25 @@ public class AutoconfTextHover implements ITextHover, ITextHoverExtension { */ protected static String getStyleSheet() { if (fgStyleSheet == null) { - Bundle bundle= Platform.getBundle(AutotoolsUIPlugin.PLUGIN_ID); - URL styleSheetURL= bundle.getEntry("/AutoconfHoverStyleSheet.css"); //$NON-NLS-1$ + Bundle bundle = Platform.getBundle(AutotoolsUIPlugin.PLUGIN_ID); + URL styleSheetURL = bundle.getEntry("/AutoconfHoverStyleSheet.css"); //$NON-NLS-1$ if (styleSheetURL != null) { try { - styleSheetURL= FileLocator.toFileURL(styleSheetURL); - try (BufferedReader reader= new BufferedReader(new InputStreamReader(styleSheetURL.openStream()))) { - StringBuilder buffer= new StringBuilder(200); - String line= reader.readLine(); + styleSheetURL = FileLocator.toFileURL(styleSheetURL); + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(styleSheetURL.openStream()))) { + StringBuilder buffer = new StringBuilder(200); + String line = reader.readLine(); while (line != null) { buffer.append(line); buffer.append('\n'); - line= reader.readLine(); + line = reader.readLine(); } - fgStyleSheet= buffer.toString(); + fgStyleSheet = buffer.toString(); } } catch (IOException ex) { AutotoolsUIPlugin.log(ex); - fgStyleSheet= ""; //$NON-NLS-1$ + fgStyleSheet = ""; //$NON-NLS-1$ } } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/HoverMessages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/HoverMessages.java index 8445c6af763..8584353318f 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/HoverMessages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/text/hover/HoverMessages.java @@ -18,15 +18,14 @@ import java.text.MessageFormat; import java.util.MissingResourceException; import java.util.ResourceBundle; - /** * AutoconfEditorMessages */ public class HoverMessages { - private static final String RESOURCE_BUNDLE= HoverMessages.class.getName(); + private static final String RESOURCE_BUNDLE = HoverMessages.class.getName(); - private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); + private static ResourceBundle fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE); private HoverMessages() { } @@ -38,53 +37,55 @@ public class HoverMessages { return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ } } + /** * Gets a string from the resource bundle and formats it with the argument - * + * * @param key the string used to get the bundle value, must not be null * @since 3.0 */ public static String getFormattedString(String key, Object arg) { - String format= null; + String format = null; try { - format= fgResourceBundle.getString(key); + format = fgResourceBundle.getString(key); } catch (MissingResourceException e) { return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ } if (arg == null) - arg= ""; //$NON-NLS-1$ + arg = ""; //$NON-NLS-1$ return MessageFormat.format(format, new Object[] { arg }); } + /** * Gets a string from the resource bundle and formats it with the arguments - * + * * @param key the string used to get the bundle value, must not be null * @since 3.0 */ public static String getFormattedString(String key, Object arg1, Object arg2) { - String format= null; + String format = null; try { - format= fgResourceBundle.getString(key); + format = fgResourceBundle.getString(key); } catch (MissingResourceException e) { return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ } if (arg1 == null) - arg1= ""; //$NON-NLS-1$ + arg1 = ""; //$NON-NLS-1$ if (arg2 == null) - arg2= ""; //$NON-NLS-1$ + arg2 = ""; //$NON-NLS-1$ return MessageFormat.format(format, new Object[] { arg1, arg2 }); } - + /** * Gets a string from the resource bundle and formats it with the argument - * + * * @param key the string used to get the bundle value, must not be null * @since 3.0 */ public static String getFormattedString(String key, boolean arg) { - String format= null; + String format = null; try { - format= fgResourceBundle.getString(key); + format = fgResourceBundle.getString(key); } catch (MissingResourceException e) { return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$ } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizard.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizard.java index b5e4717ffc1..58638db8c46 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizard.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizard.java @@ -37,15 +37,15 @@ import org.eclipse.jface.wizard.IWizard; public class AutotoolsBuildWizard extends AbstractCWizard { public static final String OTHERS_LABEL = AutotoolsWizardMessages.getResourceString("AutotoolsBuildWizard.1"); //$NON-NLS-1$ public static final String AUTOTOOLS_PROJECTTYPE_ID = "org.eclipse.linuxtools.cdt.autotools.core.projectType"; //$NON-NLS-1$ - + /** * @since 5.1 */ public static final String EMPTY_PROJECT = AutotoolsWizardMessages.getResourceString("AutotoolsBuildWizard.2"); //$NON-NLS-1$ public static final String AUTOTOOLS_TOOLCHAIN_ID = "org.eclipse.linuxtools.cdt.autotools.core.toolChain"; //$NON-NLS-1$ - + /** - * Creates and returns an array of items to be displayed + * Creates and returns an array of items to be displayed */ @Override public EntryDescriptor[] createItems(boolean supportedOnly, IWizard wizard) { @@ -63,7 +63,7 @@ public class AutotoolsBuildWizard extends AbstractCWizard { IProjectType pt = e.getValue(); AutotoolsBuildWizardHandler h = new AutotoolsBuildWizardHandler(pt, parent, wizard); IToolChain[] tcs = ManagedBuildManager.getExtensionToolChains(pt); - for(int i = 0; i < tcs.length; i++){ + for (int i = 0; i < tcs.length; i++) { IToolChain t = tcs[i]; IToolChain parent = t; @@ -74,7 +74,7 @@ public class AutotoolsBuildWizard extends AbstractCWizard { if (!parent.getId().equals(AUTOTOOLS_TOOLCHAIN_ID)) continue; - if(t.isSystemObject()) + if (t.isSystemObject()) continue; if (!isValid(t, supportedOnly, wizard)) continue; diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizardHandler.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizardHandler.java index 6da0a63ba22..3f6d1e03433 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizardHandler.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizardHandler.java @@ -49,7 +49,8 @@ public class AutotoolsBuildWizardHandler extends MBSWizardHandler { } @Override - public void createProject(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor) throws CoreException { + public void createProject(IProject project, boolean defaults, boolean onFinish, IProgressMonitor monitor) + throws CoreException { super.createProject(project, defaults, onFinish, monitor); // Fix for bug #312298 // Following is required to get around the fact that the Scanner Discovery BuildInfo isn't @@ -91,9 +92,9 @@ public class AutotoolsBuildWizardHandler extends MBSWizardHandler { @Override public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException { - super.convertProject(proj, monitor); + super.convertProject(proj, monitor); AutotoolsNewProjectNature.addAutotoolsNature(proj, monitor); - + // For each IConfiguration, create a corresponding Autotools Configuration IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(proj); IConfiguration[] cfgs = info.getManagedProject().getConfigurations(); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizard.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizard.java index 077b37148a3..69b7c15ebb5 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizard.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizard.java @@ -69,18 +69,15 @@ public class AutotoolsProjectImportWizard extends NewMakeProjFromExisting { // Add the configuration selection page projectConfigurationPage = new CProjectPlatformPage(PREFIX); - projectConfigurationPage.setTitle(AutotoolsUIPlugin - .getResourceString(CONF_TITLE)); - projectConfigurationPage.setDescription(AutotoolsUIPlugin - .getResourceString(CONF_DESC)); + projectConfigurationPage.setTitle(AutotoolsUIPlugin.getResourceString(CONF_TITLE)); + projectConfigurationPage.setDescription(AutotoolsUIPlugin.getResourceString(CONF_DESC)); addPage(projectConfigurationPage); // add custom pages MBSCustomPageManager.init(); // add stock pages - MBSCustomPageManager.addStockPage(projectConfigurationPage, - CProjectPlatformPage.PAGE_ID); + MBSCustomPageManager.addStockPage(projectConfigurationPage, CProjectPlatformPage.PAGE_ID); } @@ -107,21 +104,16 @@ public class AutotoolsProjectImportWizard extends NewMakeProjFromExisting { // Create Project try { IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject project = workspace.getRoot().getProject( - projectName); + IProject project = workspace.getRoot().getProject(projectName); - IProjectDescription description = workspace - .newProjectDescription(projectName); - IPath defaultLocation = workspace.getRoot().getLocation() - .append(projectName); + IProjectDescription description = workspace.newProjectDescription(projectName); + IPath defaultLocation = workspace.getRoot().getLocation().append(projectName); Path location = new Path(locationStr); - if (!location.isEmpty() - && !location.equals(defaultLocation)) { + if (!location.isEmpty() && !location.equals(defaultLocation)) { description.setLocation(location); } - CCorePlugin.getDefault().createCDTProject(description, - project, monitor); + CCorePlugin.getDefault().createCDTProject(description, project, monitor); // C++ natures if (isCPP) { @@ -129,34 +121,27 @@ public class AutotoolsProjectImportWizard extends NewMakeProjFromExisting { } // Set up build information - ICProjectDescriptionManager pdMgr = CoreModel.getDefault() - .getProjectDescriptionManager(); - ICProjectDescription projDesc = pdMgr - .createProjectDescription(project, false); - ManagedBuildInfo info = ManagedBuildManager - .createBuildInfo(project); + ICProjectDescriptionManager pdMgr = CoreModel.getDefault().getProjectDescriptionManager(); + ICProjectDescription projDesc = pdMgr.createProjectDescription(project, false); + ManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project); ManagedProject mProj = new ManagedProject(projDesc); info.setManagedProject(mProj); monitor.worked(1); CfgHolder cfgHolder = new CfgHolder(toolChain, null); String s = toolChain == null ? "0" : ((ToolChain) toolChain).getId(); //$NON-NLS-1$ - Configuration config = new Configuration(mProj, - (ToolChain) toolChain, - ManagedBuildManager.calculateChildId(s, null), - cfgHolder.getName()); + Configuration config = new Configuration(mProj, (ToolChain) toolChain, + ManagedBuildManager.calculateChildId(s, null), cfgHolder.getName()); IBuilder builder = config.getEditableBuilder(); builder.setManagedBuildOn(false); CConfigurationData data = config.getConfigurationData(); - projDesc.createConfiguration( - ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); + projDesc.createConfiguration(ManagedBuildManager.CFG_DATA_PROVIDER_ID, data); monitor.worked(1); pdMgr.setProjectDescription(project, projDesc); // Convert the created project to an Autotools project - page.convertProject( - project, monitor, projectName); + page.convertProject(project, monitor, projectName); } catch (Throwable e) { } monitor.done(); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizardPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizardPage.java index fceee12f408..501032e3603 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizardPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsProjectImportWizardPage.java @@ -45,16 +45,13 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; @SuppressWarnings("restriction") -public class AutotoolsProjectImportWizardPage extends - NewMakeProjFromExistingPage { +public class AutotoolsProjectImportWizardPage extends NewMakeProjFromExistingPage { private Button langc; private Button langcpp; protected AutotoolsProjectImportWizardPage() { - setTitle(AutotoolsWizardMessages - .getResourceString("ImportWizardPage.title")); - setDescription(AutotoolsWizardMessages - .getResourceString("ImportWizardPage.description")); + setTitle(AutotoolsWizardMessages.getResourceString("ImportWizardPage.title")); + setDescription(AutotoolsWizardMessages.getResourceString("ImportWizardPage.description")); } protected IProjectType getProjectType() { @@ -62,8 +59,7 @@ public class AutotoolsProjectImportWizardPage extends } protected IConfiguration[] getSelectedConfigurations() { - return ((AutotoolsProjectImportWizard) getWizard()) - .getSelectedConfigurations(); + return ((AutotoolsProjectImportWizard) getWizard()).getSelectedConfigurations(); } @Override @@ -95,13 +91,11 @@ public class AutotoolsProjectImportWizardPage extends } }; - langc = ControlFactory.createRadioButton(group, - CUIMessages.ConvertProjectWizardPage_CProject, "C ", //$NON-NLS-1$ + langc = ControlFactory.createRadioButton(group, CUIMessages.ConvertProjectWizardPage_CProject, "C ", //$NON-NLS-1$ cListener); langc.setSelection(true); - langcpp = ControlFactory.createRadioButton(group, - CUIMessages.ConvertProjectWizardPage_CppProject, "C++ ", //$NON-NLS-1$ + langcpp = ControlFactory.createRadioButton(group, CUIMessages.ConvertProjectWizardPage_CppProject, "C++ ", //$NON-NLS-1$ cListener); langcpp.setSelection(false); } @@ -111,49 +105,39 @@ public class AutotoolsProjectImportWizardPage extends return getSelectedConfigurations()[0].getToolChain(); } - public void convertProject(IProject project, IProgressMonitor monitor, - String projectID) throws CoreException { + public void convertProject(IProject project, IProgressMonitor monitor, String projectID) throws CoreException { monitor.beginTask( - AutotoolsUIPlugin - .getResourceString("WizardMakeProjectConversion.monitor.convertingToMakeProject"), 7); //$NON-NLS-1$ + AutotoolsUIPlugin.getResourceString("WizardMakeProjectConversion.monitor.convertingToMakeProject"), 7); //$NON-NLS-1$ IConfiguration defaultCfg = null; try { - monitor.subTask(AutotoolsUIPlugin - .getResourceString("adding project nature")); + monitor.subTask(AutotoolsUIPlugin.getResourceString("adding project nature")); ManagedCProjectNature.addManagedNature(project, SubMonitor.convert(monitor, 1)); AutotoolsNewProjectNature.addAutotoolsNature(project, SubMonitor.convert(monitor, 1)); - monitor.subTask(AutotoolsUIPlugin - .getResourceString("adding builder")); + monitor.subTask(AutotoolsUIPlugin.getResourceString("adding builder")); AutotoolsNewProjectNature.addAutotoolsBuilder(project, SubMonitor.convert(monitor, 1)); - project.setPersistentProperty( - AutotoolsPropertyConstants.SCANNER_USE_MAKE_W, + project.setPersistentProperty(AutotoolsPropertyConstants.SCANNER_USE_MAKE_W, AutotoolsPropertyConstants.TRUE); // Specify false for override in next call as override can cause the // method to throw an // exception. - CCorePlugin.getDefault() - .mapCProjectOwner(project, projectID, false); + CCorePlugin.getDefault().mapCProjectOwner(project, projectID, false); // Add the ManagedProject to the project IManagedProject newManagedProject = null; IManagedBuildInfo info = null; try { info = ManagedBuildManager.createBuildInfo(project); - newManagedProject = ManagedBuildManager.createManagedProject( - project, getProjectType()); + newManagedProject = ManagedBuildManager.createManagedProject(project, getProjectType()); if (newManagedProject != null) { for (int i = 0; i < getSelectedConfigurations().length; i++) { IConfiguration config = getSelectedConfigurations()[i]; int id = ManagedBuildManager.getRandomNumber(); - IConfiguration newConfig = newManagedProject - .createConfiguration(config, config.getId() - + "." + id); //$NON-NLS-1$ - newConfig.setArtifactName(newManagedProject - .getDefaultArtifactName()); + IConfiguration newConfig = newManagedProject.createConfiguration(config, + config.getId() + "." + id); //$NON-NLS-1$ + newConfig.setArtifactName(newManagedProject.getDefaultArtifactName()); } // Now add the first supported config in the list as the // default - IConfiguration[] newConfigs = newManagedProject - .getConfigurations(); + IConfiguration[] newConfigs = newManagedProject.getConfigurations(); for (int i = 0; i < newConfigs.length; i++) { if (newConfigs[i].isSupported()) { defaultCfg = newConfigs[i]; @@ -165,10 +149,8 @@ public class AutotoolsProjectImportWizardPage extends defaultCfg = newConfigs[0]; if (defaultCfg != null) { - ManagedBuildManager.setDefaultConfiguration(project, - defaultCfg); - ManagedBuildManager.setSelectedConfiguration(project, - defaultCfg); + ManagedBuildManager.setDefaultConfiguration(project, defaultCfg); + ManagedBuildManager.setSelectedConfiguration(project, defaultCfg); } ManagedBuildManager.setNewProjectVersion(project); AutotoolsNewMakeGenerator m = new AutotoolsNewMakeGenerator(); @@ -185,8 +167,7 @@ public class AutotoolsProjectImportWizardPage extends } // Save the build options - monitor.subTask(AutotoolsUIPlugin - .getResourceString("saving project")); + monitor.subTask(AutotoolsUIPlugin.getResourceString("saving project")); if (info != null) { info.setValid(true); ManagedBuildManager.saveBuildInfo(project, true); diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsWizardMessages.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsWizardMessages.java index 8b8aa297a82..5bed53071ff 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsWizardMessages.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsWizardMessages.java @@ -10,7 +10,7 @@ * * Contributors: * IBM - Initial API and implementation - * Red Hat - Copy from org.eclipse.cdt.wizards to here plus rename + * Red Hat - Copy from org.eclipse.cdt.wizards to here plus rename *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.wizards; @@ -40,7 +40,7 @@ public class AutotoolsWizardMessages { } public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getResourceString(key), (Object[])args); + return MessageFormat.format(getResourceString(key), (Object[]) args); } public static String getResourceString(String key) { diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/CProjectPlatformPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/CProjectPlatformPage.java index a4fd899c055..62276658b5e 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/CProjectPlatformPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/CProjectPlatformPage.java @@ -43,11 +43,10 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; - /** - * Class that implements the project type and configuration selection page in the new + * Class that implements the project type and configuration selection page in the new * project wizard for managed builder projects. - * + * * @since 1.2 */ public class CProjectPlatformPage extends WizardPage { @@ -61,13 +60,13 @@ public class CProjectPlatformPage extends WizardPage { private static final String TARGET_LABEL = LABEL + ".platform"; //$NON-NLS-1$ private static final String TARGET_TIP = TIP + ".platform"; //$NON-NLS-1$ private static final String FORCEDCONFIG_TIP = TIP + ".forcedconfigs"; //$NON-NLS-1$ - + // support for exporting data to custom wizard pages public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.platformPage"; //$NON-NLS-1$ public static final String PROJECT_TYPE = "projectType"; //$NON-NLS-1$ public static final String TOOLCHAIN = "toolchain"; //$NON-NLS-1$ public static final String NATURE = "nature"; //$NON-NLS-1$ - + protected Text platformSelection; private List<Object> selectedConfigurations; protected IProjectType projectType; @@ -84,7 +83,8 @@ public class CProjectPlatformPage extends WizardPage { public CProjectPlatformPage(String pageName) { super(pageName); setPageComplete(false); - projectType = ManagedBuildManager.getExtensionProjectType("org.eclipse.linuxtools.cdt.autotools.core.projectType"); //$NON-NLS-1$ + projectType = ManagedBuildManager + .getExtensionProjectType("org.eclipse.linuxtools.cdt.autotools.core.projectType"); //$NON-NLS-1$ selectedConfigurations = new ArrayList<>(0); showAllConfigsForced = false; } @@ -94,7 +94,7 @@ public class CProjectPlatformPage extends WizardPage { return validatePage() && getNextPage() != null; } - private void createConfigSelectionGroup (Composite parent) { + private void createConfigSelectionGroup(Composite parent) { // Create the group composite Composite composite = new Composite(parent, SWT.NULL); composite.setFont(parent.getFont()); @@ -106,8 +106,8 @@ public class CProjectPlatformPage extends WizardPage { configLabel.setFont(composite.getFont()); configLabel.setText(AutotoolsWizardMessages.getResourceString(CONFIG_LABEL)); - Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.MULTI - | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); + Table table = new Table(composite, + SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); table.setLayoutData(new GridData(GridData.FILL_BOTH)); table.setHeaderVisible(true); table.setLinesVisible(false); @@ -124,7 +124,7 @@ public class CProjectPlatformPage extends WizardPage { tableViewer.addSelectionChangedListener(e -> handleConfigurationSelectionChange()); } - + /** * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ @@ -149,14 +149,13 @@ public class CProjectPlatformPage extends WizardPage { // Select configuration populateConfigurations(); setPageComplete(validatePage()); - + // Do the nasty setErrorMessage(null); setMessage(null); setControl(composite); } - private void createTypeSelectGroup(Composite parent) { // Create the group composite Composite composite = new Composite(parent, SWT.NULL); @@ -170,12 +169,12 @@ public class CProjectPlatformPage extends WizardPage { platformLabel.setText(AutotoolsWizardMessages.getResourceString(TARGET_LABEL)); platformSelection = new Text(composite, SWT.READ_ONLY); -// platformSelection = new Combo(composite, SWT.READ_ONLY | SWT.BORDER); + // platformSelection = new Combo(composite, SWT.READ_ONLY | SWT.BORDER); platformSelection.setFont(composite.getFont()); platformSelection.setToolTipText(AutotoolsWizardMessages.getResourceString(TARGET_TIP)); platformSelection.setText("GNU Autotools"); //$NON-NLS-1$ platformSelection.addDisposeListener(e -> platformSelection = null); - + GridData gd = new GridData(GridData.FILL_HORIZONTAL); // Make this the same as NewCProjectWizardPage.SIZING_TEXT_FIELD_WIDTH gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 50; @@ -183,9 +182,9 @@ public class CProjectPlatformPage extends WizardPage { } public IProject getProject() { - return ((NewCProjectWizard)getWizard()).getNewProject(); + return ((NewCProjectWizard) getWizard()).getNewProject(); } - + /** * @return */ @@ -195,7 +194,7 @@ public class CProjectPlatformPage extends WizardPage { /** * Returns the selected project type. - * + * * @return IProjectType Selected type or <code>null</code> if an invalid selection * has been made. */ @@ -207,52 +206,51 @@ public class CProjectPlatformPage extends WizardPage { // Get the selections from the table viewer selectedConfigurations.clear(); selectedConfigurations.addAll(Arrays.asList(tableViewer.getCheckedElements())); - + // support for publishing the toolchains for the selected configs so that custom wizard // pages will know which toolchains have been selected - + // get the toolchains from the selected configs and put them into a set Set<IToolChain> toolchainSet = new LinkedHashSet<>(); - for(int k = 0; k < selectedConfigurations.size(); k++) - { + for (int k = 0; k < selectedConfigurations.size(); k++) { IConfiguration config = (IConfiguration) selectedConfigurations.get(k); IToolChain toolchain = config.getToolChain(); toolchainSet.add(toolchain); } - + // publish the set of selected toolchains with the custom page manager MBSCustomPageManager.addPageProperty(PAGE_ID, TOOLCHAIN, toolchainSet); - + // TODO: Don't know where this goes and how to find true nature - MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, CProjectNature.C_NATURE_ID); - + MBSCustomPageManager.addPageProperty(CProjectPlatformPage.PAGE_ID, CProjectPlatformPage.NATURE, + CProjectNature.C_NATURE_ID); + setPageComplete(validatePage()); } /** * Populate the table viewer with either all known configurations * or only with the supported configurations depending on whether a user - * has chosen to display unsupported configurations or not + * has chosen to display unsupported configurations or not * By default, only supported configurations are selected. */ private void populateConfigurations() { if (projectType == null) return; IConfiguration selected[] = null; - + configurations = filterSupportedConfigurations(projectType.getConfigurations()); selected = configurations; - + // Check for buildable configs on this platform if (selected.length == 0) { // Indicate that there are no buildable configurations on this platform for this project // type and that all configurations will be selected setMessage(AutotoolsWizardMessages.getResourceString(FORCEDCONFIG_TIP), WARNING); - } - else { + } else { setMessage(null, NONE); } - + tableViewer.setInput(configurations); tableViewer.setCheckedElements(selected); handleConfigurationSelectionChange(); @@ -262,29 +260,28 @@ public class CProjectPlatformPage extends WizardPage { * Returns the array of supported configurations found in the configurations * passed to this method */ - IConfiguration[] filterSupportedConfigurations(IConfiguration cfgs[]){ + IConfiguration[] filterSupportedConfigurations(IConfiguration cfgs[]) { ArrayList<IConfiguration> supported = new ArrayList<>(); String os = Platform.getOS(); String arch = Platform.getOSArch(); for (int i = 0; i < cfgs.length; i++) { // First, filter on supported state - if (cfgs[i].isSupported()) { + if (cfgs[i].isSupported()) { // Now, apply the OS and ARCH filters to determine if the configuration should be shown // Determine if the configuration's tool-chain supports this OS & Architecture. IToolChain tc = cfgs[i].getToolChain(); List<String> osList = Arrays.asList(tc.getOSList()); - if (osList.contains("all") || osList.contains(os)) { //$NON-NLS-1$ + if (osList.contains("all") || osList.contains(os)) { //$NON-NLS-1$ List<String> archList = Arrays.asList(tc.getArchList()); if (archList.contains("all") || archList.contains(arch)) { //$NON-NLS-1$ - supported.add(cfgs[i]); + supported.add(cfgs[i]); } - } + } } } return supported.toArray(new IConfiguration[supported.size()]); } - /** * @return @@ -295,7 +292,7 @@ public class CProjectPlatformPage extends WizardPage { setErrorMessage(null); return true; } else { - setErrorMessage(AutotoolsWizardMessages.getResourceString("PlatformBlock.message.error.noconfigs")); //$NON-NLS-1$ + setErrorMessage(AutotoolsWizardMessages.getResourceString("PlatformBlock.message.error.noconfigs")); //$NON-NLS-1$ return false; } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConfigurationContentProvider.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConfigurationContentProvider.java index f635e2adf3a..fba8a59116b 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConfigurationContentProvider.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConfigurationContentProvider.java @@ -22,7 +22,7 @@ public class ConfigurationContentProvider implements IStructuredContentProvider @Override public Object[] getElements(Object parent) { // The content is an array of configurations - Object array[] = (Object[])parent; + Object array[] = (Object[]) parent; return (array == null || array.length == 0) ? new Object[0] : array; } @@ -31,9 +31,6 @@ public class ConfigurationContentProvider implements IStructuredContentProvider } @Override - public void inputChanged( - Viewer viewer, - Object oldInput, - Object newInput) { + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConfigurationLabelProvider.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConfigurationLabelProvider.java index 62f24ea1abd..172691d0fc2 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConfigurationLabelProvider.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConfigurationLabelProvider.java @@ -14,28 +14,25 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.wizards; - import org.eclipse.cdt.internal.autotools.ui.AutotoolsUIPluginImages; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; +public class ConfigurationLabelProvider extends LabelProvider implements ITableLabelProvider { + private final Image IMG_CFG = AutotoolsUIPluginImages.get(AutotoolsUIPluginImages.IMG_BUILD_CONFIG); -public class ConfigurationLabelProvider extends LabelProvider implements ITableLabelProvider { - private final Image IMG_CFG = - AutotoolsUIPluginImages.get(AutotoolsUIPluginImages.IMG_BUILD_CONFIG); - - // + // @Override public String getColumnText(Object obj, int index) { if (obj instanceof IConfiguration) { IConfiguration tmpConfig = (IConfiguration) obj; - - if( (tmpConfig.getDescription() == null)|| (tmpConfig.getDescription().isEmpty()) ) + + if ((tmpConfig.getDescription() == null) || (tmpConfig.getDescription().isEmpty())) return ((IConfiguration) obj).getName(); else - return ( tmpConfig.getName() + " ( " + tmpConfig.getDescription() + " )"); //$NON-NLS-1$ //$NON-NLS-2$ + return (tmpConfig.getName() + " ( " + tmpConfig.getDescription() + " )"); //$NON-NLS-1$ //$NON-NLS-2$ } return ""; } @@ -45,4 +42,3 @@ public class ConfigurationLabelProvider extends LabelProvider implements ITableL return IMG_CFG; } } - diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizard.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizard.java index af49c013610..30756c9793b 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizard.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizard.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.wizards; - import java.lang.reflect.InvocationTargetException; import org.eclipse.cdt.autotools.ui.AutotoolsUIPlugin; @@ -30,9 +29,8 @@ import org.eclipse.core.runtime.SubMonitor; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.wizard.Wizard; - /** - * This wizard provides a method by which the user can + * This wizard provides a method by which the user can * add a C nature to a project that previously had no nature associated with it. */ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { @@ -41,28 +39,29 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { private static final String WZ_DESC = "WizardAutotoolsProjectConversion.description"; //$NON-NLS-1$ private static final String PREFIX = "WizardAutotoolsConversion"; //$NON-NLS-1$ private static final String WINDOW_TITLE = "WizardAutotoolsConversion.windowTitle"; //$NON-NLS-1$ - protected static final String CONF_TITLE = PREFIX + ".config.title"; //$NON-NLS-1$ - protected static final String CONF_DESC = PREFIX + ".config.desc"; //$NON-NLS-1$ - protected static final String MSG_SAVE = PREFIX + ".message.save"; //$NON-NLS-1$ - protected static final String OPTIONS_TITLE = PREFIX + ".options.title"; //$NON-NLS-1$ - protected static final String OPTIONS_DESC = PREFIX + ".options.desc"; //$NON-NLS-1$ + protected static final String CONF_TITLE = PREFIX + ".config.title"; //$NON-NLS-1$ + protected static final String CONF_DESC = PREFIX + ".config.desc"; //$NON-NLS-1$ + protected static final String MSG_SAVE = PREFIX + ".message.save"; //$NON-NLS-1$ + protected static final String OPTIONS_TITLE = PREFIX + ".options.title"; //$NON-NLS-1$ + protected static final String OPTIONS_DESC = PREFIX + ".options.desc"; //$NON-NLS-1$ public static final String NULL_INDEXER_ID = "org.eclipse.cdt.core.nullindexer"; //$NON-NLS-1$ - + protected CProjectPlatformPage projectConfigurationPage; protected NewAutotoolsProjectOptionPage optionPage; protected IProject curProject; - + /** * ConvertToAutotoolsConversionWizard Wizard constructor */ public ConvertToAutotoolsProjectWizard() { this(getWindowTitleResource(), getWzDescriptionResource()); } + /** * ConvertToAutotoolsConversionWizard Wizard constructor - * + * * @param title * @param desc */ @@ -73,7 +72,7 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { /** * Method getWzDescriptionResource, allows Wizard description label value * to be changed by subclasses - * + * * @return String */ protected static String getWzDescriptionResource() { @@ -83,7 +82,7 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { /** * Method getWzTitleResource, allows Wizard description label value * to be changed by subclasses - * + * * @return String */ protected static String getWzTitleResource() { @@ -93,7 +92,7 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { /** * Method getWindowTitleResource, allows Wizard Title label value to be * changed by subclasses - * + * * @return String */ protected static String getWindowTitleResource() { @@ -102,7 +101,7 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { /** * Method getPrefix, allows prefix value to be changed by subclasses - * + * * @return String */ protected static String getPrefix() { @@ -111,13 +110,13 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { /** * Method addPages adds our Simple to C conversion Wizard page. - * + * * @see Wizard#createPages */ @Override public void addPages() { addPage(mainPage = new ConvertToAutotoolsProjectWizardPage(getPrefix(), this)); - + // Add the configuration selection page projectConfigurationPage = new CProjectPlatformPage(PREFIX); projectConfigurationPage.setTitle(AutotoolsUIPlugin.getResourceString(CONF_TITLE)); @@ -129,10 +128,10 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { optionPage.setTitle(AutotoolsUIPlugin.getResourceString(OPTIONS_TITLE)); optionPage.setDescription(AutotoolsUIPlugin.getResourceString(OPTIONS_DESC)); addPage(optionPage); - + // add custom pages MBSCustomPageManager.init(); - + // add stock pages MBSCustomPageManager.addStockPage(fMainPage, NewCProjectWizardPage.PAGE_ID); MBSCustomPageManager.addStockPage(projectConfigurationPage, CProjectPlatformPage.PAGE_ID); @@ -152,14 +151,14 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { return projectConfigurationPage.getSelectedConfigurations(); } - protected void setCurrentProject (IProject project) { + protected void setCurrentProject(IProject project) { curProject = project; } - + public IProject getProject() { return curProject; } - + @SuppressWarnings("deprecation") public void applyOptions(IProject project, IProgressMonitor monitor) { // When applying the project options, we need to specify which @@ -169,18 +168,20 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { // applying options will ask the wizard (us) to get the project which // we will report is the current project being converted. setCurrentProject(project); - optionPage.performApply(monitor); - } - + optionPage.performApply(monitor); + } + @Override protected void doRun(IProgressMonitor monitor) throws CoreException { - monitor.beginTask(AutotoolsUIPlugin.getResourceString("WizardAutotoolsProjectConversion.monitor.convertingToMakeProject"), 2); //$NON-NLS-1$ + monitor.beginTask( + AutotoolsUIPlugin.getResourceString("WizardAutotoolsProjectConversion.monitor.convertingToMakeProject"), //$NON-NLS-1$ + 2); try { super.doRun(SubMonitor.convert(monitor, 5)); } finally { monitor.done(); } - + } @Override @@ -192,25 +193,23 @@ public class ConvertToAutotoolsProjectWizard extends ConversionWizard { @Override protected void doRunEpilogue(IProgressMonitor monitor) { // Get my initializer to run -// if (project == null) -// return; -// -// IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project); -// if (initResult.getCode() != IStatus.OK) { -// // At this point, I can live with a failure -// ManagedBuilderUIPlugin.log(initResult); -// } - + // if (project == null) + // return; + // + // IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project); + // if (initResult.getCode() != IStatus.OK) { + // // At this point, I can live with a failure + // ManagedBuilderUIPlugin.log(initResult); + // } + // execute any operations specified by custom pages IRunnableWithProgress operations[] = MBSCustomPageManager.getOperations(); - - if (operations != null) - { - for(int k = 0; k < operations.length; k++) - { + + if (operations != null) { + for (int k = 0; k < operations.length; k++) { try { - operations[k].run(monitor); - } catch(InvocationTargetException |InterruptedException e) { + operations[k].run(monitor); + } catch (InvocationTargetException | InterruptedException e) { //TODO: what should we do? } } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizardPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizardPage.java index 19ad695e6bc..ef85c2263d3 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizardPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ConvertToAutotoolsProjectWizardPage.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.ui.wizards; - import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; import org.eclipse.cdt.autotools.ui.AutotoolsUIPlugin; import org.eclipse.cdt.core.CCorePlugin; @@ -37,7 +36,6 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; - /** * * ConvertToAutotoolsProjectWizardPage @@ -56,14 +54,14 @@ import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; * </p> */ public class ConvertToAutotoolsProjectWizardPage extends ConvertProjectWizardPage { - - private static final String WZ_TITLE = "WizardAutotoolsProjectConversion.title"; //$NON-NLS-1$ - private static final String WZ_DESC = "WizardAutotoolsProjectConversion.description"; //$NON-NLS-1$ - private static final String PREFIX = "WizardAutotoolsProjectConversion"; - protected static final String MSG_ADD_NATURE = PREFIX + ".message.add_nature"; //$NON-NLS-1$ - protected static final String MSG_ADD_BUILDER = PREFIX + ".message.add_builder"; //$NON-NLS-1$ - protected static final String MSG_SAVE = PREFIX + ".message.save"; //$NON-NLS-1$ - + + private static final String WZ_TITLE = "WizardAutotoolsProjectConversion.title"; //$NON-NLS-1$ + private static final String WZ_DESC = "WizardAutotoolsProjectConversion.description"; //$NON-NLS-1$ + private static final String PREFIX = "WizardAutotoolsProjectConversion"; + protected static final String MSG_ADD_NATURE = PREFIX + ".message.add_nature"; //$NON-NLS-1$ + protected static final String MSG_ADD_BUILDER = PREFIX + ".message.add_builder"; //$NON-NLS-1$ + protected static final String MSG_SAVE = PREFIX + ".message.save"; //$NON-NLS-1$ + /** * Constructor for ConvertToStdMakeProjectWizardPage. * @param pageName @@ -72,58 +70,59 @@ public class ConvertToAutotoolsProjectWizardPage extends ConvertProjectWizardPag super(pageName); setWizard(wizard); } - - /** - * Method getWzTitleResource returns the correct Title Label for this class - * overriding the default in the superclass. - */ - @Override - protected String getWzTitleResource(){ - return AutotoolsUIPlugin.getResourceString(WZ_TITLE); - } - - /** - * Method getWzDescriptionResource returns the correct description - * Label for this class overriding the default in the superclass. - */ - @Override - protected String getWzDescriptionResource(){ - return AutotoolsUIPlugin.getResourceString(WZ_DESC); - } - - /** - * Method isCandidate returns true for all projects. - * - * @param project - * @return boolean - */ - @Override - public boolean isCandidate(IProject project) { - return true; // all - } - - protected IProjectType getProjectType() { - return ((ConvertToAutotoolsProjectWizard)getWizard()).getProjectType(); - } - - protected IConfiguration[] getSelectedConfigurations() { - return ((ConvertToAutotoolsProjectWizard)getWizard()).getSelectedConfigurations(); - } - - protected void applyOptions(IProject project, IProgressMonitor monitor) { - ((ConvertToAutotoolsProjectWizard)getWizard()).applyOptions(project, monitor); - } - + + /** + * Method getWzTitleResource returns the correct Title Label for this class + * overriding the default in the superclass. + */ + @Override + protected String getWzTitleResource() { + return AutotoolsUIPlugin.getResourceString(WZ_TITLE); + } + + /** + * Method getWzDescriptionResource returns the correct description + * Label for this class overriding the default in the superclass. + */ + @Override + protected String getWzDescriptionResource() { + return AutotoolsUIPlugin.getResourceString(WZ_DESC); + } + + /** + * Method isCandidate returns true for all projects. + * + * @param project + * @return boolean + */ + @Override + public boolean isCandidate(IProject project) { + return true; // all + } + + protected IProjectType getProjectType() { + return ((ConvertToAutotoolsProjectWizard) getWizard()).getProjectType(); + } + + protected IConfiguration[] getSelectedConfigurations() { + return ((ConvertToAutotoolsProjectWizard) getWizard()).getSelectedConfigurations(); + } + + protected void applyOptions(IProject project, IProgressMonitor monitor) { + ((ConvertToAutotoolsProjectWizard) getWizard()).applyOptions(project, monitor); + } + @Override public void convertProject(IProject project, IProgressMonitor monitor, String projectID) throws CoreException { - monitor.beginTask(AutotoolsUIPlugin.getResourceString("WizardMakeProjectConversion.monitor.convertingToMakeProject"), 7); //$NON-NLS-1$ + monitor.beginTask( + AutotoolsUIPlugin.getResourceString("WizardMakeProjectConversion.monitor.convertingToMakeProject"), 7); //$NON-NLS-1$ IConfiguration defaultCfg = null; Boolean convertingNewAutotoolsProject = false; try { super.convertProject(project, SubMonitor.convert(monitor, 1), projectID); // Bug 289834 - Converting C Autotools project to C++ loses configurations if (project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) { - convertingNewAutotoolsProject = true; // set this for finally clause + convertingNewAutotoolsProject = true; // set this for finally clause return; // We have converted C to C++ or vice-versa for an existing Autotools project and are done } // Otherwise, we must scrap existing configurations as they will have tool settings we cannot use @@ -135,7 +134,8 @@ public class ConvertToAutotoolsProjectWizardPage extends ConvertProjectWizardPag monitor.subTask(AutotoolsUIPlugin.getResourceString(MSG_ADD_BUILDER)); AutotoolsNewProjectNature.addAutotoolsBuilder(project, SubMonitor.convert(monitor, 1)); // FIXME: Default scanner property: make -w - eventually we want to use Make core's build scanner - project.setPersistentProperty(AutotoolsPropertyConstants.SCANNER_USE_MAKE_W, AutotoolsPropertyConstants.TRUE); + project.setPersistentProperty(AutotoolsPropertyConstants.SCANNER_USE_MAKE_W, + AutotoolsPropertyConstants.TRUE); // Specify false for override in next call as override can cause the method to throw an // exception. CCorePlugin.getDefault().mapCProjectOwner(project, projectID, false); @@ -147,27 +147,27 @@ public class ConvertToAutotoolsProjectWizardPage extends ConvertProjectWizardPag IProjectType parent = getProjectType(); newManagedProject = ManagedBuildManager.createManagedProject(project, parent); if (newManagedProject != null) { - IConfiguration [] selectedConfigs = getSelectedConfigurations(); + IConfiguration[] selectedConfigs = getSelectedConfigurations(); for (int i = 0; i < selectedConfigs.length; i++) { IConfiguration config = selectedConfigs[i]; int id = ManagedBuildManager.getRandomNumber(); - IConfiguration newConfig = newManagedProject.createConfiguration(config, config.getId() + "." + id); //$NON-NLS-1$ + IConfiguration newConfig = newManagedProject.createConfiguration(config, + config.getId() + "." + id); //$NON-NLS-1$ newConfig.setArtifactName(newManagedProject.getDefaultArtifactName()); } // Now add the first supported config in the list as the default IConfiguration[] newConfigs = newManagedProject.getConfigurations(); - for(int i = 0; i < newConfigs.length; i++) { - if(newConfigs[i].isSupported()){ + for (int i = 0; i < newConfigs.length; i++) { + if (newConfigs[i].isSupported()) { defaultCfg = newConfigs[i]; break; } } - - if(defaultCfg == null && newConfigs.length > 0) + + if (defaultCfg == null && newConfigs.length > 0) defaultCfg = newConfigs[0]; - - - if(defaultCfg != null) { + + if (defaultCfg != null) { ManagedBuildManager.setDefaultConfiguration(project, defaultCfg); ManagedBuildManager.setSelectedConfiguration(project, defaultCfg); } @@ -212,8 +212,8 @@ public class ConvertToAutotoolsProjectWizardPage extends ConvertProjectWizardPag @Override public void createControl(Composite parent) { super.createControl(parent); - IStructuredSelection sel = ((BasicNewResourceWizard)getWizard()).getSelection(); - if ( sel != null) { + IStructuredSelection sel = ((BasicNewResourceWizard) getWizard()).getSelection(); + if (sel != null) { tableViewer.setCheckedElements(sel.toArray()); setPageComplete(validatePage()); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ManagedProjectOptionBlock.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ManagedProjectOptionBlock.java index 5e16a1b1171..526fb5b63fa 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ManagedProjectOptionBlock.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ManagedProjectOptionBlock.java @@ -25,13 +25,12 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.ui.PlatformUI; - @SuppressWarnings("deprecation") public class ManagedProjectOptionBlock extends TabFolderOptionBlock { private ErrorParserBlock errParserBlock; private BinaryParserBlock binaryParserBlock; - + /** * @param parent */ @@ -49,29 +48,30 @@ public class ManagedProjectOptionBlock extends TabFolderOptionBlock { public BinaryParserBlock getBinaryParserBlock() { return binaryParserBlock; } - + public ErrorParserBlock getErrorParserBlock() { return errParserBlock; } - + @Override public Control createContents(Composite parent) { - Control control = super.createContents( parent ); - ((GridLayout)((Composite)control).getLayout()).marginWidth = 1; + Control control = super.createContents(parent); + ((GridLayout) ((Composite) control).getLayout()).marginWidth = 1; GridData gd = new GridData(GridData.FILL_BOTH); - ((Composite)control).setLayoutData(gd); + ((Composite) control).setLayoutData(gd); - if (getErrorParserBlock()!= null) - PlatformUI.getWorkbench().getHelpSystem().setHelp(getErrorParserBlock().getControl(), CDTHelpContextIds.MAN_PROJ_ERROR_PARSER); + if (getErrorParserBlock() != null) + PlatformUI.getWorkbench().getHelpSystem().setHelp(getErrorParserBlock().getControl(), + CDTHelpContextIds.MAN_PROJ_ERROR_PARSER); return control; - } + } public void updateValues() { - if (getErrorParserBlock()!= null) { + if (getErrorParserBlock() != null) { getErrorParserBlock().updateValues(); } - if (getBinaryParserBlock()!= null) { + if (getBinaryParserBlock() != null) { // TODO //getBinaryParserBlock().updateValues(); } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/NewAutotoolsProjectOptionPage.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/NewAutotoolsProjectOptionPage.java index f1a4e9632fe..5d3886fb0d6 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/NewAutotoolsProjectOptionPage.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/NewAutotoolsProjectOptionPage.java @@ -30,16 +30,14 @@ import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.ui.PlatformUI; - @SuppressWarnings("deprecation") public class NewAutotoolsProjectOptionPage extends NewCProjectWizardOptionPage { - + public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.projectOptionsPage"; //$NON-NLS-1$ - + public static class ManagedWizardOptionBlock extends ManagedProjectOptionBlock { - + NewAutotoolsProjectOptionPage parent; - public ManagedWizardOptionBlock(NewAutotoolsProjectOptionPage parentPage) { super(parentPage); @@ -50,7 +48,7 @@ public class NewAutotoolsProjectOptionPage extends NewCProjectWizardOptionPage { AutotoolsReferenceBlock() { super(); } - + @Override public void performApply(IProgressMonitor monitor) { try { @@ -61,6 +59,7 @@ public class NewAutotoolsProjectOptionPage extends NewCProjectWizardOptionPage { } } } + public void updateProjectTypeProperties() { } @@ -70,14 +69,14 @@ public class NewAutotoolsProjectOptionPage extends NewCProjectWizardOptionPage { // Bug 406711 - Remove the IndexerBlock as this causes an exception to occur // because the project handle isn't set up. It is not needed. } - - public void setupHelpContextIds(){ + + public void setupHelpContextIds() { List<ICOptionPage> pages = getOptionPages(); - + Iterator<ICOptionPage> iter = pages.iterator(); - for( int i = 0; i < 3 && iter.hasNext(); i++ ) { + for (int i = 0; i < 3 && iter.hasNext(); i++) { ICOptionPage page = iter.next(); - + String id = null; if (page instanceof ReferenceBlock) { id = CDTHelpContextIds.MAN_PROJ_WIZ_PROJECTS_TAB; @@ -88,7 +87,7 @@ public class NewAutotoolsProjectOptionPage extends NewCProjectWizardOptionPage { } } } - + protected ManagedWizardOptionBlock optionBlock; /** @@ -107,7 +106,7 @@ public class NewAutotoolsProjectOptionPage extends NewCProjectWizardOptionPage { @Override public IProject getProject() { if (getWizard() instanceof ConvertToAutotoolsProjectWizard) - return ((ConvertToAutotoolsProjectWizard)getWizard()).getProject(); + return ((ConvertToAutotoolsProjectWizard) getWizard()).getProject(); return null; } @@ -115,20 +114,19 @@ public class NewAutotoolsProjectOptionPage extends NewCProjectWizardOptionPage { public Preferences getPreferences() { return ManagedBuilderUIPlugin.getDefault().getPluginPreferences(); } - + public void updateProjectTypeProperties() { // Update the error parser list optionBlock.updateProjectTypeProperties(); } - - public void setupHelpContextIds(){ + + public void setupHelpContextIds() { optionBlock.setupHelpContextIds(); } - + @Override - public IWizardPage getNextPage() - { + public IWizardPage getNextPage() { return MBSCustomPageManager.getNextPage(PAGE_ID); // get first custom page, if any } - + } diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ReferenceBlock.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ReferenceBlock.java index 73ecd43f38e..6177dabacfe 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ReferenceBlock.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/wizards/ReferenceBlock.java @@ -44,20 +44,20 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; /** * @deprecated as of CDT 4.0. This Block was used for New Project Wizard * for 3.X style projects. - * + * * @noextend This class is not intended to be subclassed by clients. */ @Deprecated public class ReferenceBlock extends AbstractCOptionPage { - private static final String PREFIX = "ReferenceBlock"; //$NON-NLS-1$ //$NON-NLS-1$ - private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$ //$NON-NLS-1$ - private static final String DESC = PREFIX + ".desc"; //$NON-NLS-1$ //$NON-NLS-1$ + private static final String PREFIX = "ReferenceBlock"; //$NON-NLS-1$ + private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$ + private static final String DESC = PREFIX + ".desc"; //$NON-NLS-1$ private CheckboxTableViewer referenceProjectsViewer; private static final int PROJECT_LIST_MULTIPLIER = 10; - + public ReferenceBlock() { super(CUIPlugin.getResourceString(LABEL)); setDescription(CUIPlugin.getResourceString(DESC)); @@ -81,7 +81,7 @@ public class ReferenceBlock extends AbstractCOptionPage { if (!(element instanceof IWorkspace)) return new Object[0]; ArrayList<IProject> aList = new ArrayList<>(15); - final IProject[] projects = ((IWorkspace)element).getRoot().getProjects(); + final IProject[] projects = ((IWorkspace) element).getRoot().getProjects(); for (int i = 0; i < projects.length; i++) { if (CoreModel.hasCNature(projects[i])) { // Do not show the actual project being look at @@ -96,7 +96,7 @@ public class ReferenceBlock extends AbstractCOptionPage { }; } - protected void initializeValues () { + protected void initializeValues() { if (getContainer().getProject() != null) { try { IProject[] referenced = getContainer().getProject().getReferencedProjects(); @@ -115,7 +115,7 @@ public class ReferenceBlock extends AbstractCOptionPage { Object[] elements = referenceProjectsViewer.getCheckedElements(); IProject[] projects = new IProject[elements.length]; System.arraycopy(elements, 0, projects, 0, elements.length); - return projects; + return projects; } @Override @@ -130,15 +130,10 @@ public class ReferenceBlock extends AbstractCOptionPage { lbldata.horizontalSpan = 1; label.setLayoutData(lbldata); - - referenceProjectsViewer = - CheckboxTableViewer.newCheckList(composite, SWT.TOP | SWT.BORDER); + referenceProjectsViewer = CheckboxTableViewer.newCheckList(composite, SWT.TOP | SWT.BORDER); GridData data = new GridData(GridData.FILL_BOTH); data.grabExcessHorizontalSpace = true; - data.heightHint = - getDefaultFontHeight( - referenceProjectsViewer.getTable(), - PROJECT_LIST_MULTIPLIER); + data.heightHint = getDefaultFontHeight(referenceProjectsViewer.getTable(), PROJECT_LIST_MULTIPLIER); //Only set a height hint if it will not result in a cut off dialog referenceProjectsViewer.getTable().setLayoutData(data); @@ -176,7 +171,7 @@ public class ReferenceBlock extends AbstractCOptionPage { if (monitor == null) { monitor = new NullProgressMonitor(); } - monitor.beginTask(AutotoolsWizardMessages.getResourceString("ReferenceBlock_task_ReferenceProjects"), 1); + monitor.beginTask(AutotoolsWizardMessages.getResourceString("ReferenceBlock_task_ReferenceProjects"), 1); try { IProjectDescription description = project.getDescription(); description.setReferencedProjects(refProjects); @@ -184,7 +179,7 @@ public class ReferenceBlock extends AbstractCOptionPage { } catch (CoreException e) { } } - + } @Override |