@@ -46,7 +46,7 @@ public List<LibraryMemoryComponent> getDataList(IFile mapFile) throws Exception
4646 {
4747 String pythonExecutablePath = preconditionsCheck ();
4848
49- List <String > arguments = getCommandArgsArchives (pythonExecutablePath , mapFile );
49+ List <String > arguments = getIDFSizeCommandArgs (pythonExecutablePath , mapFile , "--archives" ); //$NON-NLS-1$
5050 String detailsJsonOp = getOutput (mapFile , arguments );
5151 if (!StringUtil .isEmpty (detailsJsonOp ))
5252 {
@@ -57,18 +57,18 @@ public List<LibraryMemoryComponent> getDataList(IFile mapFile) throws Exception
5757 return convertToViewerModel (archivesJsonObj , symbolJsonObj );
5858 }
5959 }
60- return Collections .EMPTY_LIST ;
60+ return Collections .emptyList () ;
6161
6262 }
6363
64- public JSONObject getIDFSizeOverview (IFile mapFile , String targetName ) throws Exception
64+ public JSONObject getIDFSizeOverview (IFile mapFile ) throws Exception
6565 {
6666 String pythonExecutablePath = preconditionsCheck ();
67- List <String > commandArgs = getCommandArgs (pythonExecutablePath , mapFile , targetName );
67+ List <String > commandArgs = getIDFSizeCommandArgs (pythonExecutablePath , mapFile );
6868 String detailsJsonOp = getOutput (mapFile , commandArgs );
69- detailsJsonOp = detailsJsonOp .replace ("NaN" , "0" ); //$NON-NLS-1$ //$NON-NLS-2$
7069 if (!StringUtil .isEmpty (detailsJsonOp ))
7170 {
71+ detailsJsonOp = detailsJsonOp .replace ("NaN" , "0" ); //$NON-NLS-1$ //$NON-NLS-2$
7272 return getJSON (detailsJsonOp );
7373 }
7474 return null ;
@@ -107,7 +107,7 @@ private List<LibraryMemoryComponent> convertToViewerModel(JSONObject archivesJso
107107 String symbolName = symbolsKey .substring (key .length () + 1 ); // libnet80211.a:ieee80211_output.o
108108
109109 JSONObject symbolObj = (JSONObject ) symbolJsonObj .get (symbolsKey );
110-
110+
111111 record .getChildren ().add (getSizeRecord (symbolName , symbolObj ));
112112 }
113113
@@ -121,44 +121,46 @@ private List<LibraryMemoryComponent> convertToViewerModel(JSONObject archivesJso
121121 protected LibraryMemoryComponent getSizeRecord (String key , JSONObject object )
122122 {
123123 LibraryMemoryComponent library = new LibraryMemoryComponent ();
124- String [] keySplit = key .split ("/" );
125- String nameToSet = keySplit [keySplit .length - 1 ] + " -> " + key ;
124+ String [] keySplit = key .split ("/" );
125+ String nameToSet = keySplit [keySplit .length - 1 ] + " -> " + key ;
126126 library .setName (nameToSet );
127127 library .setAbbrevName ((String ) object .get ("abbrev_name" ));
128- library .setSize (getValue (object .get ("size" )));
129- library .setSizeDiff (getValue (object .get ("size_diff" )));
130- Map <String , MemoryType > memoryTypesMap = new LinkedHashMap <>();
131- JSONObject memoryTypesJson = (JSONObject ) object .get ("memory_types" );
128+ library .setSize (getValue (object .get ("size" )));
129+ library .setSizeDiff (getValue (object .get ("size_diff" )));
130+ Map <String , MemoryType > memoryTypesMap = new LinkedHashMap <>();
131+ JSONObject memoryTypesJson = (JSONObject ) object .get ("memory_types" );
132+
133+ for (Object memoryKeyObj : memoryTypesJson .keySet ())
134+ {
135+ String memoryKey = (String ) memoryKeyObj ;
136+ JSONObject memoryTypeJson = (JSONObject ) memoryTypesJson .get (memoryKey );
132137
133- for ( Object memoryKeyObj : memoryTypesJson . keySet ()) {
134- String memoryKey = ( String ) memoryKeyObj ;
135- JSONObject memoryTypeJson = ( JSONObject ) memoryTypesJson .get (memoryKey );
138+ MemoryType memoryType = new MemoryType ();
139+ memoryType . setSize ( getValue ( memoryTypeJson . get ( "size" ))) ;
140+ memoryType . setSizeDiff ( getValue ( memoryTypeJson .get ("size_diff" )) );
136141
137- MemoryType memoryType = new MemoryType ();
138- memoryType .setSize (getValue (memoryTypeJson .get ("size" )));
139- memoryType .setSizeDiff (getValue (memoryTypeJson .get ("size_diff" )));
142+ JSONObject sectionsJson = (JSONObject ) memoryTypeJson .get ("sections" );
143+ Map <String , Section > sectionsMap = new LinkedHashMap <>();
140144
141- JSONObject sectionsJson = (JSONObject ) memoryTypeJson .get ("sections" );
142- Map <String , Section > sectionsMap = new LinkedHashMap <>();
145+ for (Object sectionKeyObj : sectionsJson .keySet ())
146+ {
147+ String sectionKey = (String ) sectionKeyObj ;
148+ JSONObject sectionJson = (JSONObject ) sectionsJson .get (sectionKey );
143149
144- for (Object sectionKeyObj : sectionsJson .keySet ()) {
145- String sectionKey = (String ) sectionKeyObj ;
146- JSONObject sectionJson = (JSONObject ) sectionsJson .get (sectionKey );
150+ Section section = new Section ();
151+ section .setSize (getValue (sectionJson .get ("size" )));
152+ section .setSizeDiff (getValue (sectionJson .get ("size_diff" )));
153+ section .setAbbrevName ((String ) sectionJson .get ("abbrev_name" ));
147154
148- Section section = new Section ();
149- section .setSize (getValue (sectionJson .get ("size" )));
150- section .setSizeDiff (getValue (sectionJson .get ("size_diff" )));
151- section .setAbbrevName ((String ) sectionJson .get ("abbrev_name" ));
155+ sectionsMap .put (sectionKey , section );
156+ }
152157
153- sectionsMap .put (sectionKey , section );
154- }
158+ memoryType .setSections (sectionsMap );
159+ memoryTypesMap .put (memoryKey , memoryType );
160+ }
155161
156- memoryType .setSections (sectionsMap );
157- memoryTypesMap .put (memoryKey , memoryType );
158- }
162+ library .setMemoryTypes (memoryTypesMap );
159163
160- library .setMemoryTypes (memoryTypesMap );
161-
162164 return library ;
163165 }
164166
@@ -169,7 +171,7 @@ protected long getValue(Object object)
169171
170172 private JSONObject getSymbolDetails (String pythonExecutablePath , IFile mapFile )
171173 {
172- List <String > arguments = getCommandArgsSymbolDetails (pythonExecutablePath , mapFile );
174+ List <String > arguments = getIDFSizeCommandArgs (pythonExecutablePath , mapFile , "--file" ); //$NON-NLS-1$
173175 String symbolsJsonOp = getOutput (mapFile , arguments );
174176 if (!StringUtil .isEmpty (symbolsJsonOp ))
175177 {
@@ -214,13 +216,16 @@ protected IStatus runProcess(IFile file, List<String> arguments) throws Exceptio
214216 }
215217 }
216218
217- protected List <String > getCommandArgsArchives (String pythonExecutablenPath , IFile file )
219+ protected List <String > getIDFSizeCommandArgs (String pythonExecutablePath , IFile file , String ... additionalFlags )
218220 {
219- List <String > arguments = new ArrayList <String >();
220- arguments .add (pythonExecutablenPath );
221+ List <String > arguments = new ArrayList <>();
222+ arguments .add (pythonExecutablePath );
221223 arguments .add (IDFUtil .getIDFSizeScriptFile ().getAbsolutePath ());
222224 arguments .add (file .getLocation ().toOSString ());
223- arguments .add ("--archives" ); //$NON-NLS-1$
225+ if (additionalFlags != null )
226+ {
227+ Collections .addAll (arguments , additionalFlags );
228+ }
224229 arguments .addAll (addJsonParseCommand ());
225230
226231 return arguments ;
@@ -251,37 +256,12 @@ public boolean isVersionAtLeast(String currentIDFVersion, String minimumIDFVersi
251256 {
252257 return true ;
253258 }
254-
259+
255260 Version currentVersion = Version .parse (currentIDFVersion );
256261 Version minVersion = Version .parse (minimumIDFVersion );
257262 return currentVersion .compareTo (minVersion ) >= 0 ;
258263 }
259264
260- protected List <String > getCommandArgsSymbolDetails (String pythonExecutablenPath , IFile file )
261- {
262- List <String > arguments = new ArrayList <String >();
263- arguments .add (pythonExecutablenPath );
264- arguments .add (IDFUtil .getIDFSizeScriptFile ().getAbsolutePath ());
265- arguments .add (file .getLocation ().toOSString ());
266- arguments .add ("--file" ); //$NON-NLS-1$
267- arguments .addAll (addJsonParseCommand ());
268-
269- return arguments ;
270- }
271-
272- protected List <String > getCommandArgs (String pythonExecutablenPath , IFile file , String targetName )
273- {
274- List <String > arguments = new ArrayList <String >();
275- arguments .add (pythonExecutablenPath );
276- arguments .add ("-m" ); //$NON-NLS-1$
277- arguments .add ("esp_idf_size" ); //$NON-NLS-1$
278- arguments .add ("--ng" ); //$NON-NLS-1$
279- arguments .add ("--format" ); //$NON-NLS-1$
280- arguments .add ("json2" ); //$NON-NLS-1$
281- arguments .add (file .getLocation ().toOSString ());
282-
283- return arguments ;
284- }
285265
286266 protected JSONObject getJSON (String jsonOutput )
287267 {
0 commit comments