-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refix: quick-fix for extraneous empty line(s) in manifest editor
Extraneous lines are errneous to the manifest compiler, but it does not recommend / provide a resolution. Add a quick fix to remove extraneous line. Takes care of the empty valid empty lines at the end of manifests. In the main iteration loop, identify empty lines and push into a list. At the end of the loop, aggregate all the empty lines into one single marker. This way, we address issues that can arise from race conditions when two threas try to manipulate the document context simultaneously. Fixes: #563
- Loading branch information
1 parent
c8754be
commit fd1420e
Showing
6 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
....eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/ExtraneousLinesResolution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
* Gireesh Punathil <gpunathi@in.ibm.com> Initial implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.pde.internal.ui.correction; | ||
|
||
import java.util.StringTokenizer; | ||
import org.eclipse.core.resources.IMarker; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.jface.text.*; | ||
import org.eclipse.pde.internal.core.builders.PDEMarkerFactory; | ||
import org.eclipse.pde.internal.core.text.bundle.BundleModel; | ||
import org.eclipse.pde.internal.ui.PDEPlugin; | ||
import org.eclipse.pde.internal.ui.PDEUIMessages; | ||
|
||
/** | ||
* <p>Represents a resolution to the problem of the bundle manifest | ||
* having extraneous lines.</p> | ||
*/ | ||
public class ExtraneousLinesResolution extends AbstractManifestMarkerResolution { | ||
/** | ||
* Creates a new resolution | ||
* | ||
* @param type | ||
* {@link AbstractPDEMarkerResolution#REMOVE_TYPE} to delete | ||
* lines | ||
*/ | ||
public ExtraneousLinesResolution(int type, IMarker marker) { | ||
super(type, marker); | ||
} | ||
|
||
/** | ||
* Resolves the problem by extracting the empty line and removing it. | ||
*/ | ||
@Override | ||
protected void createChange(BundleModel model) { | ||
IDocument doc = model.getDocument(); | ||
int line = 0; | ||
try { | ||
String emptyLines = (String) marker.getAttribute(PDEMarkerFactory.EMPTY_LINE); | ||
StringTokenizer st = new StringTokenizer(emptyLines, ","); //$NON-NLS-1$ | ||
while (st.hasMoreElements()) { | ||
line = Integer.parseInt(st.nextToken()); | ||
IRegion l = doc.getLineInformation(line); | ||
doc.replace(l.getOffset(), l.getLength() + 1, ""); //$NON-NLS-1$ | ||
} | ||
} catch (BadLocationException | CoreException | NumberFormatException e) { | ||
PDEPlugin.log(e); | ||
} | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return PDEUIMessages.ExtraneousLineResolutionRemove_description; | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return PDEUIMessages.ExtraneousLineResolutionRemove_label; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters