1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

NLS-style string resources. This change removes public visibility from SourceLookupMessages class that was given to it by mistake.

This commit is contained in:
Sergey Prigogin 2010-12-03 00:55:58 +00:00
parent f257c2f55d
commit 7791c5f8b3
6 changed files with 94 additions and 75 deletions

View file

@ -1,11 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.debug.core" version="2"> <component id="org.eclipse.cdt.debug.core" version="2">
<resource path="src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinder.java" type="org.eclipse.cdt.debug.internal.core.srcfinder.CSourceFinder"> <resource path="src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java" type="org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer">
<filter id="574619656"> <filter id="643846161">
<message_arguments> <message_arguments>
<message_argument value="ISourceFinder"/> <message_argument value="MapEntrySourceContainer"/>
<message_argument value="CSourceFinder"/> <message_argument value="MappingSourceContainer"/>
</message_arguments> <message_argument value="addMapEntries(MapEntrySourceContainer[])"/>
</filter> </message_arguments>
</resource> </filter>
<filter id="643846161">
<message_arguments>
<message_argument value="MapEntrySourceContainer"/>
<message_argument value="MappingSourceContainer"/>
<message_argument value="addMapEntry(MapEntrySourceContainer)"/>
</message_arguments>
</filter>
<filter id="643846161">
<message_arguments>
<message_argument value="MapEntrySourceContainer"/>
<message_argument value="MappingSourceContainer"/>
<message_argument value="removeMapEntries(MapEntrySourceContainer[])"/>
</message_arguments>
</filter>
<filter id="643846161">
<message_arguments>
<message_argument value="MapEntrySourceContainer"/>
<message_argument value="MappingSourceContainer"/>
<message_argument value="removeMapEntry(MapEntrySourceContainer)"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/debug/core/sourcelookup/SourceLookupMessages.java" type="org.eclipse.cdt.debug.core.sourcelookup.SourceLookupMessages">
<filter comment="SourceLookupMessages class is no longer public." id="305365105">
<message_arguments>
<message_argument value="org.eclipse.cdt.debug.core.sourcelookup.SourceLookupMessages"/>
<message_argument value="org.eclipse.cdt.debug.core_7.1.0"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinder.java" type="org.eclipse.cdt.debug.internal.core.srcfinder.CSourceFinder">
<filter id="574619656">
<message_arguments>
<message_argument value="ISourceFinder"/>
<message_argument value="CSourceFinder"/>
</message_arguments>
</filter>
</resource>
</component> </component>

View file

@ -9,7 +9,6 @@
* Nokia - Initial implementation (159833) * Nokia - Initial implementation (159833)
* Broadcom - http://bugs.eclipse.org/247853 * Broadcom - http://bugs.eclipse.org/247853
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.core.sourcelookup; package org.eclipse.cdt.debug.core.sourcelookup;
import java.io.File; 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. // The file is not already in the workspace so try to create an external translation unit for it.
ISourceLookupDirector director = getDirector(); ISourceLookupDirector director = getDirector();
if (director != null) if (director != null) {
{
ILaunchConfiguration launchConfiguration = director.getLaunchConfiguration(); ILaunchConfiguration launchConfiguration = director.getLaunchConfiguration();
if (launchConfiguration != null) if (launchConfiguration != null) {
{
String projectName = launchConfiguration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ String projectName = launchConfiguration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
if (projectName.length() > 0) { if (projectName.length() > 0) {
ICProject project = CoreModel.getDefault().getCModel().getCProject(projectName); ICProject project = CoreModel.getDefault().getCModel().getCProject(projectName);
if (project != null) if (project != null) {
{
IPath path = Path.fromOSString(file.getCanonicalPath()); IPath path = Path.fromOSString(file.getCanonicalPath());
String id = CoreModel.getRegistedContentTypeId(project.getProject(), path.lastSegment()); String id = CoreModel.getRegistedContentTypeId(project.getProject(), path.lastSegment());
return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, path, id) }; return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, path, id) };
@ -89,8 +85,7 @@ public class AbsolutePathSourceContainer extends AbstractSourceContainer {
*/ */
private IProject getProject() { private IProject getProject() {
ISourceLookupDirector director = getDirector(); ISourceLookupDirector director = getDirector();
if (director != null) if (director != null) {
{
ILaunchConfiguration config = director.getLaunchConfiguration(); ILaunchConfiguration config = director.getLaunchConfiguration();
if (config != null) { if (config != null) {
try { try {
@ -105,35 +100,33 @@ public class AbsolutePathSourceContainer extends AbstractSourceContainer {
return null; return null;
} }
public boolean isValidAbsoluteFilePath( String name ) public boolean isValidAbsoluteFilePath(String name) {
{ return isValidAbsoluteFilePath(new File(name));
return isValidAbsoluteFilePath( new File(name) );
} }
public boolean isValidAbsoluteFilePath( File file ) public boolean isValidAbsoluteFilePath(File file) {
{
return file.isAbsolute() && file.exists() && file.isFile(); return file.isAbsolute() && file.exists() && file.isFile();
} }
public Object[] findSourceElements( String name ) throws CoreException { public Object[] findSourceElements(String name) throws CoreException {
if ( name != null ) { if (name != null) {
File file = new File( name ); File file = new File(name);
if ( isValidAbsoluteFilePath(file) ) { if (isValidAbsoluteFilePath(file)) {
return findSourceElementByFile( file ); return findSourceElementByFile(file);
} }
} }
return new Object[0]; return new Object[0];
} }
public String getName() { public String getName() {
return SourceLookupMessages.getString( "AbsolutePathSourceContainer.0" ); //$NON-NLS-1$ return SourceLookupMessages.AbsolutePathSourceContainer_0;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType() * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
*/ */
public ISourceContainerType getType() { public ISourceContainerType getType() {
return getSourceContainerType( TYPE_ID ); return getSourceContainerType(TYPE_ID);
} }
@Override @Override

View file

@ -104,7 +104,9 @@ public class MappingSourceContainer extends AbstractSourceContainer {
if (single == null) { if (single == null) {
single = e; single = e;
} else if (multiStatus == null) { } 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()); multiStatus.add(e.getStatus());
} else { } else {
multiStatus.add(e.getStatus()); multiStatus.add(e.getStatus());

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Freescale - Initial implementation * Freescale - Initial implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.core.sourcelookup; package org.eclipse.cdt.debug.core.sourcelookup;
import java.io.File; import java.io.File;
@ -35,7 +34,6 @@ import org.eclipse.debug.core.ILaunchConfiguration;
* @since 7.0 * @since 7.0
*/ */
public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
/** /**
* Unique identifier for the relative path source container type * Unique identifier for the relative path source container type
* (value <code>org.eclipse.cdt.debug.core.containerType.programRelativePath</code>). * (value <code>org.eclipse.cdt.debug.core.containerType.programRelativePath</code>).
@ -83,21 +81,20 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
* *
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String) * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String)
*/ */
public Object[] findSourceElements( String sourceName ) throws CoreException { public Object[] findSourceElements(String sourceName) throws CoreException {
if (sourceName == null) {
if (sourceName == null){
return new Object[0]; return new Object[0];
} }
// check if source path is a relative path // check if source path is a relative path
IPath sourcePath = new Path(sourceName); IPath sourcePath = new Path(sourceName);
if (sourcePath.isAbsolute()){ if (sourcePath.isAbsolute()) {
return new Object[0]; return new Object[0];
} }
// get program (executable) absolute path // get program (executable) absolute path
IPath programPath = getProgramLocation(); IPath programPath = getProgramLocation();
if (programPath == Path.EMPTY){ if (programPath == Path.EMPTY) {
return new Object[0]; return new Object[0];
} }
@ -108,8 +105,8 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
// check if source file exists and is valid // check if source file exists and is valid
File sourceFile = sourcePath.toFile(); File sourceFile = sourcePath.toFile();
if ( sourceFile.exists() && sourceFile.isFile() ) { if (sourceFile.exists() && sourceFile.isFile()) {
return new Object[] { new LocalFileStorage( sourceFile ) }; return new Object[] { new LocalFileStorage(sourceFile) };
} }
return new Object[0]; return new Object[0];
@ -119,20 +116,19 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName() * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName()
*/ */
public String getName() { public String getName() {
return SourceLookupMessages.getString("ProgramRelativePathSourceContainer.0"); //$NON-NLS-1$ return SourceLookupMessages.ProgramRelativePathSourceContainer_0;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType() * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
*/ */
public ISourceContainerType getType() { public ISourceContainerType getType() {
return getSourceContainerType( TYPE_ID ); return getSourceContainerType(TYPE_ID);
} }
private synchronized IPath getProgramLocation() throws CoreException { private synchronized IPath getProgramLocation() throws CoreException {
// compute fProgramPath only if doesn't exist already // compute fProgramPath only if doesn't exist already
if (fProgramPath.isEmpty()){ if (fProgramPath.isEmpty()) {
// get launch configuration // get launch configuration
ISourceLookupDirector director = getDirector(); ISourceLookupDirector director = getDirector();
if (director == null) { if (director == null) {
@ -147,7 +143,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
// executables that are not in an Eclipse project, so this may be // executables that are not in an Eclipse project, so this may be
// null for a DSF session. See bugzilla 304433. // null for a DSF session. See bugzilla 304433.
ICProject project = null; 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) { if (projectName != null) {
project = CoreModel.getDefault().getCModel().getCProject(projectName); project = CoreModel.getDefault().getCModel().getCProject(projectName);
if (project == null || !project.exists()) { if (project == null || !project.exists()) {
@ -157,7 +153,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
// get program name // get program name
String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
if (programName == null){ if (programName == null) {
return fProgramPath; // return empty path return fProgramPath; // return empty path
} }
@ -166,8 +162,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
try { try {
if (project != null) { if (project != null) {
exeFile = project.getProject().getFile(new Path(programName)); exeFile = project.getProject().getFile(new Path(programName));
} } else {
else {
// A DSF launch config need not reference a project. Try // A DSF launch config need not reference a project. Try
// treating program name as either an absolute path or a // treating program name as either an absolute path or a
// path relative to the working directory // path relative to the working directory
@ -175,18 +170,15 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
if (path.toFile().exists()) { if (path.toFile().exists()) {
fProgramPath = path; fProgramPath = path;
return fProgramPath; return fProgramPath;
} } else {
else {
return fProgramPath; // return empty path return fProgramPath; // return empty path
} }
} }
} catch (IllegalArgumentException e) {
}
catch (IllegalArgumentException e){
return fProgramPath; // return empty path return fProgramPath; // return empty path
} }
if (!exeFile.exists()){ if (!exeFile.exists()) {
return fProgramPath; // return empty path return fProgramPath; // return empty path
} }

View file

@ -6,29 +6,23 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * 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; package org.eclipse.cdt.debug.core.sourcelookup;
import java.util.MissingResourceException; import org.eclipse.osgi.util.NLS;
import java.util.ResourceBundle;
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$ static {
NLS.initializeMessages(SourceLookupMessages.class.getName(), SourceLookupMessages.class);
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); }
private SourceLookupMessages() { private SourceLookupMessages() {
} // Do not instantiate
public static String getString( String key ) {
// TODO Auto-generated method stub
try {
return RESOURCE_BUNDLE.getString( key );
}
catch( MissingResourceException e ) {
return '!' + key + '!';
}
} }
} }

View file

@ -9,6 +9,6 @@
# QNX Software Systems - initial API and implementation # QNX Software Systems - initial API and implementation
# Nokia - added support for AbsolutePathSourceContainer # Nokia - added support for AbsolutePathSourceContainer
############################################################################### ###############################################################################
MappingSourceContainer.0=Source lookup error MappingSourceContainer_0=Source lookup error
AbsolutePathSourceContainer.0=Absolute File Path AbsolutePathSourceContainer_0=Absolute File Path
ProgramRelativePathSourceContainer.0=Program Relative File Path ProgramRelativePathSourceContainer_0=Program Relative File Path