JavaScript: Drop redundant columns from files and folders relations

This commit is contained in:
Tom Hvitved
2021-09-14 09:33:47 +02:00
parent 3bdc92ba8e
commit 63e28c57cd
4 changed files with 10 additions and 482 deletions

View File

@@ -11,6 +11,7 @@ import com.semmle.util.data.Pair;
import com.semmle.util.data.StringUtil;
import com.semmle.util.extraction.ExtractorOutputConfig;
import com.semmle.util.io.WholeIO;
import com.semmle.util.process.Env;
import com.semmle.util.srcarchive.DummySourceArchive;
import com.semmle.util.trap.ITrapWriterFactory;
import com.semmle.util.trap.TrapWriter;
@@ -21,6 +22,7 @@ import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import org.junit.AfterClass;
@@ -140,6 +142,10 @@ public class TrapTests {
options.add(inputFile.getAbsolutePath());
}
LinkedHashMap<String, String> vars = new LinkedHashMap<>();
vars.put("CODEQL_REDUCE_FILES_FOLDERS_RELATIONS", "true");
Env.systemEnv().pushEnvironmentContext(vars);
final List<Pair<String, String>> expectedVsActual = new ArrayList<Pair<String, String>>();
Main main =
new Main(

View File

@@ -156,7 +156,7 @@ abstract class Container extends @container {
/** A folder. */
class Folder extends Container, @folder {
override string getAbsolutePath() { folders(this, result, _) }
override string getAbsolutePath() { folders(this, result) }
/** Gets the file or subfolder in this folder that has the given `name`, if any. */
Container getChildContainer(string name) {
@@ -203,7 +203,7 @@ class File extends Container, @file {
*/
Location getLocation() { hasLocation(this, result) }
override string getAbsolutePath() { files(this, result, _, _, _) }
override string getAbsolutePath() { files(this, result) }
/** Gets the number of lines in this file. */
int getNumberOfLines() { result = sum(int loc | numlines(this, loc, _, _) | loc) }

View File

@@ -20,21 +20,11 @@ numlines(int element_id: @sourceline ref,
int num_comment: int ref
);
/*
fromSource(0) = unknown,
fromSource(1) = from source,
fromSource(2) = from library
*/
files(unique int id: @file,
varchar(900) name: string ref,
varchar(900) simple: string ref,
varchar(900) ext: string ref,
int fromSource: int ref);
varchar(900) name: string ref);
folders(unique int id: @folder,
varchar(900) name: string ref,
varchar(900) simple: string ref);
varchar(900) name: string ref);
@container = @folder | @file ;

View File

@@ -4840,18 +4840,6 @@
<k>name</k>
<v>6457</v>
</e>
<e>
<k>simple</k>
<v>4188</v>
</e>
<e>
<k>ext</k>
<v>4</v>
</e>
<e>
<k>fromSource</k>
<v>1</v>
</e>
</columnsizes>
<dependencies>
<dep>
@@ -4871,54 +4859,6 @@
</val>
</dep>
<dep>
<src>id</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>6457</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>id</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>6457</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>id</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>6457</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>id</trg>
<val>
@@ -4934,316 +4874,6 @@
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>6457</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>6457</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>6457</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>3423</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>507</v>
</b>
<b>
<a>3</a>
<b>305</b>
<v>258</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>3423</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>507</v>
</b>
<b>
<a>3</a>
<b>305</b>
<v>258</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>3960</v>
</b>
<b>
<a>2</a>
<b>4</b>
<v>228</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>4188</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>21</a>
<b>22</b>
<v>1</v>
</b>
<b>
<a>480</a>
<b>481</b>
<v>1</v>
</b>
<b>
<a>756</a>
<b>757</b>
<v>1</v>
</b>
<b>
<a>5200</a>
<b>5201</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>21</a>
<b>22</b>
<v>1</v>
</b>
<b>
<a>480</a>
<b>481</b>
<v>1</v>
</b>
<b>
<a>756</a>
<b>757</b>
<v>1</v>
</b>
<b>
<a>5200</a>
<b>5201</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>21</a>
<b>22</b>
<v>1</v>
</b>
<b>
<a>118</a>
<b>119</b>
<v>1</v>
</b>
<b>
<a>428</a>
<b>429</b>
<v>1</v>
</b>
<b>
<a>3858</a>
<b>3859</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>ext</src>
<trg>fromSource</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>4</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>6457</a>
<b>6458</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>6457</a>
<b>6458</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>4188</a>
<b>4189</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>fromSource</src>
<trg>ext</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>4</a>
<b>5</b>
<v>1</v>
</b>
</bs>
</hist>
</val>
</dep>
</dependencies>
</relation>
<relation>
@@ -5259,10 +4889,6 @@
<k>name</k>
<v>1590</v>
</e>
<e>
<k>simple</k>
<v>645</v>
</e>
</columnsizes>
<dependencies>
<dep>
@@ -5282,22 +4908,6 @@
</val>
</dep>
<dep>
<src>id</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>1590</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>id</trg>
<val>
@@ -5313,84 +4923,6 @@
</hist>
</val>
</dep>
<dep>
<src>name</src>
<trg>simple</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>1590</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>id</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>425</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>127</v>
</b>
<b>
<a>3</a>
<b>6</b>
<v>58</v>
</b>
<b>
<a>6</a>
<b>113</b>
<v>35</v>
</b>
</bs>
</hist>
</val>
</dep>
<dep>
<src>simple</src>
<trg>name</trg>
<val>
<hist>
<budget>12</budget>
<bs>
<b>
<a>1</a>
<b>2</b>
<v>425</v>
</b>
<b>
<a>2</a>
<b>3</b>
<v>127</v>
</b>
<b>
<a>3</a>
<b>6</b>
<v>58</v>
</b>
<b>
<a>6</a>
<b>113</b>
<v>35</v>
</b>
</bs>
</hist>
</val>
</dep>
</dependencies>
</relation>
<relation>