MCPcopy Create free account
hub / github.com/CheckPointSW/Karta / linkFile

Method linkFile

src/core/function_context.py:158–182  ·  view source on GitHub ↗

Link our context to a code file (FileMatch instance). Note: * 1st invocation: adds the given source file as a potential candidate * 2nd invocation: signals that this given source file is indeed our source file Args: file_match (FileMatch): contex

(self, file_match)

Source from the content-addressed store, hash-verified

156 raise NotImplementedError("Subclasses should implement this!")
157
158 def linkFile(self, file_match):
159 """Link our context to a code file (FileMatch instance).
160
161 Note:
162 * 1st invocation: adds the given source file as a potential candidate
163 * 2nd invocation: signals that this given source file is indeed our source file
164
165 Args:
166 file_match (FileMatch): context representing a source file
167 """
168 # already locked to a file
169 if self.file is not None:
170 return
171 # 1st invocation
172 if file_match not in self.files:
173 self.files.add(file_match)
174 # 2nd invocation
175 else:
176 # double inclusion means total ownership
177 self.file = file_match
178 for iter_file in self.files - set([file_match]):
179 iter_file.remove(self)
180 self.files = set([file_match])
181 # propagate this new information internally
182 self.selfCheck()
183
184 def expel(self, file_match):
185 """Expel us from the given file, it is no longer an option for us.

Callers

nothing calls this directly

Calls 3

selfCheckMethod · 0.95
removeMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected