1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Move class o.e.cdt.jsoncdb.core.participant.Arglets.SystemIncludePath_armcc to plugin org.eclipse.cdt.jsoncdb.arm

Eliminates a TODO.

Change-Id: I00b30ce14b0218947e7a93b95cd8f6e66ae2b650
Signed-off-by: Martin Weber <fifteenknots505@gmail.com>
This commit is contained in:
Martin Weber 2022-01-16 17:44:32 +01:00 committed by Jonah Graham
parent 93d0bf59c5
commit 7dc382abe3
5 changed files with 48 additions and 43 deletions

View file

@ -6,12 +6,12 @@
* *
* SPDX-License-Identifier: EPL-2.0 * SPDX-License-Identifier: EPL-2.0
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.jsoncdb.core.internal; package org.eclipse.cdt.jsoncdb.arm;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import org.eclipse.cdt.jsoncdb.core.participant.Arglets.SystemIncludePath_armcc; import org.eclipse.cdt.jsoncdb.core.participant.DefaultToolCommandlineParser;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.jsoncdb.core.participant.IToolCommandlineParser.IResult;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.junit.Before; import org.junit.Before;
@ -20,54 +20,50 @@ import org.junit.Test;
/** /**
* @author Martin Weber * @author Martin Weber
*/ */
public class SystemIncludePath_armcc_Test { public class SystemIncludePathTest {
private SystemIncludePath_armcc testee; private ArmccToolDetectionParticipant.SystemIncludePath_armcc testee;
/** /**
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
testee = new SystemIncludePath_armcc(); testee = new ArmccToolDetectionParticipant.SystemIncludePath_armcc();
} }
@Test @Test
public final void testProcessArgument() { public final void testProcessArgument() {
DefaultToolCommandlineParser tcp = new DefaultToolCommandlineParser(null, null, testee);
final String more = " -g " final String more = " -g "
+ " -o CMakeFiles/execut1.dir/util1.c.o -c /testprojects/C-subsrc/src/src-sub/main1.c"; + " -o CMakeFiles/execut1.dir/util1.c.o -c /testprojects/C-subsrc/src/src-sub/main1.c";
ParseContext result;
ICLanguageSettingEntry parsed;
final IPath cwd = new Path(""); final IPath cwd = new Path("");
String name = "/an/Include/Path"; String name = "/an/Include/Path";
IResult result;
// -J/an/Include/Path // -J/an/Include/Path
result = new ParseContext(); result = tcp.processArgs(cwd, "-J" + name + more);
assertEquals(2 + name.length(), testee.processArgument(result, cwd, "-J" + name + more));
assertEquals("#entries", 1, result.getSystemIncludePaths().size()); assertEquals("#entries", 1, result.getSystemIncludePaths().size());
assertEquals("name", name, result.getSystemIncludePaths().get(0)); assertEquals("name", name, result.getSystemIncludePaths().get(0));
// -J'/an/Include/Path' // -J'/an/Include/Path'
result = new ParseContext(); result = tcp.processArgs(cwd, "-J" + "'" + name + "'" + more);
assertEquals(2 + name.length() + 2, testee.processArgument(result, cwd, "-J" + "'" + name + "'" + more));
assertEquals("#entries", 1, result.getSystemIncludePaths().size()); assertEquals("#entries", 1, result.getSystemIncludePaths().size());
assertEquals("name", name, result.getSystemIncludePaths().get(0)); assertEquals("name", name, result.getSystemIncludePaths().get(0));
// -J"/an/Include/Path" // -J"/an/Include/Path"
result = new ParseContext(); result = tcp.processArgs(cwd, "-J" + "\"" + name + "\"" + more);
assertEquals(2 + name.length() + 2, testee.processArgument(result, cwd, "-J" + "\"" + name + "\"" + more));
assertEquals("#entries", 1, result.getSystemIncludePaths().size()); assertEquals("#entries", 1, result.getSystemIncludePaths().size());
assertEquals("name", name, result.getSystemIncludePaths().get(0)); assertEquals("name", name, result.getSystemIncludePaths().get(0));
name = (new Path("A:an\\In CLU de/Pat h")).toOSString(); name = (new Path("A:an\\In CLU de/Pat h")).toOSString();
// -J"A:an\In CLU de/Pat h" // -J"A:an\In CLU de/Pat h"
result = new ParseContext(); result = tcp.processArgs(cwd, "-J" + "\"" + name + "\"" + more);
assertEquals(2 + name.length() + 2, testee.processArgument(result, cwd, "-J" + "\"" + name + "\"" + more));
assertEquals("#entries", 1, result.getSystemIncludePaths().size()); assertEquals("#entries", 1, result.getSystemIncludePaths().size());
assertEquals("name", name, result.getSystemIncludePaths().get(0)); assertEquals("name", name, result.getSystemIncludePaths().get(0));
// -J'A:an\In CLU de/Pat h' // -J'A:an\In CLU de/Pat h'
result = new ParseContext(); result = tcp.processArgs(cwd, "-J" + "\"" + name + "\"" + more);
assertEquals(2 + name.length() + 2, testee.processArgument(result, cwd, "-J" + "'" + name + "'" + more));
assertEquals("#entries", 1, result.getSystemIncludePaths().size()); assertEquals("#entries", 1, result.getSystemIncludePaths().size());
assertEquals("name", name, result.getSystemIncludePaths().get(0)); assertEquals("name", name, result.getSystemIncludePaths().get(0));
} }

View file

@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %bundleName Bundle-Name: %bundleName
Bundle-Copyright: %Bundle-Copyright Bundle-Copyright: %Bundle-Copyright
Bundle-SymbolicName: org.eclipse.cdt.jsoncdb.arm;singleton:=true Bundle-SymbolicName: org.eclipse.cdt.jsoncdb.arm;singleton:=true
Bundle-Version: 1.0.0.qualifier Bundle-Version: 1.0.100.qualifier
Bundle-Vendor: %Bundle-Vendor Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-RequiredExecutionEnvironment: JavaSE-11

View file

@ -10,9 +10,12 @@
package org.eclipse.cdt.jsoncdb.arm; package org.eclipse.cdt.jsoncdb.arm;
import org.eclipse.cdt.jsoncdb.core.participant.Arglets; import org.eclipse.cdt.jsoncdb.core.participant.Arglets;
import org.eclipse.cdt.jsoncdb.core.participant.Arglets.IncludePathGeneric;
import org.eclipse.cdt.jsoncdb.core.participant.Arglets.NameOptionMatcher;
import org.eclipse.cdt.jsoncdb.core.participant.DefaultToolCommandlineParser; import org.eclipse.cdt.jsoncdb.core.participant.DefaultToolCommandlineParser;
import org.eclipse.cdt.jsoncdb.core.participant.DefaultToolDetectionParticipant; import org.eclipse.cdt.jsoncdb.core.participant.DefaultToolDetectionParticipant;
import org.eclipse.cdt.jsoncdb.core.participant.IArglet; import org.eclipse.cdt.jsoncdb.core.participant.IArglet;
import org.eclipse.core.runtime.IPath;
/** /**
* armcc C & C++. * armcc C & C++.
@ -29,10 +32,31 @@ public class ArmccToolDetectionParticipant extends DefaultToolDetectionParticipa
private static class ToolCommandlineParser extends DefaultToolCommandlineParser { private static class ToolCommandlineParser extends DefaultToolCommandlineParser {
private static final IArglet[] arglets = { new Arglets.IncludePath_C_POSIX(), new Arglets.MacroDefine_C_POSIX(), private static final IArglet[] arglets = { new Arglets.IncludePath_C_POSIX(), new Arglets.MacroDefine_C_POSIX(),
new Arglets.MacroUndefine_C_POSIX(), new Arglets.SystemIncludePath_armcc() }; new Arglets.MacroUndefine_C_POSIX(), new SystemIncludePath_armcc() };
private ToolCommandlineParser() { private ToolCommandlineParser() {
super(null, new ArmccBuiltinDetectionBehavior(), arglets); super(null, new ArmccBuiltinDetectionBehavior(), arglets);
} }
} }
/**
* A tool argument parser capable to parse a armcc-compiler system include path
* argument: {@code -Jdir}.
*/
/* package */ static class SystemIncludePath_armcc extends IncludePathGeneric implements IArglet {
@SuppressWarnings("nls")
static final NameOptionMatcher[] optionMatchers = {
/* quoted directory */
new NameOptionMatcher("-J" + "([\"'])(.+?)\\1", 2),
/* unquoted directory */
new NameOptionMatcher("-J" + "([^\\s]+)", 1), };
/*-
* @see org.eclipse.cdt.jsoncdb.IArglet#processArgs(java.lang.String)
*/
@Override
public int processArgument(IArgumentCollector resultCollector, IPath cwd, String argsLine) {
return processArgument(true, resultCollector, cwd, argsLine, optionMatchers);
}
}
} }

View file

@ -48,4 +48,12 @@
</message_arguments> </message_arguments>
</filter> </filter>
</resource> </resource>
<resource path="src/org/eclipse/cdt/jsoncdb/core/participant/Arglets.java" type="org.eclipse.cdt.jsoncdb.core.participant.Arglets">
<filter comment="Incorrectly named class that could not have been used is getting an API filter rather than old @deprecated API" id="338886760">
<message_arguments>
<message_argument value="org.eclipse.cdt.jsoncdb.core.participant.Arglets.SystemIncludePath_armcc"/>
<message_argument value="org.eclipse.cdt.jsoncdb.core_1.2.0"/>
</message_arguments>
</filter>
</resource>
</component> </component>

View file

@ -364,29 +364,6 @@ public final class Arglets {
} }
} }
////////////////////////////////////////////////////////////////////
/**
* A tool argument parser capable to parse a armcc-compiler system include path
* argument: {@code -Jdir}.
*/
// TODO move this to the arm plugin
public static class SystemIncludePath_armcc extends IncludePathGeneric implements IArglet {
@SuppressWarnings("nls")
static final NameOptionMatcher[] optionMatchers = {
/* quoted directory */
new NameOptionMatcher("-J" + "([\"'])(.+?)\\1", 2),
/* unquoted directory */
new NameOptionMatcher("-J" + "([^\\s]+)", 1), };
/*-
* @see org.eclipse.cdt.jsoncdb.IArglet#processArgs(java.lang.String)
*/
@Override
public int processArgument(IArgumentCollector resultCollector, IPath cwd, String argsLine) {
return processArgument(true, resultCollector, cwd, argsLine, optionMatchers);
}
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// POSIX compatible option parsers // POSIX compatible option parsers
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////