Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
feat: ts and js files have their warnings updated if an ignored warni…
Browse files Browse the repository at this point in the history
…ng is deleted
  • Loading branch information
L1nc0ln committed Sep 28, 2022
1 parent 94fa0c2 commit a8ddcad
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import de.adito.swing.icon.IconAttributes;
import org.jetbrains.annotations.*;
import org.netbeans.api.project.Project;
import org.openide.filesystems.FileUtil;
import org.openide.filesystems.*;
import org.openide.util.Lookup;
import org.openide.windows.TopComponent;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
Expand All @@ -17,6 +18,9 @@
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.attribute.FileTime;
import java.time.Instant;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -153,6 +157,8 @@ private void fireModelChanged()
private static class RemoveIgnoredWarningsAction extends AbstractAction
{

@NotNull
private static final Set<String> MIME_TYPES = Set.of("text/javascript", "text/typescript");
@NotNull
private final Project project;
@NotNull
Expand Down Expand Up @@ -184,12 +190,32 @@ public void actionPerformed(ActionEvent e)
{
IgnoredWarningsFacade.unIgnoreWarnings(project, itemsToRemove);
FileUtil.toFileObject(IgnoredWarningsProvider.getIgnoredWarningsFile(project)).refresh();
updateTopcomponents();

}
catch (IOException pE)
{
INotificationFacade.INSTANCE.error(pE);
}
}
}

/**
* trigger an update of all TopComponents containing js or ts files -> warnings are refreshed
*
* @throws IOException in case the lastModified time on a file cannot be set
*/
private void updateTopcomponents() throws IOException
{
for (TopComponent topComponent : TopComponent.getRegistry().getOpened())
{
FileObject fileObject = topComponent.getLookup().lookup(FileObject.class);
if (MIME_TYPES.contains(fileObject.getMIMEType()))
{
Files.setLastModifiedTime(FileUtil.toFile(fileObject).toPath(), FileTime.from(Instant.now()));
fileObject.refresh();
}
}
}
}
}

0 comments on commit a8ddcad

Please sign in to comment.