1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Externalized strings

This commit is contained in:
Alena Laskavaia 2010-05-07 02:58:31 +00:00
parent c2bf10a787
commit e0ee9359b1
22 changed files with 149 additions and 47 deletions

View file

@ -11,7 +11,7 @@ import org.osgi.framework.BundleContext;
public class CheckersUiActivator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers.ui";
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.checkers.ui"; //$NON-NLS-1$
// The shared instance
private static CheckersUiActivator plugin;

View file

@ -32,6 +32,6 @@ public class CxxBranchNode extends BranchNode {
*/
@Override
public String toString() {
return labelData.getRawSignature()+":";
return labelData.getRawSignature()+":"; //$NON-NLS-1$
}
}

View file

@ -37,7 +37,7 @@ public class CxxDecisionNode extends DecisionNode {
*/
public String toStringData() {
if (getNode() == null)
return "";
return ""; //$NON-NLS-1$
return getNode().getRawSignature();
}
}

View file

@ -38,7 +38,7 @@ public class CxxExitNode extends ExitNode implements IExitNode {
*/
public String toStringData() {
if (getNode() == null)
return "return; // fake";
return "return; // fake"; //$NON-NLS-1$
return getNode().getRawSignature();
}
}

View file

@ -39,7 +39,7 @@ public class CxxPlainNode extends PlainNode {
*/
public String toStringData() {
if (getNode() == null)
return "";
return ""; //$NON-NLS-1$
return getNode().getRawSignature();
}
}

View file

@ -30,6 +30,6 @@ public class CxxStartNode extends StartNode {
*/
@Override
public String toString() {
return "start";
return "start"; //$NON-NLS-1$
}
}

View file

@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2009,2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.core;
import org.eclipse.osgi.util.NLS;
/**
* TODO: add description
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.core.messages"; //$NON-NLS-1$
public static String CodanApplication_3;
public static String CodanApplication_all_option;
public static String CodanApplication_Error_ProjectDoesNotExists;
public static String CodanApplication_LogRunProject;
public static String CodanApplication_LogRunWorkspace;
public static String CodanApplication_Options;
public static String CodanApplication_Usage;
public static String CodanApplication_verbose_option;
public static String CodanBuilder_Code_Analysis_On;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -0,0 +1,8 @@
CodanApplication_Error_ProjectDoesNotExists=Error: project {0} does not exist
CodanApplication_LogRunProject=Launching analysis on project
CodanApplication_LogRunWorkspace=Launching analysis on workspace
CodanApplication_Usage=Usage: [options] <project1> <project2> ...
CodanApplication_Options=Options:
CodanApplication_all_option= -all - run on all projects in workspace
CodanApplication_verbose_option= -verbose - print extra build information
CodanBuilder_Code_Analysis_On=Code analysis on

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.Messages;
import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@ -12,6 +13,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.osgi.util.NLS;
/**
*
@ -40,21 +42,23 @@ public class CodanApplication implements IApplication {
public void reportProblem(String id, String markerType,
int severity, IFile file, int lineNumber, int startChar,
int endChar, String message) {
System.out.println(file.getLocation() + ":" + lineNumber + ": "
System.out.println(file.getLocation() + ":" + lineNumber + ": " //$NON-NLS-1$ //$NON-NLS-2$
+ message);
}
});
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
if (all) {
log("Launching analysis on workspace");
log(Messages.CodanApplication_LogRunWorkspace);
codanBuilder.processResource(root, new NullProgressMonitor());
} else {
for (String project : projects) {
log("Launching analysis on project " + project);
log(Messages.CodanApplication_LogRunProject + project);
IProject wProject = root.getProject(project);
if (!wProject.exists()) {
System.err.println("Error: project " + project
+ " does not exist");
System.err.println( //
NLS.bind(
Messages.CodanApplication_Error_ProjectDoesNotExists,
project));
continue;
}
codanBuilder.processResource(wProject,
@ -78,9 +82,9 @@ public class CodanApplication implements IApplication {
private void extractArguments(String[] args) {
for (int i = 0; i < args.length; i++) {
String string = args[i];
if (string.equals("-verbose")) {
if (string.equals("-verbose")) { //$NON-NLS-1$
verbose = true;
} else if (string.equals("-all")) {
} else if (string.equals("-all")) { //$NON-NLS-1$
all = true;
} else {
projects.add(string);
@ -92,10 +96,10 @@ public class CodanApplication implements IApplication {
*
*/
private void help() {
System.out.println("Usage: [options] <project1> <project2> ...");
System.out.println("Options:");
System.out.println(" -all - run on all projects in workspace");
System.out.println(" -verbose - print extra build information");
System.out.println(Messages.CodanApplication_Usage);
System.out.println(Messages.CodanApplication_Options);
System.out.println(Messages.CodanApplication_all_option);
System.out.println(Messages.CodanApplication_verbose_option);
}
public void stop() {

View file

@ -14,6 +14,7 @@ import java.util.Map;
import org.eclipse.cdt.codan.core.CodanCorePlugin;
import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.core.Messages;
import org.eclipse.cdt.codan.core.model.IChecker;
import org.eclipse.cdt.codan.core.model.ICodanBuilder;
import org.eclipse.cdt.codan.core.model.IProblemReporter;
@ -105,7 +106,7 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
}
int tick = 1000;
// System.err.println("processing " + resource);
monitor.beginTask("Code analysis on " + resource, checkers + memsize
monitor.beginTask(Messages.CodanBuilder_Code_Analysis_On + resource, checkers + memsize
* tick);
try {
IProblemReporter problemReporter = CodanRuntime.getInstance()

View file

@ -44,13 +44,13 @@ public abstract class AbstractBasicBlock implements IBasicBlock {
*/
public String toStringData() {
if (getData() == null)
return "0x" + Integer.toHexString(System.identityHashCode(this));
return "0x" + Integer.toHexString(System.identityHashCode(this)); //$NON-NLS-1$
return getData().toString();
}
@Override
public String toString() {
return getClass().getSimpleName() + ": " + toStringData();
return getClass().getSimpleName() + ": " + toStringData(); //$NON-NLS-1$
}
/**

View file

@ -75,7 +75,7 @@ public class ControlFlowGraph implements IControlFlowGraph {
}
public void print(IBasicBlock node) {
System.out.println(node.getClass().getSimpleName() + ": "
System.out.println(node.getClass().getSimpleName() + ": " //$NON-NLS-1$
+ ((AbstractBasicBlock) node).toStringData());
if (node instanceof IDecisionNode) {
// todo
@ -83,9 +83,9 @@ public class ControlFlowGraph implements IControlFlowGraph {
.getOutgoingIterator();
for (; branches.hasNext();) {
IBasicBlock brNode = branches.next();
System.out.println("{");
System.out.println("{"); //$NON-NLS-1$
print(brNode);
System.out.println("}");
System.out.println("}"); //$NON-NLS-1$
}
print(((IDecisionNode) node).getMergeNode());
} else if (node instanceof ISingleOutgoing) {
@ -118,15 +118,14 @@ public class ControlFlowGraph implements IControlFlowGraph {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.cdt.codan.core.model.cfg.IControlFlowGraph#getNodes
* ()
* @see org.eclipse.cdt.codan.core.model.cfg.IControlFlowGraph#getNodes ()
*/
public Collection<IBasicBlock> getNodes() {
Collection<IBasicBlock> result = new LinkedHashSet<IBasicBlock>();
getNodes(getStartNode(), result);
for (Iterator iterator = deadNodes.iterator(); iterator.hasNext();) {
IBasicBlock d = (IBasicBlock) iterator.next();
for (Iterator<IBasicBlock> iterator = deadNodes.iterator(); iterator
.hasNext();) {
IBasicBlock d = iterator.next();
getNodes(d, result);
}
return result;

View file

@ -98,7 +98,7 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
marker.setAttribute(IMarker.PROBLEM, id);
marker.setAttribute(IMarker.CHAR_END, endChar);
marker.setAttribute(IMarker.CHAR_START, startChar);
marker.setAttribute("org.eclipse.cdt.core.problem", 42);
marker.setAttribute("org.eclipse.cdt.core.problem", 42); //$NON-NLS-1$
} catch (CoreException e) {
e.printStackTrace();
}

View file

@ -15,7 +15,8 @@
defaultSeverity="Info"
id="org.eclipse.cdt.codan.examples.checkers.NamingConventionFunctionProblem"
messagePattern="Bad function name (example) &quot;{0}&quot; (pattern /{1}/)"
name="Name convention for function (example)">
name="Name convention for function (example)"
markerType="org.eclipse.cdt.codan.core.codanProblem">
</problem>
</checker>
</extension>

View file

@ -63,7 +63,7 @@ public abstract class AbstractCodanCQuickFixProcessor implements IQuickFixProces
IMarker m = markers[i];
int start = m.getAttribute(IMarker.CHAR_START, -1);
if (start==loc.getOffset()) {
String id = m.getAttribute(IMarker.PROBLEM,"");
String id = m.getAttribute(IMarker.PROBLEM,""); //$NON-NLS-1$
return getCorrections(context, id, m);
}
}

View file

@ -28,7 +28,7 @@ import org.osgi.framework.BundleContext;
*/
public class CodanUIActivator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.ui";
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.ui"; //$NON-NLS-1$
// The shared instance
private static CodanUIActivator plugin;
private IPreferenceStore preferenceCoreStore;

View file

@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2009,2010 Alena Laskavaia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui;
import org.eclipse.osgi.util.NLS;
/**
* TODO: add description
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.codan.internal.ui.messages"; //$NON-NLS-1$
public static String BuildPropertyPage_RunAsYouType;
public static String BuildPropertyPage_RunWithBuild;
public static String CheckedTreeEditor_SelectionCannotBeEmpty;
public static String CodanPreferencePage_Customize;
public static String CodanPreferencePage_HasParameters;
public static String CodanPreferencePage_Info;
public static String CodanPreferencePage_NoInfo;
public static String CodanPreferencePage_NoParameters;
public static String ProblemsTreeEditor_NameColumn;
public static String ProblemsTreeEditor_Problems;
public static String ProblemsTreeEditor_SeverityColumn;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -1,6 +1,17 @@
BuildPropertyPage_RunAsYouType=Run as you &type (selected checkers)
BuildPropertyPage_RunWithBuild=&Run with build
CheckedTreeEditor_SelectionCannotBeEmpty=Selection cannot be empty
CodanPreferencePage_Customize=Customize...
CodanPreferencePage_HasParameters=This problem has parameters
CodanPreferencePage_Info=Info
CodanPreferencePage_NoInfo=No additional information
CodanPreferencePage_NoParameters=No parameters
CustomizeProblemComposite_TabParameters=Parameters
CustomizeProblemComposite_TabScope=Scope
CustomizeProblemDialog_Message=Edit problem parameters, scope and launch options
CustomizeProblemDialog_Title=Customize Problem...
Job_TitleRunningAnalysis=Running Code Analysis
ParametersComposite_None=No Parameters
ProblemsTreeEditor_NameColumn=Name
ProblemsTreeEditor_Problems=Problems
ProblemsTreeEditor_SeverityColumn=Severity

View file

@ -2,6 +2,7 @@ package org.eclipse.cdt.codan.internal.ui.preferences;
import org.eclipse.cdt.codan.core.PreferenceConstants;
import org.eclipse.cdt.codan.internal.ui.CodanUIActivator;
import org.eclipse.cdt.codan.internal.ui.Messages;
import org.eclipse.cdt.codan.internal.ui.actions.ToggleNatureAction;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdaptable;
@ -31,9 +32,9 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
@Override
protected void createFieldEditors() {
addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_ON_BUILD,
"&Run with build", getFieldEditorParent()));
Messages.BuildPropertyPage_RunWithBuild, getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_IN_EDITOR,
"Run as you &type (selected checkers)", getFieldEditorParent()));
Messages.BuildPropertyPage_RunAsYouType, getFieldEditorParent()));
}
@Override
@ -90,6 +91,6 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
}
protected String getPageId() {
return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage";
return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage"; //$NON-NLS-1$
}
}

View file

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.codan.internal.ui.preferences;
import org.eclipse.cdt.codan.internal.ui.Messages;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
@ -312,7 +313,7 @@ public abstract class CheckedTreeEditor extends FieldEditor implements
if (!emptySelectionAllowed) {
Object[] checkedElements = getTreeViewer().getCheckedElements();
if (checkedElements.length == 0) {
showErrorMessage("Selection cannot be empty");
showErrorMessage(Messages.CheckedTreeEditor_SelectionCannotBeEmpty);
return false;
}
}

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemParameterInfo;
import org.eclipse.cdt.codan.core.model.IProblemProfile;
import org.eclipse.cdt.codan.internal.ui.Messages;
import org.eclipse.cdt.codan.internal.ui.dialogs.CustomizeProblemDialog;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.preferences.InstanceScope;
@ -126,14 +127,14 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
info = new Group(comp, SWT.NONE);
info.setLayoutData(new GridData(GridData.FILL_BOTH));
info.setLayout(new GridLayout(2, false));
info.setText("Info");
info.setText(Messages.CodanPreferencePage_Info);
infoParams = new Label(info, SWT.NONE);
infoParams.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false,
false));
infoButton = new Button(info, SWT.PUSH);
infoButton
.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
infoButton.setText("Customize...");
infoButton.setText(Messages.CodanPreferencePage_Customize);
infoButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@ -180,17 +181,17 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
*/
private void updateProblemInfo() {
if (selectedProblem == null) {
infoMessage.setText("");
infoParams.setText("");
infoMessage.setText(""); //$NON-NLS-1$
infoParams.setText(""); //$NON-NLS-1$
infoButton.setEnabled(false);
} else {
IProblemParameterInfo parameterInfo = selectedProblem
.getParameterInfo();
String desc = selectedProblem.getDescription();
infoMessage.setText(desc == null ? "No additional information"
infoMessage.setText(desc == null ? Messages.CodanPreferencePage_NoInfo
: desc);
infoParams.setText(parameterInfo == null ? "No parameters"
: "This problem has parameters");
infoParams.setText(parameterInfo == null ? Messages.CodanPreferencePage_NoParameters
: Messages.CodanPreferencePage_HasParameters);
infoButton.setEnabled(true);
}
info.layout(true);

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.codan.core.model.IProblemElement;
import org.eclipse.cdt.codan.core.model.IProblemProfile;
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.codan.internal.core.CodanPreferencesLoader;
import org.eclipse.cdt.codan.internal.ui.Messages;
import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
@ -145,7 +146,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
public ProblemsTreeEditor(Composite parent, IProblemProfile profile) {
super(PreferenceConstants.P_PROBLEMS, "Problems", parent);
super(PreferenceConstants.P_PROBLEMS, Messages.ProblemsTreeEditor_Problems, parent);
setEmptySelectionAllowed(true);
getTreeViewer().getTree().setHeaderVisible(true);
// getTreeViewer().getTree().
@ -154,7 +155,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
// column Name
TreeViewerColumn column1 = new TreeViewerColumn(getTreeViewer(), SWT.NONE);
column1.getColumn().setWidth(300);
column1.getColumn().setText("Name");
column1.getColumn().setText(Messages.ProblemsTreeEditor_NameColumn);
column1.setLabelProvider(new ColumnLabelProvider() {
public String getText(Object element) {
if (element instanceof IProblem) {
@ -171,7 +172,7 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
// column Severity
TreeViewerColumn column2 = new TreeViewerColumn(getTreeViewer(), SWT.NONE);
column2.getColumn().setWidth(100);
column2.getColumn().setText("Severity");
column2.getColumn().setText(Messages.ProblemsTreeEditor_SeverityColumn);
column2.setLabelProvider(new ColumnLabelProvider() {
@Override
public Image getImage(Object element) {
@ -298,6 +299,6 @@ public class ProblemsTreeEditor extends CheckedTreeEditor {
*/
@Override
protected String modelToString(Object model) {
return "";
return ""; //$NON-NLS-1$
}
}