Skip to content

Commit 748f075

Browse files
author
jan
committed
improve the description of quickfix #1760
1 parent c64aee5 commit 748f075

4 files changed

Lines changed: 31 additions & 12 deletions

File tree

io.sloeber.ui/src/io/sloeber/ui/MarkerResolutionGenerator/UnresolvedIncludesResolutionGenerator.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.sloeber.ui.MarkerResolutionGenerator;
22

3+
import static io.sloeber.core.api.Const.*;
4+
import static io.sloeber.ui.Messages.*;
35
import java.util.HashSet;
46
import java.util.Map;
57
import java.util.Set;
@@ -19,35 +21,35 @@
1921
import io.sloeber.core.api.ConfigurationPreferences;
2022
import io.sloeber.core.api.ISloeberConfiguration;
2123

24+
2225
public class UnresolvedIncludesResolutionGenerator implements IMarkerResolutionGenerator {
2326

24-
@SuppressWarnings("nls")
2527
@Override
2628
public IMarkerResolution[] getResolutions(IMarker marker) {
2729
IMarkerResolution[] ret = new IMarkerResolution[0];
2830
try {
2931
Map<String, Object> attributes = marker.getAttributes();
30-
Object severityObject = attributes.get("severity");
32+
Object severityObject = attributes.get("severity"); //$NON-NLS-1$
3133
if (!(severityObject instanceof Integer)) {
3234
return ret;
3335
}
3436
int severity = ((Integer) severityObject).intValue();
3537
if (severity != 2) {
3638
return ret;
3739
}
38-
Object messageObject = attributes.get("message");
40+
Object messageObject = attributes.get("message"); //$NON-NLS-1$
3941
if (!(messageObject instanceof String)) {
4042
return ret;
4143
}
4244
String message = (String) messageObject;
43-
if (!message.endsWith(": No such file or directory")) {
45+
if (!message.endsWith(": No such file or directory")) { //$NON-NLS-1$
4446
return ret;
4547
}
46-
String libName = message.split(":")[1].trim();
48+
String libName = message.split(COLON)[1].trim();
4749
if (libName.isBlank()) {
4850
return ret;
4951
}
50-
if (!libName.endsWith(".h")) {
52+
if (!libName.endsWith(".h")) { //$NON-NLS-1$
5153
return ret;
5254
}
5355

@@ -67,7 +69,7 @@ public IMarkerResolution[] getResolutions(IMarker marker) {
6769

6870
@Override
6971
public String getLabel() {
70-
return "Add the library to the project";
72+
return AddLibraryToProject.replace(LIB_KEY, curlib.getFQN().toString());
7173
}
7274

7375
@Override
@@ -108,21 +110,25 @@ public void run(IMarker marker11) {
108110

109111
Map<String, IArduinoLibraryVersion> toInstallLibs = LibraryManager.getLatestInstallableLibraries(librariesToInstall);
110112

111-
if (toInstallLibs.isEmpty()) {
112-
//No installable lib found
113+
if (toInstallLibs.size()!=1) {
114+
//No or more than 1 installable lib found
115+
//skip
113116
return ret;
114117
}
118+
IArduinoLibraryVersion toInstalllLib=toInstallLibs.get(libName);
115119

116120
ret = new IMarkerResolution[1];
117121
ret[0] = new IMarkerResolution() {
118122

119123
@Override
120124
public String getLabel() {
121-
return "Install the library in the workspace and add it to the project";
125+
return InstallAndAddLibraryToProject.replace(LIB_KEY,toInstalllLib.getName())
126+
.replace(VERSION_KEY, toInstalllLib.getVersion().toString())
127+
.replace(MAINTAINER, toInstalllLib.getMaintainer());
122128
}
123129

124130
@Override
125-
public void run(@SuppressWarnings("hiding") IMarker marker) {
131+
public void run( IMarker marker1) {
126132
IArduinoLibraryVersion curlib=null;
127133

128134
for (Entry<String, IArduinoLibraryVersion> curLibSet : toInstallLibs.entrySet()) {

io.sloeber.ui/src/io/sloeber/ui/Messages.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class Messages extends NLS {
1414
public static final String MAINTAINER = "{MAINTAINER}"; //$NON-NLS-1$
1515
public static final String EMAIL = "{EMAIL}"; //$NON-NLS-1$
1616
public static final String URL = "{URL}"; //$NON-NLS-1$
17+
public static final String LIB_KEY = "{LIB}"; //$NON-NLS-1$
18+
public static final String VERSION_KEY = "{VERSION}"; //$NON-NLS-1$
1719

1820
public static String ui_select_debug_level;
1921

@@ -197,6 +199,10 @@ public class Messages extends NLS {
197199

198200
public static String ui_new_sketch_sketch_source_folder;
199201

202+
public static String AddLibraryToProject;
203+
204+
public static String InstallAndAddLibraryToProject;
205+
200206
public static String yes;
201207

202208

io.sloeber.ui/src/io/sloeber/ui/messages.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,5 @@ NewProjectSourceLocationPage_CodeInSrcFolder=put code in the src folder
154154
NewProjectSourceLocationPage_CustomSourceTextFieldError=You must provide a text in the text field that matches a valid folder name
155155
NewProjectSourceLocationPage_ExplainText=You can separate the source code from the rest of the project content by putting it in a source folder.
156156
157+
AddLibraryToProject=Add the library {LIB} to the project.
158+
InstallAndAddLibraryToProject=Install the library {LIB} version {VERSION} from {MAINTAINER} in the workspace and add it to the project.

io.sloeber.ui/src/io/sloeber/ui/messages_nl.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ui_append_archive_text=Voeg to aan bibliotheek commando.
6868
ui_append_assembly=asm
6969
ui_append_assembly_text=Voeg toe aan machine code commando
7070
ui_append_c=C
71-
ui_append_c_cpp= C en C++
71+
ui_append_c_cpp= C en C++
7272
ui_append_c_cpp_text=Deze tekens worden toegevoegd aan de C en C++ compileer commandos.
7373
ui_append_c_text=Deze tekens worden toegevoegd aan het C compileer commando.
7474
ui_append_cpp=C++
@@ -132,3 +132,8 @@ Invalid_Private_Library_folder=[sloeber]/arduinoPlugin is geen geldig prive bibl
132132
ui_enable_bonjour=Zoek op het netwerk naar bonjour borden
133133
ui_put_in_version_control=Delen in versie controle?
134134
Build_Error_Before_Upload=De bouw van het project faalde voor het opladen.
135+
136+
137+
AddLibraryToProject=Voeg de bibliotheek {LIB} toe aan het project.
138+
InstallAndAddLibraryToProject=Installeer de biblitheek {LIB} versie {VERSION} van {MAINTAINER} in de werkplaats en voeg hem toe aan het project.
139+

0 commit comments

Comments
 (0)