diff --git a/ds/org.eclipse.pde.ds.annotations/META-INF/MANIFEST.MF b/ds/org.eclipse.pde.ds.annotations/META-INF/MANIFEST.MF index e20f546b1bd..3398e73071c 100644 --- a/ds/org.eclipse.pde.ds.annotations/META-INF/MANIFEST.MF +++ b/ds/org.eclipse.pde.ds.annotations/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.pde.ds.annotations;singleton:=true -Bundle-Version: 1.4.0.qualifier +Bundle-Version: 1.4.100.qualifier Bundle-Activator: org.eclipse.pde.ds.internal.annotations.Activator Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.ui;bundle-version="[3.105.0,4.0.0)", diff --git a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/AnnotationVisitor.java b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/AnnotationVisitor.java index 68e6fedc117..7828930ccf7 100644 --- a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/AnnotationVisitor.java +++ b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/AnnotationVisitor.java @@ -467,8 +467,9 @@ public String getReadableName(TextEdit edit) { try { latch.await(); } catch (InterruptedException e) { - if (debug.isDebugging()) + if (debug.isDebugging()) { debug.trace("Interrupted while waiting for edits to complete on display thread.", e); //$NON-NLS-1$ + } } if (ex[0] != null) { diff --git a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ComponentPropertyTester.java b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ComponentPropertyTester.java index 1070c15d9aa..45f4769560b 100644 --- a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ComponentPropertyTester.java +++ b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ComponentPropertyTester.java @@ -48,37 +48,43 @@ public class ComponentPropertyTester extends PropertyTester { @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (!"containsComponentWithImplicitName".equals(property)) //$NON-NLS-1$ + if (!"containsComponentWithImplicitName".equals(property)) { //$NON-NLS-1$ return false; + } - if (!(receiver instanceof IType) && !(receiver instanceof IPackageFragment)) + if (!(receiver instanceof IType) && !(receiver instanceof IPackageFragment)) { return false; + } IJavaElement element = (IJavaElement) receiver; IJavaProject javaProject = element.getJavaProject(); boolean enabled = Platform.getPreferencesService().getBoolean(Activator.PLUGIN_ID, Activator.PREF_ENABLED, false, new IScopeContext[] { new ProjectScope(javaProject.getProject()), InstanceScope.INSTANCE, DefaultScope.INSTANCE }); - if (!enabled) + if (!enabled) { return false; + } try { return element.getElementType() == IJavaElement.TYPE ? containsImplicitName((IType) receiver) : containsImplicitName((IPackageFragment) receiver); } catch (JavaModelException e) { - if (debug.isDebugging()) + if (debug.isDebugging()) { debug.trace(String.format("Error searching for components with implicit names in element: %s", element), e); //$NON-NLS-1$ + } } return false; } private boolean containsImplicitName(IPackageFragment fragment) throws JavaModelException { - if (!fragment.containsJavaResources()) + if (!fragment.containsJavaResources()) { return false; + } for (ICompilationUnit cu : fragment.getCompilationUnits()) { for (IType type : cu.getAllTypes()) { - if (hasImplicitName(type)) + if (hasImplicitName(type)) { return true; + } } } @@ -86,12 +92,14 @@ private boolean containsImplicitName(IPackageFragment fragment) throws JavaModel } private boolean containsImplicitName(IType type) throws JavaModelException { - if (hasImplicitName(type)) + if (hasImplicitName(type)) { return true; + } for (IType child : type.getTypes()) { - if (hasImplicitName(child)) + if (hasImplicitName(child)) { return true; + } } return false; diff --git a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ComponentRefactoringHelper.java b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ComponentRefactoringHelper.java index d46f8a8ac86..9984cf0e801 100644 --- a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ComponentRefactoringHelper.java +++ b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ComponentRefactoringHelper.java @@ -85,11 +85,13 @@ public boolean initialize(Object element) { } private RefactoringArguments getArguments() { - if (participant instanceof RenameParticipant) + if (participant instanceof RenameParticipant) { return ((RenameParticipant) participant).getArguments(); + } - if (participant instanceof MoveParticipant) + if (participant instanceof MoveParticipant) { return ((MoveParticipant) participant).getArguments(); + } return null; } @@ -110,19 +112,22 @@ public RefactoringStatus checkConditions(IProgressMonitor monitor, CheckConditio ResourceChangeChecker checker = context.getChecker(ResourceChangeChecker.class); IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory(); for (Map.Entry entry : elements.entrySet()) { - if (progress.isCanceled()) + if (progress.isCanceled()) { throw new OperationCanceledException(); + } progress.worked(1); RefactoringArguments args = entry.getValue(); - if (!getUpdateReferences(args)) + if (!getUpdateReferences(args)) { continue; + } IJavaElement element = (IJavaElement) entry.getKey(); IJavaProject javaProject = element.getJavaProject(); - if (unmanaged.contains(javaProject)) + if (unmanaged.contains(javaProject)) { continue; + } ProjectState state = states.get(javaProject); if (state == null) { @@ -136,10 +141,11 @@ public RefactoringStatus checkConditions(IProgressMonitor monitor, CheckConditio states.put(javaProject, state); - if (element.getElementType() == IJavaElement.TYPE) + if (element.getElementType() == IJavaElement.TYPE) { createRenames((IType) element, args, state, deltaFactory); - else if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) + } else if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { createRenames((IPackageFragment) element, args, state, deltaFactory); + } } return new RefactoringStatus(); @@ -150,11 +156,13 @@ else if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) } private boolean getUpdateReferences(RefactoringArguments args) { - if (args instanceof RenameArguments) + if (args instanceof RenameArguments) { return ((RenameArguments) args).getUpdateReferences(); + } - if (args instanceof MoveArguments) + if (args instanceof MoveArguments) { return ((MoveArguments) args).getUpdateReferences(); + } return false; } @@ -228,20 +236,23 @@ public Change createChange(IProgressMonitor monitor) throws CoreException, Opera CompositeChange compositeChange = new CompositeChange(Messages.ComponentRefactoringHelper_topLevelChangeLabel); for (Map.Entry entry : elements.entrySet()) { - if (progress.isCanceled()) + if (progress.isCanceled()) { throw new OperationCanceledException(); + } progress.worked(1); RefactoringArguments args = entry.getValue(); - if (!getUpdateReferences(args)) + if (!getUpdateReferences(args)) { continue; + } IJavaElement element = (IJavaElement) entry.getKey(); - if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) + if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { collectChanges((IPackageFragment) element, compositeChange); - else if (element.getElementType() == IJavaElement.TYPE) + } else if (element.getElementType() == IJavaElement.TYPE) { collectChanges((IType) element, compositeChange); + } } return compositeChange; @@ -257,8 +268,9 @@ private void collectChanges(IPackageFragment fragment, CompositeChange composite private void collectChanges(IType type, CompositeChange compositeChange) throws CoreException { Change change = createChange(type); - if (change != null) + if (change != null) { compositeChange.add(change); + } for (IType child : type.getTypes()) { collectChanges(child, compositeChange); @@ -267,19 +279,23 @@ private void collectChanges(IType type, CompositeChange compositeChange) throws private Change createChange(IType type) throws CoreException { IFile modelFile = modelFiles.get(type); - if (modelFile == null) + if (modelFile == null) { return null; + } String componentName = componentNames.get(modelFile); - if (componentName == null) + if (componentName == null) { return null; + } IFile newModelFile = renames.get(modelFile); - if (newModelFile == null) + if (newModelFile == null) { return null; + } - if (debug.isDebugging()) + if (debug.isDebugging()) { debug.trace(String.format("Changing %s from %s to %s.", type.getFullyQualifiedName(), modelFile.getFullPath(), newModelFile.getFullPath())); //$NON-NLS-1$ + } ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager(); manager.connect(modelFile.getFullPath(), LocationKind.IFILE, null); @@ -287,8 +303,9 @@ private Change createChange(IType type) throws CoreException { IDocumentAttributeNode attrName, attrClass; try { ITextFileBuffer buf = manager.getTextFileBuffer(modelFile.getFullPath(), LocationKind.IFILE); - if (buf == null) + if (buf == null) { return null; + } IDocument doc = buf.getDocument(); model = new DSModel(doc, false); @@ -300,8 +317,9 @@ private Change createChange(IType type) throws CoreException { attrName = component.getDocumentAttribute(IDSConstants.ATTRIBUTE_COMPONENT_NAME); attrClass = component.getImplementation().getDocumentAttribute(IDSConstants.ATTRIBUTE_IMPLEMENTATION_CLASS); } finally { - if (model != null) + if (model != null) { model.dispose(); + } manager.disconnect(modelFile.getFullPath(), LocationKind.IFILE, null); } diff --git a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationCompilationParticipant.java b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationCompilationParticipant.java index 6dd999fe485..82854fbef4f 100644 --- a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationCompilationParticipant.java +++ b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationCompilationParticipant.java @@ -117,22 +117,26 @@ public boolean isAnnotationProcessor() { public boolean isActive(IJavaProject project) { IPreferencesService prefs = Platform.getPreferencesService(); boolean enabled = prefs.getBoolean(Activator.PLUGIN_ID, Activator.PREF_ENABLED, false, new IScopeContext[] { new ProjectScope(project.getProject()), InstanceScope.INSTANCE, DefaultScope.INSTANCE }); - if (!enabled) + if (!enabled) { return false; + } IProject iproject = project.getProject(); - if (!iproject.isOpen() || !PluginProject.isPluginProject(iproject)) + if (!iproject.isOpen() || !PluginProject.isPluginProject(iproject)) { return false; + } - if (WorkspaceModelManager.isBinaryProject(project.getProject())) + if (WorkspaceModelManager.isBinaryProject(project.getProject())) { return false; + } return true; } @Override public int aboutToBuild(IJavaProject project) { - if (debug.isDebugging()) + if (debug.isDebugging()) { debug.trace(String.format("About to build project: %s", project.getElementName())); //$NON-NLS-1$ + } int result = READY_FOR_BUILD; @@ -220,8 +224,9 @@ private static ProjectState getState(IJavaProject project, int[] result) { if (state == null) { state = new ProjectState(); - if (result != null && result.length > 0) + if (result != null && result.length > 0) { result[0] = NEEDS_FULL_BUILD; + } } try { @@ -237,8 +242,9 @@ private static ProjectState getState(IJavaProject project, int[] result) { private static ProjectState loadState(IProject project) throws IOException { File stateFile = getStateFile(project); if (!stateFile.canRead()) { - if (debug.isDebugging()) + if (debug.isDebugging()) { debug.trace(String.format("Missing or invalid project state file: %s", stateFile)); //$NON-NLS-1$ + } return null; } @@ -248,8 +254,9 @@ private static ProjectState loadState(IProject project) throws IOException { if (debug.isDebugging()) { debug.trace(String.format("Loaded state for project: %s", project.getName())); //$NON-NLS-1$ - for (String cuKey : state.getCompilationUnits()) + for (String cuKey : state.getCompilationUnits()) { debug.trace(String.format("%s -> %s", cuKey, state.getModelFiles(cuKey))); //$NON-NLS-1$ + } } return state; @@ -274,19 +281,22 @@ public void buildFinished(IJavaProject project) { IResource file; if (cu != null && cu.getElementType() == IJavaElement.COMPILATION_UNIT && (file = cu.getResource()) != null && file.exists() - && file.getProject().equals(project.getProject())) + && file.getProject().equals(project.getProject())) { exists = true; + } } catch (JavaModelException e) { Activator.log(e); } if (!exists) { - if (debug.isDebugging()) + if (debug.isDebugging()) { debug.trace(String.format("Mapped CU %s no longer exists.", cuKey)); //$NON-NLS-1$ + } Collection dsKeys = state.removeMappings(cuKey); - if (dsKeys != null) + if (dsKeys != null) { abandoned.addAll(dsKeys); + } } } @@ -294,8 +304,9 @@ public void buildFinished(IJavaProject project) { HashSet retained = new HashSet<>(); for (String cuKey : state.getCompilationUnits()) { Collection dsKeys = state.getModelFiles(cuKey); - if (dsKeys != null) + if (dsKeys != null) { retained.addAll(dsKeys); + } } try { diff --git a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationPropertyPage.java b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationPropertyPage.java index f26602796fc..1118c2d1d61 100644 --- a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationPropertyPage.java +++ b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/DSAnnotationPropertyPage.java @@ -152,8 +152,9 @@ private Link createLink(Composite composite, String text) { link.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { - if (PreferencesUtil.createPreferenceDialogOn(getShell(), Activator.PLUGIN_ID, new String[] { Activator.PLUGIN_ID }, null).open() == Window.OK) + if (PreferencesUtil.createPreferenceDialogOn(getShell(), Activator.PLUGIN_ID, new String[] { Activator.PLUGIN_ID }, null).open() == Window.OK) { refreshWidgets(); + } } @Override diff --git a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/Debug.java b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/Debug.java index 2c591ecceed..bfba8c1340c 100644 --- a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/Debug.java +++ b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/Debug.java @@ -32,8 +32,9 @@ private Debug(DebugTrace trace, String option) { } public static Debug getDebug(String name) { - if (!name.startsWith("/")) //$NON-NLS-1$ + if (!name.startsWith("/")) { //$NON-NLS-1$ name = "/" + name; //$NON-NLS-1$ + } DebugTrace trace = null; Bundle bundle = FrameworkUtil.getBundle(Activator.class); @@ -58,42 +59,50 @@ public boolean isDebugging() { } public void trace(String message) { - if (trace != null) + if (trace != null) { trace.trace(option, message); + } } public void trace(String message, Throwable error) { - if (trace != null) + if (trace != null) { trace.trace(message, message, error); + } } public void traceDumpStack() { - if (trace != null) + if (trace != null) { trace.traceDumpStack(option); + } } public void traceEntry() { - if (trace != null) + if (trace != null) { trace.traceEntry(option); + } } public void traceEntry(Object methodArgument) { - if (trace != null) + if (trace != null) { trace.traceEntry(option, methodArgument); + } } public void traceEntry(Object[] methodArguments) { - if (trace != null) + if (trace != null) { trace.traceEntry(option, methodArguments); + } } public void traceExit() { - if (trace != null) + if (trace != null) { trace.traceExit(option); + } } public void traceExit(Object result) { - if (trace != null) + if (trace != null) { trace.traceExit(option, result); + } } } diff --git a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ProjectClasspathPreferenceChangeListener.java b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ProjectClasspathPreferenceChangeListener.java index 286824da346..8b41403e18d 100644 --- a/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ProjectClasspathPreferenceChangeListener.java +++ b/ds/org.eclipse.pde.ds.annotations/src/org/eclipse/pde/ds/internal/annotations/ProjectClasspathPreferenceChangeListener.java @@ -51,8 +51,9 @@ public void preferenceChange(PreferenceChangeEvent event) { static void updateClasspathContainer(IJavaProject project, IProgressMonitor monitor) { - if (monitor != null) + if (monitor != null) { monitor.beginTask(project.getElementName(), 1); + } try { if (monitor != null && monitor.isCanceled()) {