Skip to content

Commit

Permalink
reuse ZERO_LENGTH_STRING utility
Browse files Browse the repository at this point in the history
  • Loading branch information
elsazac authored and akurtakov committed Jan 4, 2024
1 parent 7a3496e commit fe9b9f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private class ModelFragmentBundleTracker implements BundleTrackerCustomizer<List
@Override
public List<FragmentWrapperElementMapping> 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<ModelFragmentWrapper> wrappers = getModelFragmentWrapperFromBundle(bundle,
ModelAssembler.this.initial);
Expand Down Expand Up @@ -158,7 +158,7 @@ public void removedBundle(Bundle bundle, BundleEvent event, List<FragmentWrapper

// unload resource
String bundleName = bundle.getSymbolicName();
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 attrURI = fr[0];
Expand Down Expand Up @@ -227,8 +227,8 @@ public void removedBundle(Bundle bundle, BundleEvent event, List<FragmentWrapper
void activate(BundleContext bundleContext) {
this.bundleContext = bundleContext;

this.tracker = new BundleTracker<>(bundleContext,
Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING, new ModelFragmentBundleTracker());
this.tracker = new BundleTracker<>(bundleContext, Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING,
new ModelFragmentBundleTracker());
}

@Deactivate
Expand Down Expand Up @@ -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 <code>true</code> if running from a non-persisted state
* @param initial <code>true</code> if running from a non-persisted state
*/
@Execute
public void processModel(boolean initial) {
Expand Down Expand Up @@ -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$
}
}
}
Expand All @@ -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<ModelFragmentWrapper> collect = this.tracker.getTracked().values().stream()
.flatMap(List::stream).map(w -> w.wrapper).collect(Collectors.toList());
List<ModelFragmentWrapper> collect = this.tracker.getTracked().values().stream().flatMap(List::stream)
.map(w -> w.wrapper).collect(Collectors.toList());
wrappers.addAll(collect);
}

Expand All @@ -380,7 +380,7 @@ private void processFragments(IExtension[] extensions, boolean initial) {

private List<ModelFragmentWrapper> getModelFragmentWrapperFromBundle(Bundle bundle, boolean initial) {
List<ModelFragmentWrapper> 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];
Expand Down Expand Up @@ -501,8 +501,8 @@ public void processFragments(Collection<ModelFragmentWrapper> 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<MApplicationElement> addedElements = new ArrayList<>();

Expand All @@ -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<MApplicationElement> merged = processModelFragment(fragment, contributorURI, checkExist);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fe9b9f6

Please sign in to comment.