1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +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">
<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>
<resource path="src/org/eclipse/cdt/debug/core/sourcelookup/MappingSourceContainer.java" type="org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer">
<filter id="643846161">
<message_arguments>
<message_argument value="MapEntrySourceContainer"/>
<message_argument value="MappingSourceContainer"/>
<message_argument value="addMapEntries(MapEntrySourceContainer[])"/>
</message_arguments>
</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>

View file

@ -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

View file

@ -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());

View file

@ -8,7 +8,6 @@
* Contributors:
* 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 <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)
*/
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
}

View file

@ -7,28 +7,22 @@
*
* Contributors:
* 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
}
}

View file

@ -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