Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
293,100
boolean (PsiElement match, @NotNull MatchContext context) { return handle(match, 0, -1, context); }
handle
293,101
boolean (PsiElement match, int start, int end, @NotNull MatchContext context) { if (!validate(match, start, end, context)) { myNestedResult = null; return false; } if (!Configuration.CONTEXT_VAR_NAME.equals(name)) { addResult(match, start, end, context); } return true; }
handle
293,102
MatchResultImpl (@NotNull PsiElement match, int start, int end) { final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(match); assert profile != null; final String image = profile.getText(match, start, end); if (myNestedResult == null) { return new MatchResultImpl(name, image, match, start, end, target); } final MatchResultImpl result = myNestedResult; result.setName(name); result.setMatchImage(image); result.setMatch(match); result.setStart(start); result.setEnd(end); result.setTarget(target); myNestedResult = null; return result; }
createMatch
293,103
boolean (@NotNull MatchContext context, int matchedOccurs) { if (target) return matchedOccurs > 0; if (minOccurs > matchedOccurs) return false; if (maxOccurs < matchedOccurs) return false; return true; }
validate
293,104
int () { return minOccurs; }
getMinOccurs
293,105
int () { return maxOccurs; }
getMaxOccurs
293,106
void (int numberOfResults, @NotNull MatchContext context) { if (numberOfResults == 0) return; final MatchResultImpl substitution = context.getResult().getChild(name); if (substitution != null) { if (substitution.hasChildren()) { while (numberOfResults > 0) { --numberOfResults; final MatchResult matchResult = substitution.removeLastChild(); context.removeMatchedNode(matchResult.getMatch()); } if (!substitution.hasChildren()) { context.getResult().removeChild(name); } } else { final MatchResult matchResult = context.getResult().removeChild(name); assert matchResult != null; context.removeMatchedNode(matchResult.getMatch()); } } }
removeLastResults
293,107
boolean (@NotNull NodeIterator patternNodes, @NotNull NodeIterator matchNodes, @NotNull MatchContext context) { return doMatchSequentially(patternNodes, matchNodes, context); }
matchSequentially
293,108
boolean (NodeIterator patternNodes, NodeIterator matchNodes, @NotNull MatchContext context) { final boolean oldValue = context.shouldRecursivelyMatch(); context.setShouldRecursivelyMatch(false); final boolean result = super.matchSequentially(patternNodes, matchNodes, context); context.setShouldRecursivelyMatch(oldValue); return result; }
doMatchSequentiallyBySimpleHandler
293,109
boolean (@NotNull NodeIterator patternNodes, @NotNull NodeIterator matchNodes, @NotNull MatchContext context) { final int previousMatchedOccurs = matchedOccurs; final FilteringNodeIterator fNodes = new FilteringNodeIterator(matchNodes, VARS_DELIM_FILTER); try { final CompiledPattern pattern = context.getPattern(); final PsiElement currentPatternNode = patternNodes.current(); final MatchingHandler handler = pattern.getHandler(currentPatternNode); matchedOccurs = 0; boolean flag = false; final List<PsiElement> matchedNodes = new SmartList<>(); while (fNodes.hasNext() && (matchedOccurs < minOccurs || target && !myRepeatedVar && !(handler instanceof TopLevelMatchingHandler))) { final PsiElement current = matchNodes.current(); if (handler.match(currentPatternNode, current, context)) { matchedNodes.add(current); ++matchedOccurs; } else if (handler instanceof TopLevelMatchingHandler && matchedOccurs == 0 || currentPatternNode instanceof PsiComment || !(matchNodes.current() instanceof PsiComment)) { break; } fNodes.advance(); flag = true; } if (matchedOccurs != minOccurs && (!target || myRepeatedVar || matchedOccurs == 0)) { // failed even for min occurs removeLastResults(matchedOccurs, context); fNodes.rewind(matchedOccurs); return false; } if (greedy) { // go greedily to maxOccurs while (fNodes.hasNext() && matchedOccurs < maxOccurs) { final PsiElement current = matchNodes.current(); if (handler.match(currentPatternNode, current, context)) { matchedNodes.add(current); ++matchedOccurs; } else if (handler instanceof TopLevelMatchingHandler && matchedOccurs == 0 || currentPatternNode instanceof PsiComment || !(matchNodes.current() instanceof PsiComment)) { break; } fNodes.advance(); flag = true; } if (flag) { fNodes.rewind(); matchNodes.advance(); } patternNodes.advance(); if (patternNodes.hasNext()) { final MatchingHandler nextHandler = pattern.getHandler(patternNodes.current()); while (matchedOccurs >= minOccurs && patternNodes.hasNext()) { if (nextHandler.matchSequentially(patternNodes, matchNodes, context)) { totalMatchedOccurs = matchedOccurs; // match found return true; } final int size = matchedNodes.size(); if (size > 0) { matchNodes.rewindTo(matchedNodes.remove(size - 1)); } removeLastResults(1, context); --matchedOccurs; } if (matchedOccurs > 0) { removeLastResults(matchedOccurs, context); } patternNodes.rewind(); } else { // match found if (handler.isMatchSequentiallySucceeded(matchNodes)) { return checkSameOccurrencesConstraint(context); } removeLastResults(matchedOccurs, context); } return false; } else { patternNodes.advance(); if (flag) { fNodes.rewind(); matchNodes.advance(); } if (patternNodes.hasNext()) { final MatchingHandler nextHandler = pattern.getHandler(patternNodes.current()); flag = false; while (matchNodes.hasNext() && matchedOccurs <= maxOccurs) { if (nextHandler.matchSequentially(patternNodes, matchNodes, context)) { return checkSameOccurrencesConstraint(context); } if (flag) { matchNodes.rewind(); fNodes.advance(); } if (handler.match(patternNodes.current(), matchNodes.current(), context)) { matchedOccurs++; } else { patternNodes.rewind(); removeLastResults(matchedOccurs, context); return false; } matchNodes.advance(); flag = true; } patternNodes.rewind(); removeLastResults(matchedOccurs, context); return false; } else { return checkSameOccurrencesConstraint(context); } } } finally { matchedOccurs = previousMatchedOccurs; } }
doMatchSequentially
293,110
boolean (@NotNull MatchContext context) { if (totalMatchedOccurs == -1) { totalMatchedOccurs = matchedOccurs; return true; } MatchResult result = context.hasResult() ? context.getResult().getChild(name) : null; if (result == null && context.getPreviousResult() != null) { result = context.getPreviousResult().getChild(name); } return result == null || result.size() == matchedOccurs || target; }
checkSameOccurrencesConstraint
293,111
void (boolean target) { this.target = target; }
setTarget
293,112
void (@NotNull MatchingHandler matchHandler) { this.matchHandler = matchHandler; }
setMatchHandler
293,113
boolean () { return target; }
isTarget
293,114
String () { return name; }
getName
293,115
void () { super.reset(); totalMatchedOccurs = -1; }
reset
293,116
boolean (@NotNull PsiElement patternElement, @NotNull PsiElement matchedElement) { return maxOccurs <= 1 && !target; }
shouldAdvanceThePatternFor
293,117
void (MatchResultImpl nestedResult) { myNestedResult = nestedResult; }
setNestedResult
293,118
MatchResultImpl () { return myNestedResult; }
getNestedResult
293,119
boolean (PsiElement patternNode, PsiElement matchedNode, final @NotNull MatchContext matchContext) { if (patternNode == null || matchedNode == null || matchedNode.getClass() == patternNode.getClass()) { return myDelegate.match(patternNode, matchedNode, matchContext); } /*if (patternNode != null && matchedNode != null && patternNode.getClass() == matchedNode.getClass()) { //return myDelegate.match(patternNode, matchedNode, matchContext); }*/ final PsiElement newPatternNode = skipNodeIfNecessary(patternNode); matchedNode = skipNodeIfNecessary(matchedNode); if (newPatternNode != patternNode) { return matchContext.getPattern().getHandler(newPatternNode).match(newPatternNode, matchedNode, matchContext); } return myDelegate.match(patternNode, matchedNode, matchContext); }
match
293,120
boolean (@NotNull PsiElement patternNode, PsiElement matchedNode, @NotNull MatchContext context) { final PsiElement newPatternNode = skipNodeIfNecessary(patternNode); if (newPatternNode != patternNode) { return context.getPattern().getHandler(newPatternNode).canMatch(newPatternNode, matchedNode, context); } return myDelegate.canMatch(patternNode, matchedNode, context); }
canMatch
293,121
boolean (final @NotNull NodeIterator patternNodes, final @NotNull NodeIterator matchNodes, final @NotNull MatchContext context) { return myDelegate.matchSequentially(patternNodes, matchNodes, context); }
matchSequentially
293,122
boolean (final @NotNull NodeIterator matchNodes) { return myDelegate.isMatchSequentiallySucceeded(matchNodes); }
isMatchSequentiallySucceeded
293,123
MatchingHandler () { return myDelegate; }
getDelegate
293,124
PsiElement (PsiElement element) { PsiElement onlyChild = null; for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { if (DuplocatorUtil.isIgnoredNode(element) || child.getTextLength() == 0) { continue; } if (onlyChild != null) { return null; } onlyChild = child; } return onlyChild; }
getOnlyNonWhitespaceChild
293,125
PsiElement (PsiElement element) { return skipNodeIfNecessary(element, null, null); }
skipNodeIfNecessary
293,126
PsiElement (PsiElement element, EquivalenceDescriptor descriptor, NodeFilter filter) { return DuplocatorUtil.skipNodeIfNecessary(element, descriptor, filter != null ? filter : LexicalNodesFilter.getInstance()); }
skipNodeIfNecessary
293,127
boolean (PsiElement patternNode, PsiElement matchedNode, @NotNull MatchContext context) { return match(matchedNode, matchedNode.getText(), 0, context); }
match
293,128
boolean (@NotNull PsiElement matchedNode, @NotNull String text, int textOffset, @NotNull MatchContext context) { if (myMatcher == null) { myMatcher = Pattern.compile(myRegexp, (myCaseSensitive ? 0 : Pattern.CASE_INSENSITIVE) | Pattern.DOTALL).matcher(text); } else { myMatcher.reset(text); } if (!myMatcher.matches()) { return false; } for (int i = 0; i < myHandlers.size(); ++i) { final SubstitutionHandler handler = myHandlers.get(i); if (!handler.handle(matchedNode, textOffset + myMatcher.start(i + 1), textOffset + myMatcher.end(i + 1), context)) { return false; } } return true; }
match
293,129
boolean (PsiElement patternNode, PsiElement matchedNode, @NotNull MatchContext context) { return handler.handle(matchedNode, context); }
match
293,130
boolean (PsiElement patternNode, PsiElement matchedNode, @NotNull MatchContext context) { if (!super.match(patternNode, matchedNode, context)) return false; return context.getMatcher().match(patternNode, matchedNode); }
match
293,131
boolean (@NotNull PsiElement matchedNode, @NotNull MatchContext context) { return match(matchedNode, 0, -1, context); }
match
293,132
boolean (@NotNull PsiElement matchedNode, int start, int end, @NotNull MatchContext context) { final List<MatchResult> results = matcher.matchByDownUp(matchedNode); for (MatchResult result : results) { if (PsiTreeUtil.isAncestor(result.getMatch(), matchedNode, false)) { return true; } } return false; }
match
293,133
Object (MatchResult result, PsiElement context) { try { Map<String, Object> variableMap = new HashMap<>(); myVariableNames.forEach(n -> variableMap.put(n, null)); variableMap.put(ScriptLog.SCRIPT_LOG_VAR_NAME, myScriptLog); if (result != null) { buildVariableMap(result.getRoot(), variableMap); if (context == null) { context = result.getMatch(); } } context = StructuralSearchUtil.getPresentableElement(context); variableMap.put(myName, context); variableMap.put(Configuration.CONTEXT_VAR_NAME, context); myScript.setBinding(new Binding(variableMap)); return myScript.run(); } catch (ThreadDeath | ProcessCanceledException t) { throw t; } catch (Throwable t) { Logger.getInstance(ScriptSupport.class).info("Exception thrown by Structural Search Groovy Script", t); throw new StructuralSearchScriptException(t); } finally { myScript.setBinding(null); } }
evaluate
293,134
boolean (@NotNull PsiElement matchedNode, int start, int end, @NotNull MatchContext context) { return first.match(matchedNode, start, end, context) && second.match(matchedNode, start, end, context); }
match
293,135
MatchPredicate () { return first; }
getFirst
293,136
MatchPredicate () { return second; }
getSecond
293,137
boolean (@NotNull PsiElement matchedNode, int start, int end, @NotNull MatchContext context) { return !myPredicate.match(matchedNode, start, end, context); }
match
293,138
MatchPredicate () { return myPredicate; }
getPredicate
293,139
boolean (@NotNull PsiElement match, int start, int end, @NotNull MatchContext context) { return Boolean.TRUE.equals(scriptSupport.evaluate(context.hasResult() ? context.getResult() : null, match)); }
match
293,140
boolean (@NotNull PsiElement matchedNode, int start, int end, @NotNull MatchContext context) { matchedNode = StructuralSearchUtil.getParentIfIdentifier(matchedNode); final List<PsiReference> references = PsiReferenceService.getService().getReferences(matchedNode, PsiReferenceService.Hints.NO_HINTS); return references.stream().map(PsiReference::resolve).filter(Objects::nonNull).anyMatch(t -> { StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(t); return profile != null && matcher.matchNode(profile.extendMatchedByDownUp(t)); }); }
match
293,141
boolean (@NotNull PsiElement match, int start, int end, @NotNull MatchContext context) { return false; }
match
293,142
void () { try { @NonNls String realRegexp = regexp; if (wholeWords) { realRegexp = ".*?\\b(?:" + realRegexp + ")\\b.*?"; } pattern = Pattern.compile(realRegexp, (caseSensitive ? 0 : Pattern.CASE_INSENSITIVE) | (multiline ? Pattern.DOTALL : 0)); } catch (PatternSyntaxException ex) { throw new MalformedPatternException(SSRBundle.message("error.incorrect.regexp.constraint", regexp, baseHandlerName)); } }
compilePattern
293,143
boolean () { return couldBeOptimized; }
couldBeOptimized
293,144
String () { return regexp; }
getRegExp
293,145
boolean (@NotNull PsiElement matchedNode, int start, int end, @NotNull MatchContext context) { final String text = myNodeTextGenerator != null ? myNodeTextGenerator.getText(matchedNode) : StructuralSearchUtil.getMeaningfulText(matchedNode); boolean result = doMatch(text, start, end, context, matchedNode); if (!result) { matchedNode = StructuralSearchUtil.getParentIfIdentifier(matchedNode); final String alternativeText = StructuralSearchUtil.getAlternativeText(matchedNode, text); if (alternativeText != null) { result = doMatch(alternativeText, start, end, context, matchedNode); } } return result; }
match
293,146
boolean (@NotNull String text, @NotNull MatchContext context, @NotNull PsiElement matchedElement) { return doMatch(text, 0, -1 ,context, matchedElement); }
doMatch
293,147
boolean (@NotNull String text, int from, int end, @NotNull MatchContext context, @NotNull PsiElement matchedElement) { if (from > 0 || end != -1) text = text.substring(from, (end == -1 || end >= text.length()) ? text.length() : end); if (simpleString) return matchesSimpleString(text); setMultilineIfApplicable(text); final Matcher matcher = pattern.matcher(text); if (!matcher.matches()) return false; for (int i = 1; i <= matcher.groupCount(); i++) { context.getResult().addChild( new MatchResultImpl( baseHandlerName + "_" + i, matcher.group(i), matchedElement, matcher.start(i), matcher.end(i), target ) ); } return true; }
doMatch
293,148
boolean (@NotNull String text) { if (simpleString) return matchesSimpleString(text); setMultilineIfApplicable(text); return pattern.matcher(text).matches(); }
match
293,149
boolean (@NotNull String text) { return caseSensitive ? text.equals(regexp) : text.equalsIgnoreCase(regexp); }
matchesSimpleString
293,150
void (@NotNull String text) { if(!multiline && text.contains("\n")) setMultiline(true); }
setMultilineIfApplicable
293,151
void (NodeTextGenerator nodeTextGenerator) { myNodeTextGenerator = nodeTextGenerator; }
setNodeTextGenerator
293,152
void (boolean b) { multiline = b; compilePattern(); }
setMultiline
293,153
boolean () { return wholeWords; }
isWholeWords
293,154
void (Object message) { log(message, NotificationType.INFORMATION); }
info
293,155
void (Object message) { log(message, NotificationType.WARNING); }
warn
293,156
void (Object message) { log(message, NotificationType.ERROR); }
error
293,157
void (Object message, NotificationType type) { final StackTraceElement[] stackTrace = new Throwable().getStackTrace(); String location = ""; for (StackTraceElement e : stackTrace) { final String methodName = e.getMethodName(); if ("run".equals(methodName)) { final String fileName = e.getFileName(); assert fileName != null; location = "(" + StringUtil.replace(fileName, UUID + ".groovy", "") + ":" + e.getLineNumber() + ") "; break; } } final NotificationGroup notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup(UIUtil.SSR_NOTIFICATION_GROUP_ID); notificationGroup.createNotification(location + message, type).notify(myProject); }
log
293,158
int () { return port_; }
getPort
293,159
long () { return pid_; }
getPid
293,160
boolean () { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; }
isInitialized
293,161
int () { int size = memoizedSize; if (size != -1) return size; size = 0; if (port_ != 0) { size += com.google.protobuf.CodedOutputStream .computeUInt32Size(1, port_); } if (!token_.isEmpty()) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(2, token_); } if (pid_ != 0L) { size += com.google.protobuf.CodedOutputStream .computeUInt64Size(3, pid_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
getSerializedSize
293,162
boolean (final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.intellij.execution.process.mediator.rpc.Handshake)) { return super.equals(obj); } com.intellij.execution.process.mediator.rpc.Handshake other = (com.intellij.execution.process.mediator.rpc.Handshake) obj; if (getPort() != other.getPort()) return false; if (!getToken() .equals(other.getToken())) return false; if (getPid() != other.getPid()) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; }
equals
293,163
int () { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + PORT_FIELD_NUMBER; hash = (53 * hash) + getPort(); hash = (37 * hash) + TOKEN_FIELD_NUMBER; hash = (53 * hash) + getToken().hashCode(); hash = (37 * hash) + PID_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong( getPid()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
hashCode
293,164
Builder () { return newBuilder(); }
newBuilderForType
293,165
Builder () { return DEFAULT_INSTANCE.toBuilder(); }
newBuilder
293,166
Builder (com.intellij.execution.process.mediator.rpc.Handshake prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); }
newBuilder
293,167
Builder () { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); }
toBuilder
293,168
Builder ( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; }
newBuilderForType
293,169
void () { if (com.google.protobuf.GeneratedMessageV3 .alwaysUseFieldBuilders) { } }
maybeForceBuilderInitialization
293,170
Builder () { super.clear(); port_ = 0; token_ = com.google.protobuf.ByteString.EMPTY; pid_ = 0L; return this; }
clear
293,171
Builder () { return super.clone(); }
clone
293,172
Builder ( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.setField(field, value); }
setField
293,173
Builder ( com.google.protobuf.Descriptors.FieldDescriptor field) { return super.clearField(field); }
clearField
293,174
Builder ( com.google.protobuf.Descriptors.OneofDescriptor oneof) { return super.clearOneof(oneof); }
clearOneof
293,175
Builder ( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { return super.setRepeatedField(field, index, value); }
setRepeatedField
293,176
Builder ( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.addRepeatedField(field, value); }
addRepeatedField
293,177
Builder (com.google.protobuf.Message other) { if (other instanceof com.intellij.execution.process.mediator.rpc.Handshake) { return mergeFrom((com.intellij.execution.process.mediator.rpc.Handshake)other); } else { super.mergeFrom(other); return this; } }
mergeFrom
293,178
Builder (com.intellij.execution.process.mediator.rpc.Handshake other) { if (other == com.intellij.execution.process.mediator.rpc.Handshake.getDefaultInstance()) return this; if (other.getPort() != 0) { setPort(other.getPort()); } if (other.getToken() != com.google.protobuf.ByteString.EMPTY) { setToken(other.getToken()); } if (other.getPid() != 0L) { setPid(other.getPid()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
mergeFrom
293,179
boolean () { return true; }
isInitialized
293,180
int () { return port_; }
getPort
293,181
Builder (int value) { port_ = value; onChanged(); return this; }
setPort
293,182
Builder () { port_ = 0; onChanged(); return this; }
clearPort
293,183
Builder (com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } token_ = value; onChanged(); return this; }
setToken
293,184
Builder () { token_ = getDefaultInstance().getToken(); onChanged(); return this; }
clearToken
293,185
long () { return pid_; }
getPid
293,186
Builder (long value) { pid_ = value; onChanged(); return this; }
setPid
293,187
Builder () { pid_ = 0L; onChanged(); return this; }
clearPid
293,188
Builder ( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); }
setUnknownFields
293,189
Builder ( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); }
mergeUnknownFields
293,190
StateOneofCase (int value) { return forNumber(value); }
valueOf
293,191
StateOneofCase (int value) { switch (value) { case 2: return STATE_NEW; case 3: return STATE_ACTIVE; case 4: return STATE_EXPIRED; case 0: return STATEONEOF_NOT_SET; default: return null; } }
forNumber
293,192
int () { return this.value; }
getNumber
293,193
StateOneofCase () { return StateOneofCase.forNumber( stateOneofCase_); }
getStateOneofCase
293,194
boolean () { return quotaOptions_ != null; }
hasQuotaOptions
293,195
boolean () { return stateOneofCase_ == 2; }
hasStateNew
293,196
boolean () { return stateOneofCase_ == 3; }
hasStateActive
293,197
boolean () { return stateOneofCase_ == 4; }
hasStateExpired
293,198
boolean () { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; }
isInitialized
293,199
int () { int size = memoizedSize; if (size != -1) return size; size = 0; if (quotaOptions_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, getQuotaOptions()); } if (stateOneofCase_ == 2) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, (com.google.protobuf.Empty) stateOneof_); } if (stateOneofCase_ == 3) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, (com.intellij.execution.process.mediator.rpc.QuotaStateActive) stateOneof_); } if (stateOneofCase_ == 4) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(4, (com.google.protobuf.Empty) stateOneof_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
getSerializedSize