-
Notifications
You must be signed in to change notification settings - Fork 133
feat: Preference option for configuring eim_idf.json file #1444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
99c6682
147cb41
f276e4c
a506780
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /******************************************************************************* | ||
| * Copyright 2025 Espressif Systems (Shanghai) PTE LTD. All rights reserved. | ||
| * Use is subject to license terms. | ||
| *******************************************************************************/ | ||
| package com.espressif.idf.core.tools; | ||
|
|
||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
|
|
||
| import org.eclipse.core.runtime.Platform; | ||
| import org.eclipse.core.runtime.preferences.InstanceScope; | ||
|
|
||
| import com.espressif.idf.core.IDFCorePlugin; | ||
| import com.espressif.idf.core.IDFCorePreferenceConstants; | ||
|
|
||
| /** | ||
| * @author Kondal Kolipaka <kondal.kolipaka@espressif.com> | ||
| * | ||
| */ | ||
| public class EimIdfJsonPathResolver | ||
| { | ||
| public Path resolveEimIdfJsonFile() | ||
| { | ||
| String custom = InstanceScope.INSTANCE.getNode(IDFCorePlugin.PLUGIN_ID) | ||
| .get(IDFCorePreferenceConstants.EIM_IDF_JSON_PATH, ""); //$NON-NLS-1$ | ||
| return resolveEimIdfJsonFileFromPreferenceString(custom); | ||
| } | ||
|
|
||
| public Path resolveEimIdfJsonFileFromPreferenceString(String custom) | ||
| { | ||
| if (custom != null && !custom.isEmpty()) | ||
| { | ||
| Path p = Paths.get(custom); | ||
| if (p.getFileName() != null | ||
| && p.getFileName().toString().equals(EimConstants.EIM_JSON) | ||
| && Files.isRegularFile(p)) | ||
| { | ||
| return p; | ||
| } | ||
| } | ||
| return getDefaultEimIdfJsonFile(); | ||
| } | ||
|
|
||
| public String getDefaultEimIdfJsonPathString() | ||
| { | ||
| return Platform.getOS().equals(Platform.OS_WIN32) ? EimConstants.EIM_WIN_PATH : EimConstants.EIM_POSIX_PATH; | ||
| } | ||
|
|
||
| public Path getDefaultEimIdfJsonFile() | ||
| { | ||
| return Paths.get(getDefaultEimIdfJsonPathString()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,11 +6,10 @@ | |
|
|
||
| import java.io.File; | ||
|
|
||
| import org.eclipse.core.runtime.Platform; | ||
| import org.osgi.service.prefs.Preferences; | ||
|
|
||
| import com.espressif.idf.core.logging.Logger; | ||
| import com.espressif.idf.core.tools.EimConstants; | ||
| import com.espressif.idf.core.tools.EimIdfJsonPathResolver; | ||
|
|
||
| /** | ||
| * Checks if eim_idf.json was changed while Eclipse was not running. Stores and compares last seen timestamp to file | ||
|
|
@@ -62,6 +61,6 @@ public void updateLastSeenTimestamp() | |
|
|
||
| private String getEimJsonPath() | ||
| { | ||
| return Platform.getOS().equals(Platform.OS_WIN32) ? EimConstants.EIM_WIN_PATH : EimConstants.EIM_POSIX_PATH; | ||
| return new EimIdfJsonPathResolver().resolveEimIdfJsonFile().toString(); | ||
|
Comment on lines
62
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bind last-seen timestamp to the resolved file path. Because Line 64 now resolves a user-configurable path, keeping a single 🛠️ Suggested fix private static final String LAST_MODIFIED_PREF_KEY = "lastEimJsonModified"; //$NON-NLS-1$
+private static final String LAST_PATH_PREF_KEY = "lastEimJsonPath"; //$NON-NLS-1$
@@
public boolean wasModifiedSinceLastRun()
{
- File jsonFile = new File(getEimJsonPath());
+ String currentPath = getEimJsonPath();
+ File jsonFile = new File(currentPath);
if (!jsonFile.exists())
{
return false;
}
+ String lastPath = preferences.get(LAST_PATH_PREF_KEY, ""); //$NON-NLS-1$
+ if (!currentPath.equals(lastPath))
+ {
+ return false;
+ }
@@
public void updateLastSeenTimestamp()
{
- File jsonFile = new File(getEimJsonPath());
+ String currentPath = getEimJsonPath();
+ File jsonFile = new File(currentPath);
if (jsonFile.exists())
{
+ preferences.put(LAST_PATH_PREF_KEY, currentPath);
preferences.putLong(LAST_MODIFIED_PREF_KEY, jsonFile.lastModified());
}
}🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.