105 lines
3.3 KiB
Java
105 lines
3.3 KiB
Java
package _VisualDVM.ProjectData.SapforData.Loops;
|
||
import Common.Visual.Fonts.VisualiserFonts;
|
||
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
||
import _VisualDVM.ProjectData.Messages.Message;
|
||
import _VisualDVM.ProjectData.SapforData.FileObjectWithMessages;
|
||
import _VisualDVM.ProjectData.SapforData.Functions.FuncCall;
|
||
import com.google.gson.annotations.Expose;
|
||
|
||
import java.util.LinkedHashMap;
|
||
import java.util.List;
|
||
import java.util.Vector;
|
||
public class Loop extends FileObjectWithMessages {
|
||
@Expose
|
||
private int lineNumAfterLoop;
|
||
@Expose
|
||
private int perfectLoop;
|
||
@Expose
|
||
private int hasNonRectangularBounds;
|
||
@Expose
|
||
private int loopState;
|
||
public LoopState getLoopState(){
|
||
switch (loopState){
|
||
case 1:
|
||
return LoopState.GoodLoop;
|
||
case 2:
|
||
return LoopState.BadLoop;
|
||
default:
|
||
return LoopState.Loop;
|
||
}
|
||
}
|
||
//---
|
||
@Expose
|
||
public List<Integer> extGotos = new Vector<>();
|
||
@Expose
|
||
public List<Integer> intGotos = new Vector<>();
|
||
@Expose
|
||
public List<Integer> ios = new Vector<>();
|
||
@Expose
|
||
public List<Integer> stops = new Vector<>();
|
||
//--
|
||
@Expose
|
||
public List<FuncCall> funcCalls = new Vector<>();
|
||
@Expose
|
||
public List<Loop> children = new Vector<>();
|
||
//--
|
||
public List<FileObjectWithMessages> getGraphNodes(DBProjectFile dbProjectFile){
|
||
List<FileObjectWithMessages> all_children = new Vector<>();
|
||
//-
|
||
if (hasNonRectangularBounds!=0)
|
||
all_children.add(new NonRectIter(dbProjectFile, line));
|
||
//-
|
||
all_children.addAll(funcCalls);
|
||
//-
|
||
for (int line_: extGotos)
|
||
all_children.add(new EGoto(dbProjectFile, line_));
|
||
for (int line_: intGotos)
|
||
all_children.add(new IGoto(dbProjectFile, line_));
|
||
for (int line_: ios)
|
||
all_children.add(new IO(dbProjectFile, line_));
|
||
for (int line_: stops)
|
||
all_children.add(new Stop(dbProjectFile, line_));
|
||
//-
|
||
for (FileObjectWithMessages fileObjectWithMessages: all_children){
|
||
fileObjectWithMessages.CheckMessagesPresence();
|
||
}
|
||
|
||
all_children.addAll(children); //у них уже проверено. (?)
|
||
return all_children;
|
||
}
|
||
@Override
|
||
public String TypeKey() {
|
||
return getLoopState().toString();
|
||
}
|
||
@Override
|
||
public String Description() {
|
||
return "цикл";
|
||
}
|
||
@Override
|
||
public boolean HasMessage(Message message) {
|
||
return (message.line >= line) && (message.line < lineNumAfterLoop);
|
||
}
|
||
@Override
|
||
public String toString() {
|
||
return super.toString() + ((perfectLoop > 1) ? (" тесная вложенность " + perfectLoop) : "");
|
||
}
|
||
@Override
|
||
public VisualiserFonts getFont() {
|
||
return getLoopState().getFont();
|
||
}
|
||
public void toMap_r(LinkedHashMap<Integer, Loop> loops_map){
|
||
CheckMessagesPresence();
|
||
loops_map.put(line, this);
|
||
for (Loop loop: children)
|
||
loop.toMap_r(loops_map);
|
||
}
|
||
@Override
|
||
public void setFile(String file_in) {
|
||
super.setFile(file_in);
|
||
for (FuncCall funcCall: funcCalls)
|
||
funcCall.setFile(file_in);
|
||
for (Loop child: children)
|
||
child.setFile(file_in);
|
||
}
|
||
}
|