From fe9b9f608c20b9b128abd6f356857e791d427031 Mon Sep 17 00:00:00 2001 From: Elsa Zacharia Date: Thu, 4 Jan 2024 09:30:15 +0530 Subject: [PATCH] reuse ZERO_LENGTH_STRING utility --- .../ConfigurationElementAdapter.java | 2 +- .../ui/internal/workbench/ModelAssembler.java | 31 +++++++++---------- .../internal/workbench/PartServiceImpl.java | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ConfigurationElementAdapter.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ConfigurationElementAdapter.java index 3eb4d5dc094..0ed60bf2354 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ConfigurationElementAdapter.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ConfigurationElementAdapter.java @@ -51,7 +51,7 @@ public Object getProperty(Object element, String id) { String idVal = ice.getAttribute("id"); //$NON-NLS-1$ String nameVal = ice.getAttribute("name"); //$NON-NLS-1$ - String constructedName = ""; //$NON-NLS-1$ + String constructedName = Util.ZERO_LENGTH_STRING; if (nameVal != null) { constructedName = nameVal; if (idVal != null) diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelAssembler.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelAssembler.java index 56c50517a5a..ba2e0c7ec9b 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelAssembler.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelAssembler.java @@ -111,7 +111,7 @@ private class ModelFragmentBundleTracker implements BundleTrackerCustomizer addingBundle(Bundle bundle, BundleEvent event) { // only react on bundles with Model-Fragment header - if (bundle.getHeaders("").get(MODEL_FRAGMENT_HEADER) != null) { //$NON-NLS-1$ + if (bundle.getHeaders(Util.ZERO_LENGTH_STRING).get(MODEL_FRAGMENT_HEADER) != null) { // add the fragment to the application model List wrappers = getModelFragmentWrapperFromBundle(bundle, ModelAssembler.this.initial); @@ -158,7 +158,7 @@ public void removedBundle(Bundle bundle, BundleEvent event, List 0) { String attrURI = fr[0]; @@ -227,8 +227,8 @@ public void removedBundle(Bundle bundle, BundleEvent event, List(bundleContext, - Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, new ModelFragmentBundleTracker()); + this.tracker = new BundleTracker<>(bundleContext, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, + new ModelFragmentBundleTracker()); } @Deactivate @@ -307,7 +307,7 @@ public void init(MApplication application, IEclipseContext context, UISynchroniz * Extension points will be sorted based on the dependencies of their * contributors. * - * @param initial true if running from a non-persisted state + * @param initial true if running from a non-persisted state */ @Execute public void processModel(boolean initial) { @@ -352,9 +352,9 @@ private void processFragments(IExtension[] extensions, boolean initial) { } for (MModelFragment fragment : fragmentsContainer.getFragments()) { boolean checkExist = !initial && NOTEXISTS.equals(ce.getAttribute("apply")); //$NON-NLS-1$ - wrappers.add(new ModelFragmentWrapper(fragmentsContainer, fragment, - ce.getContributor().getName(), URIHelper.constructPlatformURI(ce.getContributor()), - checkExist)); // $NON-NLS-1$ + wrappers.add( + new ModelFragmentWrapper(fragmentsContainer, fragment, ce.getContributor().getName(), + URIHelper.constructPlatformURI(ce.getContributor()), checkExist)); // $NON-NLS-1$ } } } @@ -370,8 +370,8 @@ private void processFragments(IExtension[] extensions, boolean initial) { // once the initial tracking is done we process the tracked bundles // this is for performance optimization on initial loading to avoid multiple // fragment merge operations - List collect = this.tracker.getTracked().values().stream() - .flatMap(List::stream).map(w -> w.wrapper).collect(Collectors.toList()); + List collect = this.tracker.getTracked().values().stream().flatMap(List::stream) + .map(w -> w.wrapper).collect(Collectors.toList()); wrappers.addAll(collect); } @@ -380,7 +380,7 @@ private void processFragments(IExtension[] extensions, boolean initial) { private List getModelFragmentWrapperFromBundle(Bundle bundle, boolean initial) { List wrappers = new ArrayList<>(); - String fragmentHeader = bundle.getHeaders("").get(MODEL_FRAGMENT_HEADER); //$NON-NLS-1$ + String fragmentHeader = bundle.getHeaders(Util.ZERO_LENGTH_STRING).get(MODEL_FRAGMENT_HEADER); String[] fr = fragmentHeader.split(";"); //$NON-NLS-1$ if (fr.length > 0) { String uri = fr[0]; @@ -501,8 +501,8 @@ public void processFragments(Collection fragmentList) { public void processFragment(MModelFragments fragmentsContainer, MModelFragment fragment, String contributorName, String contributorURI, boolean checkExist) { /** - * The application elements that were added by the given - * IConfigurationElement to the application model + * The application elements that were added by the given IConfigurationElement + * to the application model */ List addedElements = new ArrayList<>(); @@ -513,9 +513,8 @@ public void processFragment(MModelFragments fragmentsContainer, MModelFragment f Diagnostic validationResult = Diagnostician.INSTANCE.validate((EObject) fragment); int severity = validationResult.getSeverity(); if (severity == Diagnostic.ERROR) { - log(LogLevel.ERROR, - "Fragment from {} of {} could not be validated and was not merged: " //$NON-NLS-1$ - + fragment, contributorURI, contributorName); + log(LogLevel.ERROR, "Fragment from {} of {} could not be validated and was not merged: " //$NON-NLS-1$ + + fragment, contributorURI, contributorName); } List merged = processModelFragment(fragment, contributorURI, checkExist); diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java index 7177c9b1fca..3989f671859 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/PartServiceImpl.java @@ -868,7 +868,7 @@ public MPlaceholder createSharedPart(String id, boolean force) { if (!force) { int colonIndex = id.indexOf(':'); if (colonIndex >= 0) { - String remId = ""; //$NON-NLS-1$ + String remId = Util.ZERO_LENGTH_STRING; try { remId = id.substring(colonIndex + 1); } catch (StringIndexOutOfBoundsException e) {