Files
ghidra/Ghidra/Features/Base/ghidra_scripts/RemoveSourceLanguage.java
T

50 lines
1.5 KiB
Java

/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//Removes a source language from the program
//@category Program
import java.util.*;
import ghidra.app.script.GhidraScript;
import ghidra.app.util.sourcelanguage.SourceLanguageID;
public class RemoveSourceLanguage extends GhidraScript {
@Override
public void run() throws Exception {
if (currentProgram == null) {
return;
}
Set<SourceLanguageID> idSet = currentProgram.getSourceLanguageIDs();
if (idSet.isEmpty()) {
println("No source languages found in " + currentProgram);
}
Set<SourceLanguageID> selected = new HashSet<>(askChoices("Remove Source Language(s)",
"Select source languages to remove from the program", new ArrayList<>(idSet)));
// Remove from the "Source Language" program property
idSet.removeIf(selected::contains);
currentProgram.setSourceLanguageIDs(idSet);
// Future: Remove associated spec extensions if possible
// Future: Remove associated data archives if possible
}
}