Skip to content

Commit

Permalink
Removes unnecessary quotes in coding in markdown documents
Browse files Browse the repository at this point in the history
  • Loading branch information
jnerlich authored and vogella committed Feb 15, 2024
1 parent f88d2cf commit a8f5ea3
Show file tree
Hide file tree
Showing 18 changed files with 89 additions and 113 deletions.
8 changes: 4 additions & 4 deletions docs/FAQ/FAQ_How_do_I_add_a_builder_to_a_given_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ To register the eScript builder for a given project, add the builder to the proj

private void addBuilder(IProject project, String id) {
IProjectDescription desc = project.getDescription();
ICommand\[\] commands = desc.getBuildSpec();
ICommand[] commands = desc.getBuildSpec();
for (int i = 0; i < commands.length; ++i)
if (commands\[i\].getBuilderName().equals(id))
if (commands[i].getBuilderName().equals(id))
return;
//add builder to project
ICommand command = desc.newCommand();
command.setBuilderName(id);
ICommand\[\] nc = new ICommand\[commands.length + 1\];
ICommand[] nc = new ICommand[commands.length + 1];
// Add it before other builders.
System.arraycopy(commands, 0, nc, 1, commands.length);
nc\[0\] = command;
nc[0] = command;
desc.setBuildSpec(nc);
project.setDescription(desc, null);
}
Expand Down
18 changes: 9 additions & 9 deletions docs/FAQ/FAQ_How_do_I_create_a_dialog_with_a_details_area.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ If you want to provide more information in the details area, you need to supply

Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat();
String\[\] patterns = new String\[\] {
String[] patterns = new String[] {
"EEEE", "yyyy", "MMMM", "h 'o''clock'"};
String\[\] prefixes = new String\[\] {
String[] prefixes = new String[] {
"Today is ", "The year is ", "It is ", "It is "};
String\[\] msg = new String\[patterns.length\];
String[] msg = new String\[patterns.length\];
for (int i = 0; i < msg.length; i++) {
format.applyPattern(patterns\[i\]);
msg\[i\] = prefixes\[i\] + format.format(date);
format.applyPattern(patterns[i]);
msg[i] = prefixes[i] + format.format(date);
}
final String PID = ExamplesPlugin.ID;
MultiStatus info = new MultiStatus(PID, 1, msg\[0\], null);
info.add(new Status(IStatus.INFO, PID, 1, msg\[1\], null));
info.add(new Status(IStatus.INFO, PID, 1, msg\[2\], null));
info.add(new Status(IStatus.INFO, PID, 1, msg\[3\], null));
MultiStatus info = new MultiStatus(PID, 1, msg[0], null);
info.add(new Status(IStatus.INFO, PID, 1, msg[1], null));
info.add(new Status(IStatus.INFO, PID, 1, msg[2], null));
info.add(new Status(IStatus.INFO, PID, 1, msg[3], null));
ErrorDialog.openError(window.getShell(), "Time", null, info);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Here is a simple example of an advisor that creates two menus-**Window** and **H

public void fillActionBars(IWorkbenchWindow window,
IActionBarConfigurer configurer, int flags) {
if ((flags & FILL\_MENU\_BAR) == 0)
if ((flags & FILL_MENU_BAR) == 0)
return;
IMenuManager mainMenu = configurer.getMenuManager();
MenuManager windowMenu = new MenuManager("&Window",
Expand All @@ -31,13 +31,13 @@ For simplicity, this snippet creates new actions each time fillActionBars is cal
//configurer is provided by initialize method
private IWorkbenchConfigurer configurer = ...;
private static final String MENU_ACTIONS = &menu.actions&;
private IAction\[\] getMenuActions(IWorkbenchWindow window) {
private IAction[] getMenuActions(IWorkbenchWindow window) {
IWorkbenchWindowConfigurer wwc =
configurer.getWindowConfigurer(window);
IAction\[\] actions = (IAction\[\]) wwc.getData(MENU_ACTIONS);
IAction[] actions = (IAction[]) wwc.getData(MENU_ACTIONS);
if (actions == null) {
IAction max = ActionFactory.MAXIMIZE.create(window);
actions = new IAction\[\] {max};
actions = new IAction[] {max};
wwc.setData(MENU_ACTIONS, actions);
}
return actions;
Expand All @@ -55,5 +55,5 @@ Note that WorkbenchAdvisor fillActionBars is deprecated and ActionBarAdvisor.fil
See Also:
---------

[FAQ\_How\_do\_I\_build\_menus\_and\_toolbars\_programmatically?](./FAQ_How_do_I_build_menus_and_toolbars_programmatically.md "FAQ How do I build menus and toolbars programmatically?")
[FAQ How do I build menus and toolbars programmatically?](./FAQ_How_do_I_build_menus_and_toolbars_programmatically.md "FAQ How do I build menus and toolbars programmatically?")

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ How to get all IConfigurationElement objects more simply?
You can also get all IConfigurationElement objects without retrieving each extension by using following code:

IExtensionRegistry reg = Platform.getExtensionRegistry();
IConfigurationElement\[\] elements = reg.getConfigurationElementsFor("Extension Point ID");
IConfigurationElement[] elements = reg.getConfigurationElementsFor("Extension Point ID");

See Also:
---------
Expand Down
24 changes: 11 additions & 13 deletions docs/FAQ/FAQ_How_do_I_find_out_what_view_or_editor_is_selected.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@


FAQ How do I find out what view or editor is selected?
======================================================

To find out what view or editor is selected, use the IPartService. As with ISelectionService, you can add a listener to this service to track the active part or simply query it whenever you need to know. Note, saying that the part is _active_ does not imply that it has _focus_. If a dialog opens on top of the workbench window, the active part does not change, even though the active part loses focus. The part service will also notify you when parts are closed, hidden, brought to the top of a stack, and during other lifecycle events.

Two types of listeners can be added to the part service: IPartListener and the poorly named IPartListener2. You should always use this second one as it can handle part-change events on parts that have not yet been created because they are hidden in a stack behind another part. This listener will also tell you when a part is made visible or hidden or when an editor's input is changed:

IWorkbenchPage page = ...;
//the active part
IWorkbenchPart active = page.getActivePart();
//adding a listener
IPartListener2 pl = new IPartListener2() {
public void partActivated(IWorkbenchPartReference ref) {
System.out.println("Active: "+ref.getTitle());
}
... other listener methods ...
};
page.addPartListener(pl);
IWorkbenchPage page = ...;
//the active part
IWorkbenchPart active = page.getActivePart();
//adding a listener
IPartListener2 pl = new IPartListener2() {
public void partActivated(IWorkbenchPartReference ref) {
System.out.println("Active: "+ref.getTitle());
}
... other listener methods ...
};
page.addPartListener(pl);

IWorkbenchPage implements IPartService directly. You can also access a activation service by using IWorkbenchWindow.getPartService.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ The JDT has support for so-called Quick Fixes. Whenever a marker is generated, a
The implementation class implements the IMarkerResolutionGenerator interface. Use the IMarkerResolutionGenerator2 when resolutions are expensive to implement. See the javadoc for the interface for an explanation. Here is what the implementation class may look like:

public class QuickFixer implements IMarkerResolutionGenerator {
public IMarkerResolution\[\] getResolutions(IMarker mk) {
public IMarkerResolution[] getResolutions(IMarker mk) {
try {
Object problem = mk.getAttribute("WhatsUp");
return new IMarkerResolution\[\] {
return new IMarkerResolution[] {
new QuickFix("Fix #1 for "+problem),
new QuickFix("Fix #2 for "+problem),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To implement an incremental project builder, you first have to create an extensi
The second step is to create a builder class that must extend the abstract IncrementalProjectBuilder superclass:

public class Builder extends IncrementalProjectBuilder {
protected IProject\[\] build(int kind, Map args,
protected IProject[] build(int kind, Map args,
IProgressMonitor monitor) {
if (kind == IncrementalProjectBuilder.FULL_BUILD) {
fullBuild(monitor);
Expand Down
4 changes: 2 additions & 2 deletions docs/FAQ/FAQ_How_do_I_launch_a_Java_program.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ With those plug-ins added to your dependent plug-in list, your Java program can
IVMInstall vm = JavaRuntime.getVMInstall(proj);
if (vm == null) vm = JavaRuntime.getDefaultVMInstall();
IVMRunner vmr = vm.getVMRunner(ILaunchManager.RUN_MODE);
String\[\] cp = JavaRuntime.
String[] cp = JavaRuntime.
computeDefaultRuntimeClassPath(proj);
VMRunnerConfiguration config =
new VMRunnerConfiguration(main, cp);
Expand Down Expand Up @@ -54,5 +54,5 @@ More information is available at **Help > Help Contents > JDT Plug-in Developer
See Also:
---------

[FAQ\_What\_is\_a\_launch_configuration?](./FAQ_What_is_a_launch_configuration.md "FAQ What is a launch configuration?")
[FAQ What is a launch configuration?](./FAQ_What_is_a_launch_configuration.md "FAQ What is a launch configuration?")

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The `org.eclipse.ui.dialogs.PreferencesUtil` in bundle `org.eclipse.ui.workbench

PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
shell, "org.eclipse.licensing.ui.licensesPreferencePage",
new String\[\] {"org.eclipse.licensing.ui.licensesPreferencePage"}, null);
new String[] {"org.eclipse.licensing.ui.licensesPreferencePage"}, null);
dialog.open();

Alternative solution
Expand Down
16 changes: 8 additions & 8 deletions docs/FAQ/FAQ_How_do_I_make_my_plug-in_dynamic_aware.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ The cache has a startup method that loads the initial set of extensions and then
public void startup() {
IExtensionRegistry reg = Platform.getExtensionRegistry();
IExtensionPoint pt = reg.getExtensionPoint(PT_ID);
IExtension\[\] ext = pt.getExtensions();
IExtension[] ext = pt.getExtensions();
for (int i = 0; i < ext.length; i++)
extensions.add(ext\[i\]);
extensions.add(ext[i]);
reg.addRegistryChangeListener(this);
}

The class implements the IRegistryChangeListener interface, which has a single method that is called whenever the registry changes:

public void registryChanged(IRegistryChangeEvent event) {
IExtensionDelta\[\] deltas =
IExtensionDelta[] deltas =
event.getExtensionDeltas(PID, PT_ID);
for (int i = 0; i < deltas.length; i++) {
if (deltas\[i\].getKind() == IExtensionDelta.ADDED)
extensions.add(deltas\[i\].getExtension());
if (deltas[i].getKind() == IExtensionDelta.ADDED)
extensions.add(deltas[i].getExtension());
else
extensions.remove(deltas\[i\].getExtension());
extensions.remove(deltas[i].getExtension());
}
}

Expand All @@ -58,6 +58,6 @@ If you hold onto classes defined in other plug-ins through different mechanisms,
See Also:
---------

* [FAQ\_What\_is\_a\_dynamic_plug-in?](./FAQ_What_is_a_dynamic_plug-in.md "FAQ What is a dynamic plug-in?")
* [FAQ\_How\_do\_I\_make\_my\_plug-in\_dynamic\_enabled?](./FAQ_How_do_I_make_my_plug-in_dynamic_enabled.md "FAQ How do I make my plug-in dynamic enabled?")
* [FAQ What is a dynamic plug-in?](./FAQ_What_is_a_dynamic_plug-in.md "FAQ What is a dynamic plug-in?")
* [FAQ How do I make my plug-in dynamic enabled?](./FAQ_How_do_I_make_my_plug-in_dynamic_enabled.md "FAQ How do I make my plug-in dynamic enabled?")

Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@


FAQ How do I prompt the user to select a file or a directory?
=============================================================

SWT provides native dialogs for asking the user to select a file (FileDialog) or a directory (DirectoryDialog). Both dialogs allow you to specify an initial directory (setFilterPath), and FileDialog also allows you to specify an initial selection (setFileName). Neither of these settings will restrict the user's ultimate choice as the dialogs allow the user to browse to another directory regardless of the filter path. FileDialog also allows you to specify permitted file extensions (setFilterExtensions), and the dialog will not let the user select a file whose extension does not match one of the filters. The following example usage of FileDialog asks the user to open an HTML file:

FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String \[\] {"*.html"});
dialog.setFilterPath("c:\\\temp");
dialog.setFilterExtensions(new String [] {"*.html"});
dialog.setFilterPath("c:\\temp");
String result = dialog.open();




By default, FileDialog allows the user to select only a single file, but with the SWT.MULTI style bit, it can be configured for selecting multiple files. In this case, you can obtain the result by using the getFileNames method. The returned file names will always be relative to the filter path, so be sure to prefix the filter path to the result to obtain the full path.







See Also:
---------

[FAQ\_How\_do\_I\_prompt\_the\_user\_to\_select\_a\_resource?](./FAQ_How_do_I_prompt_the_user_to_select_a_resource.md "FAQ How do I prompt the user to select a resource?")
[FAQ How do I prompt the user to select a resource?](./FAQ_How_do_I_prompt_the_user_to_select_a_resource.md "FAQ How do I prompt the user to select a resource?")

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


FAQ How do I store extra properties on a resource?
==================================================

Expand All @@ -10,7 +8,7 @@ Table 17.1 provides a high-level view of the various forms of metadata, along wi
|   | **Speed** | **Footprint** | **Notify** | **Persistence** | **Types** | **Size constraints?** |
| --- | --- | --- | --- | --- | --- | --- |
| Markers | Good | Medium | Yes | Save; snapshot | String, int, boolean | No |
| Sync info | Good | Medium | Yes | Save; snapshot | byte\[\] | ?? |
| Sync info | Good | Medium | Yes | Save; snapshot | byte[] | ?? |
| Session Property | Fast | Medium | No | None | Object | No |
| Persistent Property | Slow | None | No | Immediate | String | Yes: 2K, exception thrown on overflow |
| Project Preferences | Slow | Small (preference cache) | Yes | Immediate | String, all primitive types | No |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@


FAQ How do I support multiple natural languages in my plug-in messages?
=======================================================================

Almost all plug-ins in Eclipse use java.util.ResourceBundle, a messages.properties file, and look up messages by using a key. The MessageFormat class can be used to insert parameters into the translated message. Here is an example:

String translate(String key, String\[\] parms) {
String translate(String key, String[] parms) {
try {
ResourceBundle bundle =
ResourceBundle.getBundle("messages");
Expand Down
10 changes: 5 additions & 5 deletions docs/FAQ/FAQ_How_do_I_write_an_editor_for_my_own_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ Our configuration looks like this:
ISourceViewer sourceViewer) {
PresentationReconciler pr = new PresentationReconciler();
DefaultDamagerRepairer ddr = new DefaultDamagerRepairer('''new Scanner()''');
pr.setRepairer(ddr, IDocument.DEFAULT\_CONTENT\_TYPE);
pr.setDamager(ddr, IDocument.DEFAULT\_CONTENT\_TYPE);
pr.setRepairer(ddr, IDocument.DEFAULT_CONTENT_TYPE);
pr.setDamager(ddr, IDocument.DEFAULT_CONTENT_TYPE);
return pr;
}
IContentAssistant getContentAssistant(ISourceViewer sv) {
ContentAssistant ca = new ContentAssistant();
IContentAssistProcessor cap = '''new CompletionProcessor()''';
ca.setContentAssistProcessor(cap, IDocument.DEFAULT\_CONTENT\_TYPE);
ca.setContentAssistProcessor(cap, IDocument.DEFAULT_CONTENT_TYPE);
ca.setInformationControlCreator(getInformationControlCreator(sv));
return ca;
}
Expand Down Expand Up @@ -76,9 +76,9 @@ For scanning the underlying document to draw it using different colors and fonts
Token string = new Token(new TextAttribute(Editor.STRING));
//add tokens for each reserved word
for (int n = 0; n < Parser.KEYWORDS.length; n++) {
rule.addWord(Parser.KEYWORDS\[n\], keyword);
rule.addWord(Parser.KEYWORDS[n], keyword);
}
setRules(new IRule\[\] {
setRules(new IRule[] {
rule,
new SingleLineRule("#", null, comment),
new SingleLineRule("\\"", "\\"", string, '\\\'),
Expand Down
16 changes: 7 additions & 9 deletions docs/FAQ/FAQ_How_do_I_write_to_the_console_from_a_plug-in.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


FAQ How do I write to the console from a plug-in?
=================================================

Expand All @@ -14,13 +12,13 @@ Prior to Eclipse 3.0, each plug-in that wanted console-like output created its o
private MessageConsole findConsole(String name) {
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
IConsole\[\] existing = conMan.getConsoles();
IConsole[] existing = conMan.getConsoles();
for (int i = 0; i < existing.length; i++)
if (name.equals(existing\[i\].getName()))
return (MessageConsole) existing\[i\];
if (name.equals(existing[i].getName()))
return (MessageConsole) existing[i];
//no console found, so create a new one
MessageConsole myConsole = new MessageConsole(name, null);
conMan.addConsoles(new IConsole\[\]{myConsole});
conMan.addConsoles(new IConsole[]{myConsole});
return myConsole;
}

Expand All @@ -36,7 +34,7 @@ Creating a console and writing to it do not create or reveal the Console view. I

IConsole myConsole = ...;// your console instance
IWorkbenchPage page = ...;// [obtain the active page](./FAQ_How_do_I_find_the_active_workbench_page.md "FAQ How do I find the active workbench page?")
String id = IConsoleConstants.ID\_CONSOLE\_VIEW;
String id = IConsoleConstants.ID_CONSOLE_VIEW;
IConsoleView view = (IConsoleView) page.showView(id);
view.display(myConsole);

Expand All @@ -45,7 +43,7 @@ Creating a console and writing to it do not create or reveal the Console view. I
See Also:
---------

[FAQ\_How\_do\_I\_use\_the\_platform\_debug\_tracing_facility?](./FAQ_How_do_I_use_the_platform_debug_tracing_facility.md "FAQ How do I use the platform debug tracing facility?")
[FAQ How do I use the platform debug tracing facility?](./FAQ_How_do_I_use_the_platform_debug_tracing_facility.md "FAQ How do I use the platform debug tracing facility?")

[FAQ\_How\_do\_I\_use\_the\_text\_document\_model?](./FAQ_How_do_I_use_the_text_document_model.md "FAQ How do I use the text document model?")
[FAQ How do I use the text document model?](./FAQ_How_do_I_use_the_text_document_model.md "FAQ How do I use the text document model?")

0 comments on commit a8f5ea3

Please sign in to comment.