MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / doInclude

Method doInclude

ij/src/main/java/ij/plugin/frame/Editor.java:596–622  ·  view source on GitHub ↗

Process optional #include statment at begining of macro.

(String code)

Source from the content-addressed store, hash-verified

594
595 /** Process optional #include statment at begining of macro. */
596 public static String doInclude(String code) {
597 if (code.startsWith("#include ")||code.startsWith("// include ")) {
598 if (IJ.isWindows())
599 code = code.replaceAll("\r\n", "\n");
600 int offset = code.startsWith("#include ")?9:11;
601 int eol = code.indexOf("\n");
602 String path = code.substring(offset, eol);
603 boolean isURL = path.startsWith("http://") || path.startsWith("https://");
604 if (!isURL) {
605 boolean fullPath = path.startsWith("/") || path.startsWith("\\") || path.indexOf(":\\")==1 || path.indexOf(":/")==1;
606 if (!fullPath) {
607 String macrosDir = Menus.getMacrosPath();
608 if (macrosDir!=null)
609 path = Menus.getMacrosPath() + path;
610 }
611 File f = new File(path);
612 if (!f.exists())
613 IJ.error("Include file not found:\n"+path);
614 }
615 code = code.substring(eol+1,code.length());
616 if (isURL)
617 code = "//\n"+code + IJ.openUrlAsString(path);
618 else
619 code = "//\n"+code + IJ.openAsString(path);
620 }
621 return code;
622 }
623
624 void evaluateMacro() {
625 String title = getTitle();

Callers 2

runMacroFileMethod · 0.95
runMacroMethod · 0.95

Calls 11

isWindowsMethod · 0.95
getMacrosPathMethod · 0.95
errorMethod · 0.95
openUrlAsStringMethod · 0.95
openAsStringMethod · 0.95
startsWithMethod · 0.80
replaceAllMethod · 0.80
substringMethod · 0.80
lengthMethod · 0.65
indexOfMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected