1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 564349 - rename classes with 'Indexer' in name to sth. more appropriate

Change-Id: I3247f3a001a6d0f882a6b4c674b1c7c0f74b1b9e
Signed-off-by: Martin Weber <fifteenknots505@gmail.com>
This commit is contained in:
Martin Weber 2021-07-08 23:13:36 +02:00
parent 72bc739a29
commit 2f65266115
20 changed files with 62 additions and 62 deletions

View file

@ -32,7 +32,7 @@ import org.eclipse.cdt.cmake.core.properties.ICMakeProperties;
import org.eclipse.cdt.cmake.core.properties.ICMakePropertiesController;
import org.eclipse.cdt.cmake.core.properties.IOsOverrides;
import org.eclipse.cdt.jsoncdb.core.CompileCommandsJsonParser;
import org.eclipse.cdt.jsoncdb.core.IIndexerInfoConsumer;
import org.eclipse.cdt.jsoncdb.core.ISourceFileInfoConsumer;
import org.eclipse.cdt.jsoncdb.core.ParseRequest;
import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ConsoleOutputStream;
@ -490,7 +490,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration {
project.deleteMarkers(ICMakeExecutionMarkerFactory.CMAKE_PROBLEM_MARKER_ID, false, IResource.DEPTH_INFINITE);
}
private static class CMakeIndexerInfoConsumer implements IIndexerInfoConsumer {
private static class CMakeIndexerInfoConsumer implements ISourceFileInfoConsumer {
/**
* gathered IScannerInfo objects or <code>null</code> if no new IScannerInfo was received
*/

View file

@ -41,13 +41,13 @@ public class GccOutputProcessorTest {
@Test
@Ignore
public void testProcessLine() {
testee.processLine("#define AAA xyz", new RawIndexerInfo());
testee.processLine("#define AAA xyz", new RawSourceFileInfo());
}
@Test
public void testProcessFile() throws IOException {
// pass resource content line-wise to the testee...
RawIndexerInfo pc = new RawIndexerInfo();
RawSourceFileInfo pc = new RawSourceFileInfo();
try (InputStream is = getClass().getResourceAsStream("cbd-gcc.output.txt");
OutputSniffer os = new OutputSniffer(testee, null, pc)) {
byte[] buffer = new byte[1024];

View file

@ -5,8 +5,8 @@
point="org.eclipse.ui.preferencePages">
<page
category="org.eclipse.cdt.cmake.ui.page1"
class="org.eclipse.cdt.jsoncdb.core.ui.internal.IndexerSupportPreferencePage"
id="org.eclipse.cdt.jsoncdb.core.ui.IndexerSupportPreferencePage"
class="org.eclipse.cdt.jsoncdb.core.ui.internal.JsonCdbPreferencePage"
id="org.eclipse.cdt.jsoncdb.core.ui.JsonCdbPreferencePage"
name="%page.name">
</page>
</extension>

View file

@ -39,17 +39,17 @@ import org.osgi.framework.FrameworkUtil;
/**
* Preference page for JSON Compilation Database Parser.
*/
public class IndexerSupportPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
public class JsonCdbPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
private Text pattern;
private Button btnVersionsEnabled;
private Button btnWithConsole;
private final IParserPreferencesAccess prefsAccess;
public IndexerSupportPreferencePage() {
public JsonCdbPreferencePage() {
prefsAccess = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext())
.get(IParserPreferencesAccess.class);
setDescription(Messages.IndexerSupportPreferencePage_description);
setDescription(Messages.JsonCdbPreferencePage_description);
}
/**
@ -64,13 +64,13 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor
composite.setLayout(new GridLayout(1, false));
GridDataFactory.swtDefaults().applyTo(composite);
final Group gr = createGroup(composite, SWT.FILL, 1,
Messages.IndexerSupportPreferencePage_label_version_suffix_group, 2);
final Group gr = createGroup(composite, SWT.FILL, 1, Messages.JsonCdbPreferencePage_label_version_suffix_group,
2);
btnVersionsEnabled = createCheckbox(gr, SWT.BEGINNING, 2, prefsMeta.tryVersionSuffix());
btnVersionsEnabled.setSelection(prefs.getTryVersionSuffix());
{
Label label = new Label(gr, SWT.NONE);
label.setText(Messages.IndexerSupportPreferencePage_label_suffix_pattern);
label.setText(Messages.JsonCdbPreferencePage_label_suffix_pattern);
GridDataFactory.defaultsFor(label).applyTo(label);
}
@ -88,7 +88,7 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor
Pattern.compile(text);
setErrorMessage(null);
} catch (PatternSyntaxException ex) {
String msg = String.format(Messages.IndexerSupportPreferencePage_errmsg_suffix_regex,
String msg = String.format(Messages.JsonCdbPreferencePage_errmsg_suffix_regex,
ex.getDescription(), ex.getPattern(), ex.getIndex());
setErrorMessage(msg);
}

View file

@ -19,10 +19,10 @@ import org.eclipse.osgi.util.NLS;
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.jsoncdb.core.ui.internal.messages"; //$NON-NLS-1$
public static String IndexerSupportPreferencePage_description;
public static String IndexerSupportPreferencePage_errmsg_suffix_regex;
public static String IndexerSupportPreferencePage_label_suffix_pattern;
public static String IndexerSupportPreferencePage_label_version_suffix_group;
public static String JsonCdbPreferencePage_description;
public static String JsonCdbPreferencePage_errmsg_suffix_regex;
public static String JsonCdbPreferencePage_label_suffix_pattern;
public static String JsonCdbPreferencePage_label_version_suffix_group;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);

View file

@ -11,7 +11,7 @@
# Contributors:
# Martin Weber - initial API and implementation
###############################################################################
IndexerSupportPreferencePage_description=Configure how macros and include paths get extracted from the compile_commands.json file
IndexerSupportPreferencePage_errmsg_suffix_regex=Suffix pattern regular expression: %1$s in '%2$s' at index %3$d
IndexerSupportPreferencePage_label_suffix_pattern=&Suffix pattern:
IndexerSupportPreferencePage_label_version_suffix_group=For compilers with version in name
JsonCdbPreferencePage_description=Configure how macros and include paths get extracted from the compile_commands.json file
JsonCdbPreferencePage_errmsg_suffix_regex=Suffix pattern regular expression: %1$s in '%2$s' at index %3$d
JsonCdbPreferencePage_label_suffix_pattern=&Suffix pattern:
JsonCdbPreferencePage_label_version_suffix_group=For compilers with version in name

View file

@ -32,7 +32,7 @@ import org.eclipse.cdt.jsoncdb.core.internal.ParserDetection.ParserDetectionResu
import org.eclipse.cdt.jsoncdb.core.internal.Plugin;
import org.eclipse.cdt.jsoncdb.core.internal.builtins.CompilerBuiltinsDetector;
import org.eclipse.cdt.jsoncdb.core.participant.DefaultToolDetectionParticipant;
import org.eclipse.cdt.jsoncdb.core.participant.IRawIndexerInfo;
import org.eclipse.cdt.jsoncdb.core.participant.IRawSourceFileInfo;
import org.eclipse.cdt.jsoncdb.core.participant.IToolCommandlineParser;
import org.eclipse.cdt.jsoncdb.core.participant.IToolCommandlineParser.IResult;
import org.eclipse.cdt.jsoncdb.core.participant.IToolDetectionParticipant;
@ -100,7 +100,7 @@ public class CompileCommandsJsonParser {
* the raw scanner info results for each source file (source file name ->
* IResult)
*/
private Map<String, IRawIndexerInfo> fileResults;
private Map<String, IRawSourceFileInfo> fileResults;
/**
* minimized set of CompilerBuiltinsDetector to run. (detector key ->
@ -272,9 +272,9 @@ public class CompileCommandsJsonParser {
java.nio.file.Path buildDir = java.nio.file.Path.of(buildRootFolder.getLocationURI());
// run each built-in detector and collect the results..
Map<String, IRawIndexerInfo> builtinDetectorsResults = new HashMap<>();
Map<String, IRawSourceFileInfo> builtinDetectorsResults = new HashMap<>();
for (Entry<String, CompilerBuiltinsDetector> entry : builtinDetectorsToRun.entrySet()) {
IRawIndexerInfo result = entry.getValue().detectBuiltins(jsonFile.getProject(), buildDir,
IRawSourceFileInfo result = entry.getValue().detectBuiltins(jsonFile.getProject(), buildDir,
parseRequest.getLauncher(), parseRequest.getConsole(), monitor);
// store detector key with result
builtinDetectorsResults.put(entry.getKey(), result);
@ -294,8 +294,8 @@ public class CompileCommandsJsonParser {
// merge built-in results with source file results
for (Entry<String, String> link : fileToBuiltinDetectorLinks.entrySet()) {
String sourceFileName = link.getKey();
IRawIndexerInfo fileResult = fileResults.get(sourceFileName);
IRawIndexerInfo builtinDetectorsResult = builtinDetectorsResults.get(link.getValue());
IRawSourceFileInfo fileResult = fileResults.get(sourceFileName);
IRawSourceFileInfo builtinDetectorsResult = builtinDetectorsResults.get(link.getValue());
mergeResultsForFile(stringPooler, sourceFileName, fileResult, builtinDetectorsResult);
}
}
@ -303,7 +303,7 @@ public class CompileCommandsJsonParser {
/**
* Merges preprocessor symbols and macros for a source file with compiler
* built-in preprocessor symbols and macros and passes the to the
* {@code IIndexerInfoConsumer} that was specified in the constructor.
* {@code ISourceFileInfoConsumer} that was specified in the constructor.
*
* @param fileResult source file preprocessor symbols and macros
* @param builtinDetectorsResult compiler built-in preprocessor symbols and
@ -313,7 +313,7 @@ public class CompileCommandsJsonParser {
* @param sourceFileName the name of the source file
*/
private void mergeResultsForFile(Function<String, String> stringPooler, String sourceFileName,
IRawIndexerInfo fileResult, IRawIndexerInfo builtinDetectorsResult) {
IRawSourceFileInfo fileResult, IRawSourceFileInfo builtinDetectorsResult) {
/*
* Handling of -U and -D is ambivalent here. - The GCC man page states: '-U name
* Cancel any previous definition of name, either built in or provided with a -D
@ -344,8 +344,8 @@ public class CompileCommandsJsonParser {
List<String> includeFiles = fileResult.getIncludeFiles();
// feed the paths and defines with the file name to the indexer..
parseRequest.getIndexerInfoConsumer().acceptSourceFileInfo(sourceFileName, systemIncludePaths, effectiveDefines,
includePaths, macroFiles, includeFiles);
parseRequest.getSourceFileInfoConsumer().acceptSourceFileInfo(sourceFileName, systemIncludePaths,
effectiveDefines, includePaths, macroFiles, includeFiles);
}
private static void createMarker(IResource rc, String message) throws CoreException {
@ -417,7 +417,7 @@ public class CompileCommandsJsonParser {
* Parses the {@code compile_commands.json} file in the build directory of the
* build configuration if necessary and generates indexer information. If the JSON file did not change since the last invocation
* of this method on the same build configuration, parsing of the file will be skipped; that is:
* Method {@link IIndexerInfoConsumer#accept()} is not invoked.
* Method {@link ISourceFileInfoConsumer#accept()} is not invoked.
* @param monitor the job's progress monitor
*
* @return {@code true} if the {@code compile_commands.json} file did change
@ -440,7 +440,7 @@ public class CompileCommandsJsonParser {
}
return processJsonFile(monitor);
} finally {
parseRequest.getIndexerInfoConsumer().shutdown();
parseRequest.getSourceFileInfoConsumer().shutdown();
if (DEBUG_TIME) {
long end = System.currentTimeMillis();
System.out.printf("Parsed file '%s' in %dms%n", //$NON-NLS-1$
@ -492,7 +492,7 @@ public class CompileCommandsJsonParser {
* @param file
* @param result
*/
private void rememberFileResult(String sourceFileName, IRawIndexerInfo result) {
private void rememberFileResult(String sourceFileName, IRawSourceFileInfo result) {
fileResults.put(sourceFileName, result);
}

View file

@ -22,13 +22,13 @@ import java.util.Map;
*
* @author weber
*/
public interface IIndexerInfoConsumer {
public interface ISourceFileInfoConsumer {
// Cmake writes filenames with forward slashes (/) even if it runs on windows.
// OTOH, IScannerInfoProvider requests info for IResourceS.
// Somewhere in the calling sequence, the filenames have to be converted/mapped to IResource. Conversion *could*
// be done in CompileCommandsJsonParser, but when I think of builds running
// in a Linux-Docker-Container under windows, it might be better to do the conversion
// on the IIndexerInfoConsumer side which has more information on the build setup.
// on the ISourceFileInfoConsumer side which has more information on the build setup.
/** Adds indexer relevant information for a single source file.
*

View file

@ -23,7 +23,7 @@ import org.eclipse.core.resources.IFile;
*/
public final class ParseRequest {
private final IFile compileCommandsJson;
private final IIndexerInfoConsumer indexerInfoConsumer;
private final ISourceFileInfoConsumer indexerInfoConsumer;
private final ICommandLauncher launcher;
private final IConsole console;
@ -39,7 +39,7 @@ public final class ParseRequest {
* detection to or <code>null</code> if no console output is requested.
* Ignored if workspace preferences indicate that no console output is wanted.
*/
public ParseRequest(IFile compileCommandsJsonFile, IIndexerInfoConsumer indexerInfoConsumer,
public ParseRequest(IFile compileCommandsJsonFile, ISourceFileInfoConsumer indexerInfoConsumer,
ICommandLauncher launcher, IConsole console) {
this.compileCommandsJson = Objects.requireNonNull(compileCommandsJsonFile, "compileCommandsJsonFile"); //$NON-NLS-1$
this.indexerInfoConsumer = Objects.requireNonNull(indexerInfoConsumer, "indexerInfoConsumer"); //$NON-NLS-1$
@ -56,7 +56,7 @@ public final class ParseRequest {
/** Gets the object that receives the indexer relevant
* information for each source file
*/
public IIndexerInfoConsumer getIndexerInfoConsumer() {
public ISourceFileInfoConsumer getSourceFileInfoConsumer() {
return indexerInfoConsumer;
}

View file

@ -12,7 +12,7 @@ package org.eclipse.cdt.jsoncdb.core.internal;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.jsoncdb.core.internal.builtins.RawIndexerInfo;
import org.eclipse.cdt.jsoncdb.core.internal.builtins.RawSourceFileInfo;
import org.eclipse.cdt.jsoncdb.core.participant.IArglet;
import org.eclipse.cdt.jsoncdb.core.participant.IToolCommandlineParser;
@ -21,7 +21,7 @@ import org.eclipse.cdt.jsoncdb.core.participant.IToolCommandlineParser;
*
* @author Martin Weber
*/
public final class ParseContext extends RawIndexerInfo
public final class ParseContext extends RawSourceFileInfo
implements IArglet.IArgumentCollector, IToolCommandlineParser.IResult {
private final List<String> args = new ArrayList<>();

View file

@ -20,7 +20,7 @@ import java.util.Objects;
import org.eclipse.cdt.jsoncdb.core.IParserPreferences;
import org.eclipse.cdt.jsoncdb.core.IParserPreferencesAccess;
import org.eclipse.cdt.jsoncdb.core.internal.Plugin;
import org.eclipse.cdt.jsoncdb.core.participant.IRawIndexerInfo;
import org.eclipse.cdt.jsoncdb.core.participant.IRawSourceFileInfo;
import org.eclipse.cdt.jsoncdb.core.participant.builtins.IBuiltinsDetectionBehavior;
import org.eclipse.cdt.jsoncdb.core.participant.builtins.IBuiltinsOutputProcessor;
import org.eclipse.cdt.jsoncdb.core.participant.builtins.OutputSniffer;
@ -86,7 +86,7 @@ public class CompilerBuiltinsDetector {
* <code>null</code> if no console output is requested.
* @throws CoreException
*/
public IRawIndexerInfo detectBuiltins(IProject project, java.nio.file.Path buildDirectory,
public IRawSourceFileInfo detectBuiltins(IProject project, java.nio.file.Path buildDirectory,
ICommandLauncher launcher, IConsole console, IProgressMonitor monitor) throws CoreException {
this.project = Objects.requireNonNull(project, "project"); //$NON-NLS-1$
this.buildDirectory = Objects.requireNonNull(buildDirectory, "buildDirectory"); //$NON-NLS-1$
@ -95,7 +95,7 @@ public class CompilerBuiltinsDetector {
monitor = new NullProgressMonitor();
}
RawIndexerInfo result = new RawIndexerInfo();
RawSourceFileInfo result = new RawSourceFileInfo();
final List<String> argList = getCompilerArguments();
argList.addAll(builtinsDetectionArgs);

View file

@ -21,16 +21,16 @@ import java.util.Map.Entry;
import java.util.Objects;
import org.eclipse.cdt.jsoncdb.core.internal.Plugin;
import org.eclipse.cdt.jsoncdb.core.participant.IRawIndexerInfo;
import org.eclipse.cdt.jsoncdb.core.participant.IRawIndexerInfoCollector;
import org.eclipse.cdt.jsoncdb.core.participant.IRawSourceFileInfoCollector;
import org.eclipse.cdt.jsoncdb.core.participant.IRawSourceFileInfo;
import org.eclipse.core.runtime.Platform;
/**
* Default implementation of IRawIndexerInfo.
* Default implementation of IRawSourceFileInfo.
*
* @author weber
*/
public class RawIndexerInfo implements IRawIndexerInfo, IRawIndexerInfoCollector {
public class RawSourceFileInfo implements IRawSourceFileInfo, IRawSourceFileInfoCollector {
@SuppressWarnings("nls")
private static final boolean DEBUG = Boolean

View file

@ -41,7 +41,7 @@ public interface IArglet {
*
* @author Martin Weber
*/
interface IArgumentCollector extends IRawIndexerInfoCollector {
interface IArgumentCollector extends IRawSourceFileInfoCollector {
/**
* Adds a compiler argument that affects built-in detection. For the GNU
* compilers, these are options like {@code --sysroot} and options that specify

View file

@ -20,7 +20,7 @@ import java.util.Map;
*
* @author weber
*/
public interface IRawIndexerInfo {
public interface IRawSourceFileInfo {
/**
* Gets the preprocessor symbols (macro definition)s.
*/

View file

@ -17,7 +17,7 @@ package org.eclipse.cdt.jsoncdb.core.participant;
*
* @author weber
*/
public interface IRawIndexerInfoCollector {
public interface IRawSourceFileInfoCollector {
/**
* Adds a preprocessor symbol (macro definition).

View file

@ -49,7 +49,7 @@ public interface IToolCommandlineParser {
*
* @see IToolCommandlineParser#processArgs(IPath, String)
*/
interface IResult extends IRawIndexerInfo {
interface IResult extends IRawSourceFileInfo {
/**
* Gets the compiler arguments from the command-line that affect built-in
* detection. For the GNU compilers, these are options like {@code --sysroot}

View file

@ -13,7 +13,7 @@ import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.cdt.jsoncdb.core.participant.IRawIndexerInfoCollector;
import org.eclipse.cdt.jsoncdb.core.participant.IRawSourceFileInfoCollector;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
@ -50,7 +50,7 @@ public final class GccOutputProcessor implements IBuiltinsOutputProcessor {
@SuppressWarnings("nls")
@Override
public void processLine(String line, IRawIndexerInfoCollector infoCollector) {
public void processLine(String line, IRawSourceFileInfoCollector infoCollector) {
// include paths
if (line.equals("#include \"...\" search starts here:")) {

View file

@ -9,7 +9,7 @@
package org.eclipse.cdt.jsoncdb.core.participant.builtins;
import org.eclipse.cdt.jsoncdb.core.participant.IRawIndexerInfoCollector;
import org.eclipse.cdt.jsoncdb.core.participant.IRawSourceFileInfoCollector;
/**
* Responsible for parsing the output that is produced when a compiler is
@ -25,5 +25,5 @@ public interface IBuiltinsOutputProcessor {
* @param infoCollector the buffer that receives the new {@code LanguageSetting}
* entries
*/
void processLine(String line, IRawIndexerInfoCollector infoCollector);
void processLine(String line, IRawSourceFileInfoCollector infoCollector);
}

View file

@ -13,7 +13,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Objects;
import org.eclipse.cdt.jsoncdb.core.participant.IRawIndexerInfoCollector;
import org.eclipse.cdt.jsoncdb.core.participant.IRawSourceFileInfoCollector;
/**
* An OutputStream that passes each line written to it to a
@ -28,7 +28,7 @@ public class OutputSniffer extends OutputStream {
private static final String SEP = System.lineSeparator();
private final StringBuilder buffer;
private final IBuiltinsOutputProcessor processor;
private final IRawIndexerInfoCollector infoCollector;
private final IRawSourceFileInfoCollector infoCollector;
private final OutputStream os;
/**
@ -37,7 +37,7 @@ public class OutputSniffer extends OutputStream {
* and include paths
*/
public OutputSniffer(IBuiltinsOutputProcessor processor, OutputStream outputStream,
IRawIndexerInfoCollector infoCollector) {
IRawSourceFileInfoCollector infoCollector) {
this.processor = Objects.requireNonNull(processor, "processor"); //$NON-NLS-1$
this.infoCollector = Objects.requireNonNull(infoCollector, "infoCollector"); //$NON-NLS-1$
this.os = outputStream;

View file

@ -20,7 +20,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.eclipse.cdt.jsoncdb.core.participant.IRawIndexerInfoCollector;
import org.eclipse.cdt.jsoncdb.core.participant.IRawSourceFileInfoCollector;
import org.eclipse.cdt.jsoncdb.core.participant.builtins.GccOutputProcessor;
import org.eclipse.cdt.jsoncdb.core.participant.builtins.OutputSniffer;
import org.junit.Before;
@ -45,7 +45,7 @@ public class NvccOutputProcessorTest {
@Test
public void testProcessFile() throws IOException {
// pass resource content line-wise to the testee...
RawIndexerInfoMock pc = new RawIndexerInfoMock();
RawSourceFileInfoMock pc = new RawSourceFileInfoMock();
try (InputStream is = getClass().getResourceAsStream("cbd-nvcc.output.txt");
OutputSniffer os = new OutputSniffer(testee, null, pc)) {
byte[] buffer = new byte[1024];
@ -63,7 +63,7 @@ public class NvccOutputProcessorTest {
assertEquals("value", "85", pc.defines.get("__CUDACC_VER_BUILD__"));
}
private static class RawIndexerInfoMock implements IRawIndexerInfoCollector {
private static class RawSourceFileInfoMock implements IRawSourceFileInfoCollector {
private final Map<String, String> defines = new HashMap<>();
private final List<String> undefines = new ArrayList<>();
private final List<String> includePaths = new ArrayList<>();