-
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.
Show warnings/errors from the BND build
Currently if one has an error in the pde.bnd file there is no feedback for the user about the problem. This adds a validator that reads the errors/warning and display them to the user as error markers mapping the error to a line number if possible. Fix #699
- Loading branch information
1 parent
c71d0c1
commit f4823ba
Showing
7 changed files
with
116 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
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
84 changes: 84 additions & 0 deletions
84
ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bnd/BndErrorReporter.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,84 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Christoph Läubrich 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: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.pde.internal.core.bnd; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.runtime.IProgressMonitor; | ||
import org.eclipse.jface.text.IDocument; | ||
import org.eclipse.pde.internal.core.builders.CompilerFlags; | ||
import org.eclipse.pde.internal.core.builders.ErrorReporter; | ||
import org.eclipse.pde.internal.core.builders.PDEMarkerFactory; | ||
import org.eclipse.pde.internal.core.natures.BndProject; | ||
|
||
import aQute.bnd.properties.IRegion; | ||
import aQute.bnd.properties.LineType; | ||
import aQute.bnd.properties.PropertiesLineReader; | ||
import aQute.service.reporter.Report; | ||
import aQute.service.reporter.Report.Location; | ||
|
||
public class BndErrorReporter extends ErrorReporter { | ||
|
||
private BndDocument bndDocument; | ||
private Report report; | ||
|
||
public BndErrorReporter(IProject project, Report report) { | ||
super(project.getFile(BndProject.INSTRUCTIONS_FILE)); | ||
this.report = report; | ||
IDocument document = createDocument(fFile); | ||
if (document != null) { | ||
bndDocument = new BndDocument(document); | ||
} | ||
} | ||
|
||
@Override | ||
protected void validate(IProgressMonitor monitor) { | ||
if (report != null) { | ||
for (String warn : report.getWarnings()) { | ||
reportProblem(warn, CompilerFlags.WARNING, report.getLocation(warn)); | ||
} | ||
for (String err : report.getErrors()) { | ||
reportProblem(err, CompilerFlags.ERROR, report.getLocation(err)); | ||
} | ||
} | ||
} | ||
|
||
private void reportProblem(String err, int severity, Location location) { | ||
int line = -1; | ||
if (location != null) { | ||
if (location.line > 0) { | ||
line = location.line; | ||
} else if (location.header != null && bndDocument != null) { | ||
try { | ||
PropertiesLineReader reader = new PropertiesLineReader(bndDocument); | ||
LineType type = reader.next(); | ||
while (type != LineType.eof) { | ||
if (type == LineType.entry) { | ||
String key = reader.key(); | ||
if (location.header.equals(key)) { | ||
IRegion region = reader.region(); | ||
line = bndDocument.getLineOfOffset(region.getOffset()) + 1; | ||
break; | ||
} | ||
} | ||
type = reader.next(); | ||
} | ||
} catch (Exception e) { | ||
// can't do anything here then... | ||
} | ||
} | ||
} | ||
report(err, line, severity, PDEMarkerFactory.CAT_FATAL); | ||
} | ||
|
||
} |
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