aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java b/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
index 3e37c009ad..f50e6ee5f1 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
@@ -14,8 +14,10 @@
package com.google.devtools.build.lib.syntax;
import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.events.Location.LineAndColumn;
import com.google.devtools.build.lib.profiler.Profiler;
import com.google.devtools.build.lib.profiler.ProfilerTask;
+import com.google.devtools.build.lib.vfs.PathFragment;
/**
* The actual function registered in the environment. This function is defined in the
@@ -73,12 +75,39 @@ public class UserDefinedFunction extends BaseFunction {
real.registerStatement(lastStatement);
throw real;
} finally {
- Profiler.instance().logSimpleTask(startTimeProfiler, ProfilerTask.SKYLARK_USER_FN, getName());
+ Profiler.instance().logSimpleTask(
+ startTimeProfiler,
+ ProfilerTask.SKYLARK_USER_FN,
+ getLocationPathAndLine() + "#" + getName());
}
return Runtime.NONE;
}
/**
+ * Returns the location (filename:line) of the BaseFunction's definition.
+ *
+ * <p>If such a location is not defined, this method returns an empty string.
+ */
+ private String getLocationPathAndLine() {
+ if (location == null) {
+ return "";
+ }
+
+ StringBuilder builder = new StringBuilder();
+ PathFragment path = location.getPath();
+ if (path != null) {
+ builder.append(path.getPathString());
+ }
+
+ LineAndColumn position = location.getStartLineAndColumn();
+ if (position != null) {
+ builder.append(":").append(position.getLine());
+ }
+ return builder.toString();
+ }
+
+
+ /**
* Creates a new environment for the execution of this function.
*/
@Override