Skip to content

Commit

Permalink
[sonar] Fix issues
Browse files Browse the repository at this point in the history
Change-Id: I0000000000000000000000000000000000000000
Signed-off-by: Arnaud Dieumegard <[email protected]>
  • Loading branch information
arnauddieumegard committed Jan 20, 2022
1 parent c0e380f commit 4ca8827
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public Collection<Resource> getDerivedSemanticResources(TransactionalEditingDoma
protected List<IDerivedSemanticResourceProvider> getAllDerivedSemanticResourceProviders() {
if (null == _derivedSemanticResourceProviders) {
_derivedSemanticResourceProviders = new ArrayList<IDerivedSemanticResourceProvider>();
List<IConfigurationElement> BQProvider = Arrays
List<IConfigurationElement> providers = Arrays
.asList(ExtensionPointHelper.getConfigurationElements(FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), DERIVED_SEMANTIC_RESOURCE_PROVIDER_EXTENSION_ID));
for (IConfigurationElement configurationElement : BQProvider) {
for (IConfigurationElement configurationElement : providers) {
IDerivedSemanticResourceProvider contrib = (IDerivedSemanticResourceProvider) ExtensionPointHelper
.createInstance(configurationElement, ExtensionPointHelper.ATT_CLASS);
if (contrib != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public class SemanticModelPreferences extends AbstractPreferenceInitializer impl
*/
@Override
public void initializeDefaultPreferences() {
new DefaultScope().getNode(FrameworkUtil.getBundle(this.getClass()).getSymbolicName()).putBoolean(ISemanticModelPreferences.KEY_SEMANTIC_MODE, true);
DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(this.getClass()).getSymbolicName()).putBoolean(ISemanticModelPreferences.KEY_SEMANTIC_MODE, true);
}

/**
* {@inheritDoc}
*/
public void setSemanticMode(boolean enabled_p) {
new InstanceScope().getNode(FrameworkUtil.getBundle(this.getClass()).getSymbolicName()).putBoolean(ISemanticModelPreferences.KEY_SEMANTIC_MODE, enabled_p);
InstanceScope.INSTANCE.getNode(FrameworkUtil.getBundle(this.getClass()).getSymbolicName()).putBoolean(ISemanticModelPreferences.KEY_SEMANTIC_MODE, enabled_p);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void initializeDefaultPreferences() {

Collection<IItemDescriptor> constraints = PreferencesItemsRegistry.getInstance().getAllDescriptors();

IEclipsePreferences eclipsePreferenceNode = new DefaultScope().getNode(FrameworkUtil.getBundle(this.getClass()).getSymbolicName());
IEclipsePreferences eclipsePreferenceNode = DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(this.getClass()).getSymbolicName());

for (IItemDescriptor capellaPreferenceNode : constraints) {
eclipsePreferenceNode.put(capellaPreferenceNode.getId(), String.valueOf(capellaPreferenceNode.isEnabledByDefault()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,67 +157,71 @@ private void search(Pattern pattern, Object element, IProject project) {
protected void searchForAttribute(Pattern pattern, IProject project, EObject inputObject, SearchForAttributeItem attributeItem) {

Object searchAttribute = attributeItem.getAttributeFor(inputObject);
if (searchAttribute != null) {
Object searchData = attributeItem.getRelevantSearchData(inputObject);

if (searchData instanceof String) {
String searchText = (String) searchData;
String[] searchTextLines = searchText.split("\n");

if (searchTextLines.length == 1) {
if (isMatchOccurrences(pattern, searchText)) {
SearchMatch result = new SearchMatch(inputObject, searchText, project, searchAttribute);
capellaSearchResult.addMatch(result);
capellaSearchResult.getTreeData().addElement(inputObject);
}
} else {
SearchMatch parentSearchMatch = new SearchMatch(inputObject, null, project, searchAttribute);
boolean matched = false;
for (int number = 0; number < searchTextLines.length; number++) {
String searchTextLine = searchTextLines[number];

if (isMatchOccurrences(pattern, searchTextLine)) {
LineSearchMatchChild childSearchMatch = new LineSearchMatchChild(inputObject, searchTextLine, project, parentSearchMatch, number);

parentSearchMatch.getChildren().add(childSearchMatch);
capellaSearchResult.addMatch(childSearchMatch);
matched = true;
}
}
if (searchAttribute == null) {
return;
}

if (matched) {
capellaSearchResult.addMatch(parentSearchMatch);
capellaSearchResult.getTreeData().addElement(inputObject);
}
}
Object searchData = attributeItem.getRelevantSearchData(inputObject);
if (searchData instanceof String) {
searchForAttributeInStringSearchData(pattern, project, inputObject, searchAttribute, searchData);
}

}
else if (searchData instanceof List) {
searchForAttributeInListSearchData(pattern, project, inputObject, searchAttribute, searchData);
}
}

else if (searchData instanceof List) {
List<?> searchDataList = ((List<?>) searchData);
SearchMatch parentSearchMatch = new SearchMatch(inputObject, null, project, searchAttribute);
boolean matched = false;
private void searchForAttributeInListSearchData(Pattern pattern, IProject project, EObject inputObject, Object searchAttribute, Object searchData) {
List<?> searchDataList = ((List<?>) searchData);
SearchMatch parentSearchMatch = new SearchMatch(inputObject, null, project, searchAttribute);
boolean matched = false;

for (int index = 0; index < searchDataList.size(); index++) {
Object searchElement = searchDataList.get(index);
for (int index = 0; index < searchDataList.size(); index++) {
Object searchElement = searchDataList.get(index);

if (searchElement instanceof String) {
String searchText = (String) searchDataList.get(index);
if (searchElement instanceof String && isMatchOccurrences(pattern, (String) searchElement)) {
ListElementSearchMatchChild childSearchMatch = new ListElementSearchMatchChild(inputObject, (String) searchElement, project, parentSearchMatch, index);
parentSearchMatch.getChildren().add(childSearchMatch);
capellaSearchResult.addMatch(childSearchMatch);
matched = true;
}
}

if (isMatchOccurrences(pattern, searchText)) {
ListElementSearchMatchChild childSearchMatch = new ListElementSearchMatchChild(inputObject, searchText, project, parentSearchMatch, index);
parentSearchMatch.getChildren().add(childSearchMatch);
capellaSearchResult.addMatch(childSearchMatch);
matched = true;
}
}
}
if (matched) {
capellaSearchResult.addMatch(parentSearchMatch);
capellaSearchResult.getTreeData().addElement(inputObject);
}
}

if (matched) {
capellaSearchResult.addMatch(parentSearchMatch);
capellaSearchResult.getTreeData().addElement(inputObject);
private void searchForAttributeInStringSearchData(Pattern pattern, IProject project, EObject inputObject, Object searchAttribute, Object searchData) {
String searchText = (String) searchData;
String[] searchTextLines = searchText.split("\n");

if (searchTextLines.length == 1) {
if (isMatchOccurrences(pattern, searchText)) {
SearchMatch result = new SearchMatch(inputObject, searchText, project, searchAttribute);
capellaSearchResult.addMatch(result);
capellaSearchResult.getTreeData().addElement(inputObject);
}
} else {
SearchMatch parentSearchMatch = new SearchMatch(inputObject, null, project, searchAttribute);
boolean matched = false;
for (int number = 0; number < searchTextLines.length; number++) {
String searchTextLine = searchTextLines[number];

if (isMatchOccurrences(pattern, searchTextLine)) {
LineSearchMatchChild childSearchMatch = new LineSearchMatchChild(inputObject, searchTextLine, project, parentSearchMatch, number);

parentSearchMatch.getChildren().add(childSearchMatch);
capellaSearchResult.addMatch(childSearchMatch);
matched = true;
}
}

if (matched) {
capellaSearchResult.addMatch(parentSearchMatch);
capellaSearchResult.getTreeData().addElement(inputObject);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public IStatus validate() {
return new Status(IStatus.ERROR, FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), CapellaSearchConstants.CapellaSearchPage_Validation_Message_SearchMetaClass_Selection);
}

if (searchAttributeItems.isEmpty() && !searchMetaClassItems.stream().anyMatch(SearchForNoteItem.class::isInstance)) {
if (searchAttributeItems.isEmpty() && searchMetaClassItems.stream().noneMatch(SearchForNoteItem.class::isInstance)) {
return new Status(IStatus.ERROR, FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), CapellaSearchConstants.CapellaSearchPage_Validation_Message_SearchAttribute_Selection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ExportValidationPreferenceInitializer() {
public void initializeDefaultPreferences() {


IEclipsePreferences node = new DefaultScope().getNode(FrameworkUtil.getBundle(this.getClass()).getSymbolicName());
IEclipsePreferences node = DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(this.getClass()).getSymbolicName());

node.put(
IExportValidationConstants.EXPORT_ONLY_CAPELLA_PREF_ID,
Expand Down

0 comments on commit 4ca8827

Please sign in to comment.