From 7791c5f8b3dfba91ca914a90dadbaeb47b59e837 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 3 Dec 2010 00:55:58 +0000 Subject: [PATCH] NLS-style string resources. This change removes public visibility from SourceLookupMessages class that was given to it by mistake. --- .../.settings/.api_filters | 56 ++++++++++++++++--- .../AbsolutePathSourceContainer.java | 35 +++++------- .../sourcelookup/MappingSourceContainer.java | 4 +- .../ProgramRelativePathSourceContainer.java | 40 ++++++------- .../sourcelookup/SourceLookupMessages.java | 28 ++++------ .../SourceLookupMessages.properties | 6 +- 6 files changed, 94 insertions(+), 75 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/.settings/.api_filters b/debug/org.eclipse.cdt.debug.core/.settings/.api_filters index ad89415c2e2..50097440abc 100644 --- a/debug/org.eclipse.cdt.debug.core/.settings/.api_filters +++ b/debug/org.eclipse.cdt.debug.core/.settings/.api_filters @@ -1,11 +1,49 @@ - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java index bec01fb264a..f07010fc382 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java @@ -9,7 +9,6 @@ * Nokia - Initial implementation (159833) * Broadcom - http://bugs.eclipse.org/247853 *******************************************************************************/ - package org.eclipse.cdt.debug.core.sourcelookup; import java.io.File; @@ -58,16 +57,13 @@ public class AbsolutePathSourceContainer extends AbstractSourceContainer { // The file is not already in the workspace so try to create an external translation unit for it. ISourceLookupDirector director = getDirector(); - if (director != null) - { + if (director != null) { ILaunchConfiguration launchConfiguration = director.getLaunchConfiguration(); - if (launchConfiguration != null) - { + if (launchConfiguration != null) { String projectName = launchConfiguration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ if (projectName.length() > 0) { ICProject project = CoreModel.getDefault().getCModel().getCProject(projectName); - if (project != null) - { + if (project != null) { IPath path = Path.fromOSString(file.getCanonicalPath()); String id = CoreModel.getRegistedContentTypeId(project.getProject(), path.lastSegment()); return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, path, id) }; @@ -89,8 +85,7 @@ public class AbsolutePathSourceContainer extends AbstractSourceContainer { */ private IProject getProject() { ISourceLookupDirector director = getDirector(); - if (director != null) - { + if (director != null) { ILaunchConfiguration config = director.getLaunchConfiguration(); if (config != null) { try { @@ -105,35 +100,33 @@ public class AbsolutePathSourceContainer extends AbstractSourceContainer { return null; } - public boolean isValidAbsoluteFilePath( String name ) - { - return isValidAbsoluteFilePath( new File(name) ); + public boolean isValidAbsoluteFilePath(String name) { + return isValidAbsoluteFilePath(new File(name)); } - public boolean isValidAbsoluteFilePath( File file ) - { + public boolean isValidAbsoluteFilePath(File file) { return file.isAbsolute() && file.exists() && file.isFile(); } - public Object[] findSourceElements( String name ) throws CoreException { - if ( name != null ) { - File file = new File( name ); - if ( isValidAbsoluteFilePath(file) ) { - return findSourceElementByFile( file ); + public Object[] findSourceElements(String name) throws CoreException { + if (name != null) { + File file = new File(name); + if (isValidAbsoluteFilePath(file)) { + return findSourceElementByFile(file); } } return new Object[0]; } public String getName() { - return SourceLookupMessages.getString( "AbsolutePathSourceContainer.0" ); //$NON-NLS-1$ + return SourceLookupMessages.AbsolutePathSourceContainer_0; } /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType() */ public ISourceContainerType getType() { - return getSourceContainerType( TYPE_ID ); + return getSourceContainerType(TYPE_ID); } @Override diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java index 4ab380c4112..753b843397a 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java @@ -104,7 +104,9 @@ public class MappingSourceContainer extends AbstractSourceContainer { if (single == null) { single = e; } else if (multiStatus == null) { - multiStatus = new MultiStatus(DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, new IStatus[]{ single.getStatus() }, SourceLookupMessages.getString("MappingSourceContainer.0"), null); //$NON-NLS-1$ + multiStatus = new MultiStatus(DebugPlugin.getUniqueIdentifier(), + DebugPlugin.INTERNAL_ERROR, new IStatus[] { single.getStatus() }, + SourceLookupMessages.MappingSourceContainer_0, null); multiStatus.add(e.getStatus()); } else { multiStatus.add(e.getStatus()); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ProgramRelativePathSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ProgramRelativePathSourceContainer.java index fee83aa6dac..bbd45d51d44 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ProgramRelativePathSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ProgramRelativePathSourceContainer.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Freescale - Initial implementation + * Freescale - Initial implementation *******************************************************************************/ - package org.eclipse.cdt.debug.core.sourcelookup; import java.io.File; @@ -35,7 +34,6 @@ import org.eclipse.debug.core.ILaunchConfiguration; * @since 7.0 */ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ - /** * Unique identifier for the relative path source container type * (value org.eclipse.cdt.debug.core.containerType.programRelativePath). @@ -83,21 +81,20 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ * * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String) */ - public Object[] findSourceElements( String sourceName ) throws CoreException { - - if (sourceName == null){ + public Object[] findSourceElements(String sourceName) throws CoreException { + if (sourceName == null) { return new Object[0]; } // check if source path is a relative path IPath sourcePath = new Path(sourceName); - if (sourcePath.isAbsolute()){ + if (sourcePath.isAbsolute()) { return new Object[0]; } // get program (executable) absolute path IPath programPath = getProgramLocation(); - if (programPath == Path.EMPTY){ + if (programPath == Path.EMPTY) { return new Object[0]; } @@ -108,8 +105,8 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ // check if source file exists and is valid File sourceFile = sourcePath.toFile(); - if ( sourceFile.exists() && sourceFile.isFile() ) { - return new Object[] { new LocalFileStorage( sourceFile ) }; + if (sourceFile.exists() && sourceFile.isFile()) { + return new Object[] { new LocalFileStorage(sourceFile) }; } return new Object[0]; @@ -119,20 +116,19 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName() */ public String getName() { - return SourceLookupMessages.getString("ProgramRelativePathSourceContainer.0"); //$NON-NLS-1$ + return SourceLookupMessages.ProgramRelativePathSourceContainer_0; } /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType() */ public ISourceContainerType getType() { - return getSourceContainerType( TYPE_ID ); + return getSourceContainerType(TYPE_ID); } private synchronized IPath getProgramLocation() throws CoreException { - // compute fProgramPath only if doesn't exist already - if (fProgramPath.isEmpty()){ + if (fProgramPath.isEmpty()) { // get launch configuration ISourceLookupDirector director = getDirector(); if (director == null) { @@ -147,7 +143,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ // executables that are not in an Eclipse project, so this may be // null for a DSF session. See bugzilla 304433. ICProject project = null; - String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null); + String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null); if (projectName != null) { project = CoreModel.getDefault().getCModel().getCProject(projectName); if (project == null || !project.exists()) { @@ -157,7 +153,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ // get program name String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); - if (programName == null){ + if (programName == null) { return fProgramPath; // return empty path } @@ -166,8 +162,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ try { if (project != null) { exeFile = project.getProject().getFile(new Path(programName)); - } - else { + } else { // A DSF launch config need not reference a project. Try // treating program name as either an absolute path or a // path relative to the working directory @@ -175,18 +170,15 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ if (path.toFile().exists()) { fProgramPath = path; return fProgramPath; - } - else { + } else { return fProgramPath; // return empty path } } - - } - catch (IllegalArgumentException e){ + } catch (IllegalArgumentException e) { return fProgramPath; // return empty path } - if (!exeFile.exists()){ + if (!exeFile.exists()) { return fProgramPath; // return empty path } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupMessages.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupMessages.java index 6642ac23e17..91d23ede9e4 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupMessages.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupMessages.java @@ -6,29 +6,23 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX Software Systems - Initial API and implementation + * QNX Software Systems - Initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.debug.core.sourcelookup; -import java.util.MissingResourceException; -import java.util.ResourceBundle; +import org.eclipse.osgi.util.NLS; -public class SourceLookupMessages { +class SourceLookupMessages extends NLS { + public static String MappingSourceContainer_0; + public static String AbsolutePathSourceContainer_0; + public static String ProgramRelativePathSourceContainer_0; - private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.core.sourcelookup.SourceLookupMessages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); + static { + NLS.initializeMessages(SourceLookupMessages.class.getName(), SourceLookupMessages.class); + } private SourceLookupMessages() { - } - - public static String getString( String key ) { - // TODO Auto-generated method stub - try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { - return '!' + key + '!'; - } + // Do not instantiate } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupMessages.properties b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupMessages.properties index 4e040be40e4..a8e9c710d31 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupMessages.properties +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupMessages.properties @@ -9,6 +9,6 @@ # QNX Software Systems - initial API and implementation # Nokia - added support for AbsolutePathSourceContainer ############################################################################### -MappingSourceContainer.0=Source lookup error -AbsolutePathSourceContainer.0=Absolute File Path -ProgramRelativePathSourceContainer.0=Program Relative File Path +MappingSourceContainer_0=Source lookup error +AbsolutePathSourceContainer_0=Absolute File Path +ProgramRelativePathSourceContainer_0=Program Relative File Path