Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ protected void updateLocalization(List<? extends MUIElement> children) {
updateLocalization(((MElementContainer) element).getChildren());
}

if (element instanceof MWindow) {
MWindow window = (MWindow) element;
if (element instanceof MWindow window) {
MMenu mainMenu = window.getMainMenu();
if (mainMenu != null) {
mainMenu.updateLocalization();
Expand All @@ -132,8 +131,7 @@ protected void updateLocalization(List<? extends MUIElement> children) {
updateLocalization(((MPerspective) element).getWindows());
}

if (element instanceof MPart) {
MPart mPart = (MPart) element;
if (element instanceof MPart mPart) {
MToolBar toolbar = mPart.getToolbar();
if (toolbar != null && toolbar.getChildren() != null) {
toolbar.updateLocalization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

public class ActiveChildLookupFunction extends ContextFunction {

private String localVar;
private String var;
private final String localVar;
private final String var;

public ActiveChildLookupFunction(String var, String localVar) {
this.var = var;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ public Object compute(IEclipseContext context, String contextKey) {
return null;
}
MPart part = current.getActiveLeaf().get(MPart.class);
if (part == null)
if (part == null) {
return null;
}
MUIElement parent = part.getCurSharedRef() != null ? part.getCurSharedRef().getParent() : part.getParent();
if (parent == null)
if (parent == null) {
return part;
}
List<String> parentTags = parent.getTags();
if (parentTags.contains(IPresentationEngine.MINIMIZED) && !parentTags.contains(IPresentationEngine.ACTIVE)
&& !part.getTags().contains(IPresentationEngine.ACTIVE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class ApplicationPartServiceImpl implements EPartService {
private static final Supplier<RuntimeException> NO_VALID_PARTSERVICE = () -> new IllegalStateException(
"No valid PartService can be acquired from the current context"); //$NON-NLS-1$

private MApplication application;
private final MApplication application;

private EModelService modelService;
private final EModelService modelService;

@Inject
ApplicationPartServiceImpl(MApplication application, EModelService modelService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ final class BundleFinder implements BundleTrackerCustomizer<List<Bundle>> {
*/
public Bundle findBundle(String symbolicName) {
List<Bundle> bundlesWithSameSymName = trackedBundles.get(symbolicName);
if (bundlesWithSameSymName == null)
if (bundlesWithSameSymName == null) {
return null;
}

List<Bundle> snapshot = new ArrayList<>(bundlesWithSameSymName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ public Object getProperty(Object element, String id) {
String constructedName = Util.ZERO_LENGTH_STRING;
if (nameVal != null) {
constructedName = nameVal;
if (idVal != null)
if (idVal != null) {
constructedName += " [" + idVal + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
} else if (idVal != null) {
constructedName = idVal;
} else
} else {
constructedName = ice.getName();
}

return constructedName;
} else if (CLASS_IMPL.equals(id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,9 @@
}

public static void collectInfo(ExpressionInfo info, MExpression exp) {
if (!(exp instanceof MCoreExpression)) {
if (!(exp instanceof MCoreExpression expr)) {
return;
}
MCoreExpression expr = (MCoreExpression) exp;
Expression ref = null;
if (expr.getCoreExpression() instanceof Expression) {
ref = (Expression) expr.getCoreExpression();
Expand Down Expand Up @@ -232,8 +231,7 @@
}

public static boolean isVisible(MExpression exp, final ExpressionContext eContext) {
if (exp instanceof MCoreExpression) {
MCoreExpression coreExpression = (MCoreExpression) exp;
if (exp instanceof MCoreExpression coreExpression) {
return isCoreExpressionVisible(coreExpression, eContext);
} else if (exp instanceof MImperativeExpression) {
return isImperativeExpressionVisible((MImperativeExpression) exp, eContext);
Expand Down Expand Up @@ -472,10 +470,10 @@
static class Key {
private int tag = -1;
private int hc = -1;
private String parentId;
private String position;
private MCoreExpression vexp;
private Object factory;
private final String parentId;
private final String position;
private final MCoreExpression vexp;
private final Object factory;

public Key(String parentId, String position, List<String> tags, MCoreExpression vexp,
Object factory) {
Expand All @@ -500,10 +498,9 @@

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Key)) {
if (!(obj instanceof Key other)) {
return false;
}
Key other = (Key) obj;
Object exp1 = vexp == null ? null : vexp.getCoreExpression();
Object exp2 = other.vexp == null ? null : other.vexp.getCoreExpression();
return Objects.equals(parentId, other.parentId) && Objects.equals(position, other.position)
Expand Down Expand Up @@ -533,10 +530,10 @@

static class MenuKey extends Key {
static final String FACTORY = "ContributionFactory"; //$NON-NLS-1$
private MMenuContribution contribution;
private final MMenuContribution contribution;

public MenuKey(MMenuContribution mc) {

Check warning on line 535 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: MenuKey illegally references method MApplicationElement.getTags()

Check warning on line 535 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: MenuKey illegally references method MMenuContribution.getParentId()

Check warning on line 535 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: MenuKey illegally references method MMenuContribution.getPositionInParent()
super(mc.getParentId(), mc.getPositionInParent(), mc.getTags(), (MCoreExpression) mc

Check warning on line 536 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: MenuKey illegally references method MApplicationElement.getTransientData()

Check warning on line 536 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: MenuKey illegally references method MUIElement.getVisibleWhen()
.getVisibleWhen(), mc.getTransientData().get(FACTORY));
this.contribution = mc;
mc.setWidget(this);
Expand All @@ -549,10 +546,10 @@

static class ToolBarKey extends Key {
static final String FACTORY = "ToolBarContributionFactory"; //$NON-NLS-1$
private MToolBarContribution contribution;
private final MToolBarContribution contribution;

public ToolBarKey(MToolBarContribution mc) {

Check warning on line 551 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: ToolBarKey illegally references method MToolBarContribution.getPositionInParent()

Check warning on line 551 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: ToolBarKey illegally references method MToolBarContribution.getParentId()

Check warning on line 551 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: ToolBarKey illegally references method MApplicationElement.getTags()
super(mc.getParentId(), mc.getPositionInParent(), mc.getTags(), (MCoreExpression) mc

Check warning on line 552 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: ToolBarKey illegally references method MUIElement.getVisibleWhen()

Check warning on line 552 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: ToolBarKey illegally references method MApplicationElement.getTransientData()
.getVisibleWhen(), mc.getTransientData().get(FACTORY));
this.contribution = mc;
mc.setWidget(this);
Expand All @@ -564,10 +561,10 @@
}

static class TrimKey extends Key {
private MTrimContribution contribution;
private final MTrimContribution contribution;

public TrimKey(MTrimContribution mc) {

Check warning on line 566 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: TrimKey illegally references method MTrimContribution.getPositionInParent()

Check warning on line 566 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: TrimKey illegally references method MApplicationElement.getTags()

Check warning on line 566 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: TrimKey illegally references method MTrimContribution.getParentId()
super(mc.getParentId(), mc.getPositionInParent(), mc.getTags(), (MCoreExpression) mc

Check warning on line 567 in bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ContributionsAnalyzer.java

View check run for this annotation

Jenkins - Eclipse Platform / API Tools

ILLEGAL_REFERENCE

NORMAL: TrimKey illegally references method MUIElement.getVisibleWhen()
.getVisibleWhen(), null);
this.contribution = mc;
mc.setWidget(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class E4XMIResource extends XMIResourceImpl {

public static final String OPTION_FILTER_PERSIST_STATE = "E4_FILTER_PERSISTED_STATE"; //$NON-NLS-1$

private Map<EObject, String> objectMap = new WeakHashMap<>();
private Set<String> knownIds = new HashSet<>();
private final Map<EObject, String> objectMap = new WeakHashMap<>();
private final Set<String> knownIds = new HashSet<>();

public E4XMIResource() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ public E4XMISave(XMLHelper helper) {
*/
@Override
protected void saveElement(InternalEObject o, EStructuralFeature f) {
if (o instanceof MApplicationElement) {
MApplicationElement appElement = (MApplicationElement) o;
if (o instanceof MApplicationElement appElement) {
String persists = appElement.getPersistedState().get(IWorkbench.PERSIST_STATE);
if (persists != null && !Boolean.parseBoolean(persists)) {
return;
}
}
if (o instanceof MUIElement) {
MUIElement uiElement = (MUIElement) o;
if (o instanceof MUIElement uiElement) {
if (OpaqueElementUtil.isOpaqueElement(uiElement) || RenderedElementUtil.isRenderedElement(uiElement)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ExtensionTrackeContextFunction extends ContextFunction implements E
@Reference
private ILog log;

private Map<IEclipseContext, IExtensionTracker> createdObjects = new ConcurrentHashMap<>();
private final Map<IEclipseContext, IExtensionTracker> createdObjects = new ConcurrentHashMap<>();

@Override
public Object compute(IEclipseContext context, String contextKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ final class GenericMApplicationElementFactoryImpl {
* if the given Eclipse ExtensionRegistry is {@code null}
*/
GenericMApplicationElementFactoryImpl(IExtensionRegistry extensionRegistry) {
if (extensionRegistry == null)
if (extensionRegistry == null) {
throw new NullPointerException("No ExtensionRegistry given!"); //$NON-NLS-1$
}

emfGeneratedPackages = new MApplicationElementClassToEClass();

Expand Down Expand Up @@ -278,16 +279,15 @@ private List<Class<? extends MApplicationElement>> addToMapping(
*/
private final Map<Class<? extends MApplicationElement>, EClass> buildMapping(
EPackage ePackage) {
if (ePackage == null)
if (ePackage == null) {
return null;
}

List<EClassifier> eClassifiers = ePackage.getEClassifiers();
Map<Class<? extends MApplicationElement>, EClass> mapping = new HashMap<>();

for (EClassifier eClassifier : eClassifiers) {
if (eClassifier instanceof EClass) {
EClass eClass = (EClass) eClassifier;

if (eClassifier instanceof EClass eClass) {
if (mApplicationElementEClass.isSuperTypeOf(eClass) && !eClass.isAbstract()
&& !eClass.isInterface()) {
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public ModelFragmentComparator(MApplication application) {

@Override
public int compare(ModelFragmentWrapper o1, ModelFragmentWrapper o2) {
if (o1 == o2)
if (o1 == o2) {
return 0;
}

PositionDescription posInfo1 = getPositionDescription(o1);
PositionDescription posInfo2 = getPositionDescription(o2);
Expand All @@ -80,8 +81,9 @@ public int compare(ModelFragmentWrapper o1, ModelFragmentWrapper o2) {
switch (posInfo2.getPlace()) {
case INDEX:
int result = posInfo1.getPositionReferenceAsInteger() - posInfo2.getPositionReferenceAsInteger();
if (result == 0)
if (result == 0) {
return 1;
}
return result;
default:
return -1;
Expand All @@ -92,24 +94,29 @@ public int compare(ModelFragmentWrapper o1, ModelFragmentWrapper o2) {
boolean hasElement = false;
for (MApplicationElement element : o2.getModelFragment().getElements()) {
hasElement |= ModelUtils.findElementById(element, posInfo1.getReference()) != null;
if (hasElement)
if (hasElement) {
break;
}
}
if (hasElement)
if (hasElement) {
return 1;
}

hasElement = false;
for (MApplicationElement element : o1.getModelFragment().getElements()) {
hasElement |= ModelUtils.findElementById(element, posInfo2.getReference()) != null;
if (hasElement)
if (hasElement) {
break;
}
}
if (hasElement)
if (hasElement) {
return -1;
}

hasElement = ModelUtils.findElementById(application, posInfo1.getReference()) != null;
if (hasElement)
if (hasElement) {
return -1;
}

return 1;
default:
Expand All @@ -122,15 +129,18 @@ public int compare(ModelFragmentWrapper o1, ModelFragmentWrapper o2) {
}

private PositionDescription getPositionDescription(ModelFragmentWrapper wrapper) {
if (!MStringModelFragment.class.isInstance(wrapper.getModelFragment()))
if (!MStringModelFragment.class.isInstance(wrapper.getModelFragment())) {
return new PositionDescription(PositionPlace.NONE, null);
}
MStringModelFragment stringFragment = (MStringModelFragment) wrapper.getModelFragment();
if (stringFragment.getPositionInList() == null)
if (stringFragment.getPositionInList() == null) {
return new PositionDescription(PositionPlace.NONE, null);
}
String posInList = stringFragment.getPositionInList().trim();
PositionInfo posInfo = PositionInfo.parse(posInList);
if (posInfo == null)
if (posInfo == null) {
return new PositionDescription(PositionPlace.NONE, null);
}
switch (posInfo.getPosition()) {
case AFTER:
case BEFORE:
Expand Down
Loading
Loading