Skip to content

Commit 57cd708

Browse files
committed
fix #363
Also fixed issues when using cpp and arduino projects
1 parent df31e18 commit 57cd708

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

it.baeyens.arduino.core/src/it/baeyens/arduino/listeners/IndexerListener.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
import org.eclipse.cdt.core.index.IIndexerStateEvent;
1313
import org.eclipse.cdt.core.index.IIndexerStateListener;
1414
import org.eclipse.core.resources.IProject;
15+
import org.eclipse.core.runtime.CoreException;
1516
import org.eclipse.core.runtime.IProgressMonitor;
1617
import org.eclipse.core.runtime.IStatus;
1718
import org.eclipse.core.runtime.Status;
1819
import org.eclipse.core.runtime.jobs.Job;
1920

21+
import it.baeyens.arduino.common.Const;
2022
import it.baeyens.arduino.common.InstancePreferences;
2123
import it.baeyens.arduino.tools.Libraries;
2224

@@ -26,7 +28,15 @@ public class IndexerListener implements IIndexChangeListener, IIndexerStateListe
2628

2729
@Override
2830
public void indexChanged(IIndexChangeEvent event) {
29-
this.ChangedProjects.add(event.getAffectedProject().getProject());
31+
IProject project = event.getAffectedProject().getProject();
32+
try {
33+
if (project.hasNature(Const.ArduinoNatureID)) {
34+
this.ChangedProjects.add(project);
35+
}
36+
} catch (CoreException e) {
37+
// TODO Auto-generated catch block
38+
e.printStackTrace();
39+
}
3040

3141
}
3242

it.baeyens.arduino.core/src/it/baeyens/arduino/toolchain/ArduinoLanguageProvider.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ private enum State {
3333

3434
private State state = State.NONE;
3535

36-
@SuppressWarnings("nls")
3736
private static final AbstractOptionParser[] optionParsers = {
38-
new IncludePathOptionParser("#include \"(\\S.*)\"", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.LOCAL),
39-
new IncludePathOptionParser("#include <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
40-
new IncludePathOptionParser("#framework <(\\S.*)>", "$1",
37+
new IncludePathOptionParser("#include \"(\\S.*)\"", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.LOCAL), //$NON-NLS-1$ //$NON-NLS-2$
38+
new IncludePathOptionParser("#include <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), //$NON-NLS-1$ //$NON-NLS-2$
39+
new IncludePathOptionParser("#framework <(\\S.*)>", "$1", //$NON-NLS-1$ //$NON-NLS-2$
4140
ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.FRAMEWORKS_MAC),
42-
new MacroOptionParser("#define\\s+(\\S*\\(.*?\\))\\s*(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY),
43-
new MacroOptionParser("#define\\s+(\\S*)\\s*(\\S*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), };
41+
new MacroOptionParser("#define\\s+(\\S*\\(.*?\\))\\s*(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
42+
new MacroOptionParser("#define\\s+(\\S*)\\s*(\\S*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
4443

4544
@Override
4645
public String getToolchainId() {
@@ -61,44 +60,43 @@ private static List<String> makeList(String line) {
6160
return list;
6261
}
6362

64-
@SuppressWarnings("nls")
6563
@Override
6664
protected List<String> parseOptions(String lineIn) {
6765
String line = lineIn.trim();
6866

6967
// contribution of -dD option
70-
if (line.startsWith("#define")) {
68+
if (line.startsWith("#define")) { //$NON-NLS-1$
7169
return makeList(line);
7270
}
7371

7472
// contribution of includes
75-
if (line.equals("#include \"...\" search starts here:")) {
73+
if (line.equals("#include \"...\" search starts here:")) { //$NON-NLS-1$
7674
this.state = State.EXPECTING_LOCAL_INCLUDE;
77-
} else if (line.equals("#include <...> search starts here:")) {
75+
} else if (line.equals("#include <...> search starts here:")) { //$NON-NLS-1$
7876
this.state = State.EXPECTING_SYSTEM_INCLUDE;
79-
} else if (line.startsWith("End of search list.")) {
77+
} else if (line.startsWith("End of search list.")) { //$NON-NLS-1$
8078
this.state = State.NONE;
81-
} else if (line.equals("Framework search starts here:")) {
79+
} else if (line.equals("Framework search starts here:")) { //$NON-NLS-1$
8280
this.state = State.EXPECTING_FRAMEWORKS;
83-
} else if (line.startsWith("End of framework search list.")) {
81+
} else if (line.startsWith("End of framework search list.")) { //$NON-NLS-1$
8482
this.state = State.NONE;
8583
} else if (this.state == State.EXPECTING_LOCAL_INCLUDE) {
8684
// making that up for the parser to figure out
87-
line = "#include \"" + line + "\"";
85+
line = "#include \"" + line + "\""; //$NON-NLS-1$ //$NON-NLS-2$
8886
return makeList(line);
8987
} else {
90-
String frameworkIndicator = "(framework directory)";
88+
String frameworkIndicator = "(framework directory)"; //$NON-NLS-1$
9189
if (this.state == State.EXPECTING_SYSTEM_INCLUDE) {
9290
// making that up for the parser to figure out
9391
if (line.contains(frameworkIndicator)) {
94-
line = "#framework <" + line.replace(frameworkIndicator, "").trim() + ">";
92+
line = "#framework <" + line.replace(frameworkIndicator, "").trim() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
9593
} else {
96-
line = "#include <" + line + ">";
94+
line = "#include <" + line + ">"; //$NON-NLS-1$ //$NON-NLS-2$
9795
}
9896
return makeList(line);
9997
} else if (this.state == State.EXPECTING_FRAMEWORKS) {
10098
// making that up for the parser to figure out
101-
line = "#framework <" + line.replace(frameworkIndicator, "").trim() + ">";
99+
line = "#framework <" + line.replace(frameworkIndicator, "").trim() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
102100
return makeList(line);
103101
}
104102
}
@@ -143,6 +141,7 @@ protected String getCompilerCommand(String languageId) {
143141
// IContributedEnvironment contribEnv =
144142
// envManager.getContributedEnvironment();
145143
ICConfigurationDescription confDesc = prjDesc.getActiveConfiguration();
144+
146145
// Bug fix for CDT 8.1 fixed in 8.2
147146
IFolder buildFolder = this.currentProject.getFolder(confDesc.getName());
148147
if (!buildFolder.exists()) {
@@ -187,12 +186,12 @@ protected String getCompilerCommand(String languageId) {
187186
ManagedBuilderCorePlugin.error("Unable to find compiler command for language " + languageId + " in toolchain=" + getToolchainId()); //$NON-NLS-1$ //$NON-NLS-2$
188187
}
189188

190-
String ret = compilerCommand.replaceAll("[^\\\\]\"\"", Const.EMPTY_STRING).replaceAll(" ", " "); // remove //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
189+
String ret = compilerCommand.replaceAll(" -MMD ", " ").replaceAll("[^\\\\]\"\"", Const.EMPTY_STRING).replaceAll(" ", " "); // remove //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
191190
// "" except \""
192191
// and
193192
// double
194193
// blanks
195194
return ret;
196195
}
197196

198-
}
197+
}

it.baeyens.arduino.feature/feature.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ If you do not agree with this policy, then please do not install this software.
130130

131131
<url>
132132
<update label="Arduino eclipse plugin V2 update site" url="http://www.baeyens.it/eclipse/V2/"/>
133-
<discovery label="AVR-Eclipse offers plenty of godies for AVR development" url="http://avr-eclipse.sourceforge.net/wiki/index.php/Plugin_Download"/>
134133
<discovery label="jan&apos;s site with plenty of documentation" url="http://www.baeyens.it/eclipse/"/>
135134
</url>
136135

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = true
2-
org.eclipse.ui/defaultPerspectiveId=org.eclipse.cdt.ui.CPerspective
2+

0 commit comments

Comments
 (0)