diff --git a/src/main/java/io/github/tandemdude/hklbsupport/CommandParameterCompletionContributor.java b/src/main/java/io/github/tandemdude/hklbsupport/CommandParameterCompletionContributor.java index f67ddc6..f41a775 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/CommandParameterCompletionContributor.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/CommandParameterCompletionContributor.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport; import com.intellij.codeInsight.completion.CompletionContributor; diff --git a/src/main/java/io/github/tandemdude/hklbsupport/CommandParameterTypeInspector.java b/src/main/java/io/github/tandemdude/hklbsupport/CommandParameterTypeInspector.java index b56f94d..ee78a0b 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/CommandParameterTypeInspector.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/CommandParameterTypeInspector.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport; import com.intellij.codeInspection.LocalInspectionToolSession; diff --git a/src/main/java/io/github/tandemdude/hklbsupport/CommandRequiredParametersInspector.java b/src/main/java/io/github/tandemdude/hklbsupport/CommandRequiredParametersInspector.java index 0f49a88..daad37a 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/CommandRequiredParametersInspector.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/CommandRequiredParametersInspector.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport; import com.intellij.codeInspection.LocalInspectionToolSession; diff --git a/src/main/java/io/github/tandemdude/hklbsupport/LightbulbPackageManagerListener.java b/src/main/java/io/github/tandemdude/hklbsupport/LightbulbPackageManagerListener.java index cf25f75..dda64e0 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/LightbulbPackageManagerListener.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/LightbulbPackageManagerListener.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport; import com.intellij.openapi.application.ApplicationManager; diff --git a/src/main/java/io/github/tandemdude/hklbsupport/ProjectDataService.java b/src/main/java/io/github/tandemdude/hklbsupport/ProjectDataService.java index c6ba8a7..d1d8e7a 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/ProjectDataService.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/ProjectDataService.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport; import com.fasterxml.jackson.core.type.TypeReference; @@ -56,48 +78,45 @@ LightbulbData readMetaparamsFile(String version, VirtualFile vf) throws IOExcept return new LightbulbData(version, parsedParamData); } - public void notifyChange(Sdk sdk) { - if (!sdkCache.containsKey(sdk)) { - return; + boolean populateCacheForSdk(Sdk sdk, VirtualFile paramsFile) { + if (!paramsFile.getName().equals("metaparams.json") + || !paramsFile.getParent().getName().equals("lightbulb")) { + return true; + } + + var initFile = paramsFile.getParent().findChild("__init__.py"); + if (initFile == null) { + return true; + } + + try { + var matcher = VERSION_PATTERN.matcher(new String(initFile.contentsToByteArray())); + String version = null; + while (matcher.find()) { + version = matcher.group(1); + } + + if (version == null) { + return true; + } + + if (sdkCache.get(sdk) != null && version.equals(sdkCache.get(sdk).version())) { + return false; + } + + var data = readMetaparamsFile(version, paramsFile); + sdkCache.put(sdk, data); + Notifier.notifyInformation(project, "Lightbulb configuration loaded successfully (%s)", sdk.getName()); + } catch (IOException e) { + throw new RuntimeException(e); } + return false; + } + public void notifyChange(Sdk sdk) { FileTypeIndex.processFiles( FileTypeManager.getInstance().getFileTypeByExtension("json"), - file -> { - if (!file.getName().equals("metaparams.json") - || !file.getParent().getName().equals("lightbulb")) { - return true; - } - - var initFile = file.getParent().findChild("__init__.py"); - if (initFile == null) { - return true; - } - - try { - var matcher = VERSION_PATTERN.matcher(new String(initFile.contentsToByteArray())); - String version = null; - while (matcher.find()) { - version = matcher.group(1); - } - - if (version == null) { - return true; - } - - if (version.equals(sdkCache.get(sdk).version())) { - return false; - } - - var data = readMetaparamsFile(version, file); - sdkCache.put(sdk, data); - Notifier.notifyInformation( - project, "Lightbulb configuration loaded successfully (%s)", sdk.getName()); - } catch (IOException e) { - throw new RuntimeException(e); - } - return false; - }, + file -> populateCacheForSdk(sdk, file), GlobalSearchScope.allScope(project)); } } diff --git a/src/main/java/io/github/tandemdude/hklbsupport/actions/CacheRefreshAction.java b/src/main/java/io/github/tandemdude/hklbsupport/actions/CacheRefreshAction.java index 6072eb3..5b9cf4e 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/actions/CacheRefreshAction.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/actions/CacheRefreshAction.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport.actions; import com.intellij.openapi.actionSystem.ActionUpdateThread; diff --git a/src/main/java/io/github/tandemdude/hklbsupport/models/LightbulbData.java b/src/main/java/io/github/tandemdude/hklbsupport/models/LightbulbData.java index 207a4a5..2c5bdfa 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/models/LightbulbData.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/models/LightbulbData.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport.models; import java.util.Map; diff --git a/src/main/java/io/github/tandemdude/hklbsupport/models/ParamData.java b/src/main/java/io/github/tandemdude/hklbsupport/models/ParamData.java index b0a0124..2f5a313 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/models/ParamData.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/models/ParamData.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport.models; import java.util.Map; diff --git a/src/main/java/io/github/tandemdude/hklbsupport/utils/Notifier.java b/src/main/java/io/github/tandemdude/hklbsupport/utils/Notifier.java index 36b761d..d7272c7 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/utils/Notifier.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/utils/Notifier.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport.utils; import com.intellij.notification.NotificationGroupManager; diff --git a/src/main/java/io/github/tandemdude/hklbsupport/utils/Utils.java b/src/main/java/io/github/tandemdude/hklbsupport/utils/Utils.java index 9b9a568..46ba0ff 100644 --- a/src/main/java/io/github/tandemdude/hklbsupport/utils/Utils.java +++ b/src/main/java/io/github/tandemdude/hklbsupport/utils/Utils.java @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2024-present tandemdude + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package io.github.tandemdude.hklbsupport.utils; import com.intellij.openapi.module.ModuleUtilCore;