_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q5500 | XtextLinker.clearReference | train | @Override
protected void clearReference(EObject obj, EReference ref) {
super.clearReference(obj, ref);
if (obj.eIsSet(ref) && ref.getEType().equals(XtextPackage.Literals.TYPE_REF)) {
INode node = NodeModelUtils.getNode((EObject) obj.eGet(ref));
if (node == null)
obj.eUnset(ref);
}
if (obj.eIsSet(ref) && ref == XtextPackage.Literals.CROSS_REFERENCE__TERMINAL) {
INode node = NodeModelUtils.getNode((EObject) obj.eGet(ref));
if (node == null)
obj.eUnset(ref);
}
if (ref == XtextPackage.Literals.RULE_CALL__RULE) {
obj.eUnset(XtextPackage.Literals.RULE_CALL__EXPLICITLY_CALLED);
}
} | java | {
"resource": ""
} |
q5501 | OutdatedStateManager.newCancelIndicator | train | public CancelIndicator newCancelIndicator(final ResourceSet rs) {
CancelIndicator _xifexpression = null;
if ((rs instanceof XtextResourceSet)) {
final boolean cancelationAllowed = (this.cancelationAllowed.get()).booleanValue();
final int current = ((XtextResourceSet)rs).getModificationStamp();
final CancelIndicator _function = () -> {
return (cancelationAllowed && (((XtextResourceSet)rs).isOutdated() || (current != ((XtextResourceSet)rs).getModificationStamp())));
};
return _function;
} else {
_xifexpression = CancelIndicator.NullImpl;
}
return _xifexpression;
} | java | {
"resource": ""
} |
q5502 | IdeContentProposalCreator.createProposal | train | public ContentAssistEntry createProposal(final String proposal, final ContentAssistContext context) {
return this.createProposal(proposal, context.getPrefix(), context, ContentAssistEntry.KIND_UNKNOWN, null);
} | java | {
"resource": ""
} |
q5503 | IdeContentProposalCreator.createSnippet | train | public ContentAssistEntry createSnippet(final String proposal, final String label, final ContentAssistContext context) {
final Procedure1<ContentAssistEntry> _function = (ContentAssistEntry it) -> {
it.setLabel(label);
};
return this.createProposal(proposal, context.getPrefix(), context, ContentAssistEntry.KIND_SNIPPET, _function);
} | java | {
"resource": ""
} |
q5504 | IdeContentProposalCreator.createProposal | train | public ContentAssistEntry createProposal(final String proposal, final ContentAssistContext context, final Procedure1<? super ContentAssistEntry> init) {
return this.createProposal(proposal, context.getPrefix(), context, ContentAssistEntry.KIND_UNKNOWN, init);
} | java | {
"resource": ""
} |
q5505 | IdeContentProposalCreator.createProposal | train | public ContentAssistEntry createProposal(final String proposal, final String prefix, final ContentAssistContext context, final String kind, final Procedure1<? super ContentAssistEntry> init) {
boolean _isValidProposal = this.isValidProposal(proposal, prefix, context);
if (_isValidProposal) {
final ContentAssistEntry result = new ContentAssistEntry();
result.setProposal(proposal);
result.setPrefix(prefix);
if ((kind != null)) {
result.setKind(kind);
}
if ((init != null)) {
init.apply(result);
}
return result;
}
return null;
} | java | {
"resource": ""
} |
q5506 | UriExtensions.toDecodedString | train | public String toDecodedString(final java.net.URI uri) {
final String scheme = uri.getScheme();
final String part = uri.getSchemeSpecificPart();
if ((scheme == null)) {
return part;
}
return ((scheme + ":") + part);
} | java | {
"resource": ""
} |
q5507 | UriExtensions.withEmptyAuthority | train | public URI withEmptyAuthority(final URI uri) {
URI _xifexpression = null;
if ((uri.isFile() && (uri.authority() == null))) {
_xifexpression = URI.createHierarchicalURI(uri.scheme(), "", uri.device(), uri.segments(), uri.query(), uri.fragment());
} else {
_xifexpression = uri;
}
return _xifexpression;
} | java | {
"resource": ""
} |
q5508 | RequiredRuleNameComputer.getRequiredRuleNames | train | public String[][] getRequiredRuleNames(Param param) {
if (isFiltered(param)) {
return EMPTY_ARRAY;
}
AbstractElement elementToParse = param.elementToParse;
String ruleName = param.ruleName;
if (ruleName == null) {
return getRequiredRuleNames(param, elementToParse);
}
return getAdjustedRequiredRuleNames(param, elementToParse, ruleName);
} | java | {
"resource": ""
} |
q5509 | RequiredRuleNameComputer.isFiltered | train | protected boolean isFiltered(Param param) {
AbstractElement elementToParse = param.elementToParse;
while (elementToParse != null) {
if (isFiltered(elementToParse, param)) {
return true;
}
elementToParse = getEnclosingSingleElementGroup(elementToParse);
}
return false;
} | java | {
"resource": ""
} |
q5510 | RequiredRuleNameComputer.getEnclosingSingleElementGroup | train | protected AbstractElement getEnclosingSingleElementGroup(AbstractElement elementToParse) {
EObject container = elementToParse.eContainer();
if (container instanceof Group) {
if (((Group) container).getElements().size() == 1) {
return (AbstractElement) container;
}
}
return null;
} | java | {
"resource": ""
} |
q5511 | RequiredRuleNameComputer.isFiltered | train | protected boolean isFiltered(AbstractElement canddiate, Param param) {
if (canddiate instanceof Group) {
Group group = (Group) canddiate;
if (group.getGuardCondition() != null) {
Set<Parameter> context = param.getAssignedParametes();
ConditionEvaluator evaluator = new ConditionEvaluator(context);
if (!evaluator.evaluate(group.getGuardCondition())) {
return true;
}
}
}
return false;
} | java | {
"resource": ""
} |
q5512 | CodeGenUtil2.isJavaLangType | train | public static boolean isJavaLangType(String s) {
return getJavaDefaultTypes().contains(s) && Character.isUpperCase(s.charAt(0));
} | java | {
"resource": ""
} |
q5513 | ContentAssistContext.copy | train | public ContentAssistContext.Builder copy() {
Builder result = builderProvider.get();
result.copyFrom(this);
return result;
} | java | {
"resource": ""
} |
q5514 | ContentAssistContext.getFirstSetGrammarElements | train | public ImmutableList<AbstractElement> getFirstSetGrammarElements() {
if (firstSetGrammarElements == null) {
firstSetGrammarElements = ImmutableList.copyOf(mutableFirstSetGrammarElements);
}
return firstSetGrammarElements;
} | java | {
"resource": ""
} |
q5515 | ContentAssistContext.getReplaceContextLength | train | public int getReplaceContextLength() {
if (replaceContextLength == null) {
int replacementOffset = getReplaceRegion().getOffset();
ITextRegion currentRegion = getCurrentNode().getTextRegion();
int replaceContextLength = currentRegion.getLength() - (replacementOffset - currentRegion.getOffset());
this.replaceContextLength = replaceContextLength;
return replaceContextLength;
}
return replaceContextLength.intValue();
} | java | {
"resource": ""
} |
q5516 | NodeModelStreamer.getFormattedDatatypeValue | train | protected String getFormattedDatatypeValue(ICompositeNode node, AbstractRule rule, String text) throws ValueConverterException {
Object value = valueConverter.toValue(text, rule.getName(), node);
text = valueConverter.toString(value, rule.getName());
return text;
} | java | {
"resource": ""
} |
q5517 | LexerSpecialStateTransitionSplitter.splitSpecialStateSwitch | train | public String splitSpecialStateSwitch(String specialStateTransition){
Matcher transformedSpecialStateMatcher =
TRANSORMED_SPECIAL_STATE_TRANSITION_METHOD.matcher(specialStateTransition);
if( !transformedSpecialStateMatcher.find() ){
return specialStateTransition;
}
String specialStateSwitch = transformedSpecialStateMatcher.group(3);
Matcher transformedCaseMatcher = TRANSFORMED_CASE_PATTERN.matcher(specialStateSwitch);
StringBuffer switchReplacementBuffer = new StringBuffer();
StringBuffer extractedMethods = new StringBuffer();
List<String> extractedCasesList = new ArrayList<String>();
switchReplacementBuffer.append("$2\n");
boolean methodExtracted = false;
boolean isFirst = true;
String from = "0";
String to = "0";
//Process individual case statements
while(transformedCaseMatcher.find()){
if(isFirst){
isFirst = false;
from = transformedCaseMatcher.group(2);
}
to = transformedCaseMatcher.group(2);
extractedCasesList.add(transformedCaseMatcher.group());
//If the list of not processed extracted cases exceeds the maximal allowed number
//generate individual method for those cases
if (extractedCasesList.size() >= casesPerSpecialStateSwitch ){
generateExtractedSwitch(extractedCasesList, from, to, extractedMethods, switchReplacementBuffer);
extractedCasesList.clear();
isFirst = true;
methodExtracted = true;
}
}
//If no method was extracted return the input unchanged
//or process rest of cases by generating method for them
if(!methodExtracted){
return specialStateTransition;
}else if(!extractedCasesList.isEmpty() && methodExtracted){
generateExtractedSwitch(extractedCasesList, from, to, extractedMethods, switchReplacementBuffer);
}
switchReplacementBuffer.append("$5");
StringBuffer result = new StringBuffer();
transformedSpecialStateMatcher.appendReplacement( result, switchReplacementBuffer.toString());
result.append(extractedMethods);
transformedSpecialStateMatcher.appendTail(result);
return result.toString();
} | java | {
"resource": ""
} |
q5518 | PluginXmlAccess.merge | train | public boolean merge(final PluginXmlAccess other) {
boolean _xblockexpression = false;
{
String _path = this.getPath();
String _path_1 = other.getPath();
boolean _notEquals = (!Objects.equal(_path, _path_1));
if (_notEquals) {
String _path_2 = this.getPath();
String _plus = ("Merging plugin.xml files with different paths: " + _path_2);
String _plus_1 = (_plus + ", ");
String _path_3 = other.getPath();
String _plus_2 = (_plus_1 + _path_3);
PluginXmlAccess.LOG.warn(_plus_2);
}
_xblockexpression = this.entries.addAll(other.entries);
}
return _xblockexpression;
} | java | {
"resource": ""
} |
q5519 | DefaultDocumentHighlightService.getTargetURIs | train | protected Iterable<URI> getTargetURIs(final EObject primaryTarget) {
final TargetURIs result = targetURIsProvider.get();
uriCollector.add(primaryTarget, result);
return result;
} | java | {
"resource": ""
} |
q5520 | NameBasedFilter.setRegularExpression | train | public void setRegularExpression(String regularExpression) {
if (regularExpression != null)
this.regularExpression = Pattern.compile(regularExpression);
else
this.regularExpression = null;
} | java | {
"resource": ""
} |
q5521 | AbstractGenericResourceSupport.registerServices | train | public void registerServices(boolean force) {
Injector injector = Guice.createInjector(getGuiceModule());
injector.injectMembers(this);
registerInRegistry(force);
} | java | {
"resource": ""
} |
q5522 | ResourceDescriptionsData.register | train | public void register(Delta delta) {
final IResourceDescription newDesc = delta.getNew();
if (newDesc == null) {
removeDescription(delta.getUri());
} else {
addDescription(delta.getUri(), newDesc);
}
} | java | {
"resource": ""
} |
q5523 | AbstractTraceForURIProvider.getGeneratedLocation | train | protected AbsoluteURI getGeneratedLocation(PersistedTrace trace) {
AbsoluteURI path = trace.getPath();
String fileName = traceFileNameProvider.getJavaFromTrace(path.getURI().toString());
return new AbsoluteURI(fileName);
} | java | {
"resource": ""
} |
q5524 | Scopes.scopeFor | train | public static <T extends EObject> IScope scopeFor(Iterable<? extends T> elements,
final Function<T, QualifiedName> nameComputation, IScope outer) {
return new SimpleScope(outer,scopedElementsFor(elements, nameComputation));
} | java | {
"resource": ""
} |
q5525 | PolymorphicDispatcher.compare | train | protected int compare(MethodDesc o1, MethodDesc o2) {
final Class<?>[] paramTypes1 = o1.getParameterTypes();
final Class<?>[] paramTypes2 = o2.getParameterTypes();
// sort by parameter types from left to right
for (int i = 0; i < paramTypes1.length; i++) {
final Class<?> class1 = paramTypes1[i];
final Class<?> class2 = paramTypes2[i];
if (class1.equals(class2))
continue;
if (class1.isAssignableFrom(class2) || Void.class.equals(class2))
return -1;
if (class2.isAssignableFrom(class1) || Void.class.equals(class1))
return 1;
}
// sort by declaring class (more specific comes first).
if (!o1.getDeclaringClass().equals(o2.getDeclaringClass())) {
if (o1.getDeclaringClass().isAssignableFrom(o2.getDeclaringClass()))
return 1;
if (o2.getDeclaringClass().isAssignableFrom(o1.getDeclaringClass()))
return -1;
}
// sort by target
final int compareTo = ((Integer) targets.indexOf(o2.target)).compareTo(targets.indexOf(o1.target));
return compareTo;
} | java | {
"resource": ""
} |
q5526 | ResourceStorageWritable.writeEntries | train | protected void writeEntries(final StorageAwareResource resource, final ZipOutputStream zipOut) throws IOException {
final BufferedOutputStream bufferedOutput = new BufferedOutputStream(zipOut);
ZipEntry _zipEntry = new ZipEntry("emf-contents");
zipOut.putNextEntry(_zipEntry);
try {
this.writeContents(resource, bufferedOutput);
} finally {
bufferedOutput.flush();
zipOut.closeEntry();
}
ZipEntry _zipEntry_1 = new ZipEntry("resource-description");
zipOut.putNextEntry(_zipEntry_1);
try {
this.writeResourceDescription(resource, bufferedOutput);
} finally {
bufferedOutput.flush();
zipOut.closeEntry();
}
if (this.storeNodeModel) {
ZipEntry _zipEntry_2 = new ZipEntry("node-model");
zipOut.putNextEntry(_zipEntry_2);
try {
this.writeNodeModel(resource, bufferedOutput);
} finally {
bufferedOutput.flush();
zipOut.closeEntry();
}
}
} | java | {
"resource": ""
} |
q5527 | IndentationAwareCompletionPrefixProvider.getInputToParse | train | @Override
public String getInputToParse(String completeInput, int offset, int completionOffset) {
int fixedOffset = getOffsetIncludingWhitespace(completeInput, offset, Math.min(completeInput.length(), completionOffset));
return super.getInputToParse(completeInput, fixedOffset, completionOffset);
} | java | {
"resource": ""
} |
q5528 | GrammarResource.doLinking | train | @Override
protected void doLinking() {
IParseResult parseResult = getParseResult();
if (parseResult == null || parseResult.getRootASTElement() == null)
return;
XtextLinker castedLinker = (XtextLinker) getLinker();
castedLinker.discardGeneratedPackages(parseResult.getRootASTElement());
} | java | {
"resource": ""
} |
q5529 | SourceLevelURIsAdapter.setSourceLevelUrisWithoutCopy | train | public static void setSourceLevelUrisWithoutCopy(final ResourceSet resourceSet, final Set<URI> uris) {
final SourceLevelURIsAdapter adapter = SourceLevelURIsAdapter.findOrCreateAdapter(resourceSet);
adapter.sourceLevelURIs = uris;
} | java | {
"resource": ""
} |
q5530 | XtextGeneratorLanguage.setFileExtensions | train | public void setFileExtensions(final String fileExtensions) {
this.fileExtensions = IterableExtensions.<String>toList(((Iterable<String>)Conversions.doWrapArray(fileExtensions.trim().split("\\s*,\\s*"))));
} | java | {
"resource": ""
} |
q5531 | NodeModelUtils.compactDump | train | public static String compactDump(INode node, boolean showHidden) {
StringBuilder result = new StringBuilder();
try {
compactDump(node, showHidden, "", result);
} catch (IOException e) {
return e.getMessage();
}
return result.toString();
} | java | {
"resource": ""
} |
q5532 | NodeModelUtils.getTokenText | train | public static String getTokenText(INode node) {
if (node instanceof ILeafNode)
return ((ILeafNode) node).getText();
else {
StringBuilder builder = new StringBuilder(Math.max(node.getTotalLength(), 1));
boolean hiddenSeen = false;
for (ILeafNode leaf : node.getLeafNodes()) {
if (!leaf.isHidden()) {
if (hiddenSeen && builder.length() > 0)
builder.append(' ');
builder.append(leaf.getText());
hiddenSeen = false;
} else {
hiddenSeen = true;
}
}
return builder.toString();
}
} | java | {
"resource": ""
} |
q5533 | SemanticHighlightingRegistry.getAllScopes | train | public List<List<String>> getAllScopes() {
this.checkInitialized();
final ImmutableList.Builder<List<String>> builder = ImmutableList.<List<String>>builder();
final Consumer<Integer> _function = (Integer it) -> {
List<String> _get = this.scopes.get(it);
StringConcatenation _builder = new StringConcatenation();
_builder.append("No scopes are available for index: ");
_builder.append(it);
builder.add(Preconditions.<List<String>>checkNotNull(_get, _builder));
};
this.scopes.keySet().forEach(_function);
return builder.build();
} | java | {
"resource": ""
} |
q5534 | MergeableManifest2.addRequiredBundles | train | public void addRequiredBundles(Set<String> requiredBundles) {
addRequiredBundles(requiredBundles.toArray(new String[requiredBundles.size()]));
} | java | {
"resource": ""
} |
q5535 | MergeableManifest2.addRequiredBundles | train | public void addRequiredBundles(String... requiredBundles) {
String oldBundles = mainAttributes.get(REQUIRE_BUNDLE);
if (oldBundles == null)
oldBundles = "";
BundleList oldResultList = BundleList.fromInput(oldBundles, newline);
BundleList resultList = BundleList.fromInput(oldBundles, newline);
for (String bundle : requiredBundles) {
Bundle newBundle = Bundle.fromInput(bundle);
if (name != null && name.equals(newBundle.getName()))
continue;
resultList.mergeInto(newBundle);
}
String result = resultList.toString();
boolean changed = !oldResultList.toString().equals(result);
modified |= changed;
if (changed)
mainAttributes.put(REQUIRE_BUNDLE, result);
} | java | {
"resource": ""
} |
q5536 | MergeableManifest2.addImportedPackages | train | public void addImportedPackages(Set<String> importedPackages) {
addImportedPackages(importedPackages.toArray(new String[importedPackages.size()]));
} | java | {
"resource": ""
} |
q5537 | MergeableManifest2.addImportedPackages | train | public void addImportedPackages(String... importedPackages) {
String oldBundles = mainAttributes.get(IMPORT_PACKAGE);
if (oldBundles == null)
oldBundles = "";
BundleList oldResultList = BundleList.fromInput(oldBundles, newline);
BundleList resultList = BundleList.fromInput(oldBundles, newline);
for (String bundle : importedPackages)
resultList.mergeInto(Bundle.fromInput(bundle));
String result = resultList.toString();
boolean changed = !oldResultList.toString().equals(result);
modified |= changed;
if (changed)
mainAttributes.put(IMPORT_PACKAGE, result);
} | java | {
"resource": ""
} |
q5538 | MergeableManifest2.addExportedPackages | train | public void addExportedPackages(Set<String> exportedPackages) {
addExportedPackages(exportedPackages.toArray(new String[exportedPackages.size()]));
} | java | {
"resource": ""
} |
q5539 | MergeableManifest2.addExportedPackages | train | public void addExportedPackages(String... exportedPackages) {
String oldBundles = mainAttributes.get(EXPORT_PACKAGE);
if (oldBundles == null)
oldBundles = "";
BundleList oldResultList = BundleList.fromInput(oldBundles, newline);
BundleList resultList = BundleList.fromInput(oldBundles, newline);
for (String bundle : exportedPackages)
resultList.mergeInto(Bundle.fromInput(bundle));
String result = resultList.toString();
boolean changed = !oldResultList.toString().equals(result);
modified |= changed;
if (changed)
mainAttributes.put(EXPORT_PACKAGE, result);
} | java | {
"resource": ""
} |
q5540 | MergeableManifest2.setBREE | train | public void setBREE(String bree) {
String old = mainAttributes.get(BUNDLE_REQUIREDEXECUTIONENVIRONMENT);
if (!bree.equals(old)) {
this.mainAttributes.put(BUNDLE_REQUIREDEXECUTIONENVIRONMENT, bree);
this.modified = true;
this.bree = bree;
}
} | java | {
"resource": ""
} |
q5541 | MergeableManifest2.setBundleActivator | train | public void setBundleActivator(String bundleActivator) {
String old = mainAttributes.get(BUNDLE_ACTIVATOR);
if (!bundleActivator.equals(old)) {
this.mainAttributes.put(BUNDLE_ACTIVATOR, bundleActivator);
this.modified = true;
this.bundleActivator = bundleActivator;
}
} | java | {
"resource": ""
} |
q5542 | MergeableManifest2.make512Safe | train | public static String make512Safe(StringBuffer input, String newline) {
StringBuilder result = new StringBuilder();
String content = input.toString();
String rest = content;
while (!rest.isEmpty()) {
if (rest.contains("\n")) {
String line = rest.substring(0, rest.indexOf("\n"));
rest = rest.substring(rest.indexOf("\n") + 1);
if (line.length() > 1 && line.charAt(line.length() - 1) == '\r')
line = line.substring(0, line.length() - 1);
append512Safe(line, result, newline);
} else {
append512Safe(rest, result, newline);
break;
}
}
return result.toString();
} | java | {
"resource": ""
} |
q5543 | AbstractFormatter2._format | train | protected void _format(EObject obj, IFormattableDocument document) {
for (EObject child : obj.eContents())
document.format(child);
} | java | {
"resource": ""
} |
q5544 | AbstractReadWriteAcces.process | train | public <Result> Result process(IUnitOfWork<Result, State> work) {
releaseReadLock();
acquireWriteLock();
try {
if (log.isTraceEnabled())
log.trace("process - " + Thread.currentThread().getName());
return modify(work);
} finally {
if (log.isTraceEnabled())
log.trace("Downgrading from write lock to read lock...");
acquireReadLock();
releaseWriteLock();
}
} | java | {
"resource": ""
} |
q5545 | AbstractInternalAntlrParser.forceCreateModelElementAndSet | train | protected EObject forceCreateModelElementAndSet(Action action, EObject value) {
EObject result = semanticModelBuilder.create(action.getType().getClassifier());
semanticModelBuilder.set(result, action.getFeature(), value, null /* ParserRule */, currentNode);
insertCompositeNode(action);
associateNodeWithAstElement(currentNode, result);
return result;
} | java | {
"resource": ""
} |
q5546 | AntlrCodeQualityHelper.stripUnnecessaryComments | train | public String stripUnnecessaryComments(String javaContent, AntlrOptions options) {
if (!options.isOptimizeCodeQuality()) {
return javaContent;
}
javaContent = stripMachineDependentPaths(javaContent);
if (options.isStripAllComments()) {
javaContent = stripAllComments(javaContent);
}
return javaContent;
} | java | {
"resource": ""
} |
q5547 | ContentAssistContextFactory.getPrefix | train | public String getPrefix(INode prefixNode) {
if (prefixNode instanceof ILeafNode) {
if (((ILeafNode) prefixNode).isHidden() && prefixNode.getGrammarElement() != null)
return "";
return getNodeTextUpToCompletionOffset(prefixNode);
}
StringBuilder result = new StringBuilder(prefixNode.getTotalLength());
doComputePrefix((ICompositeNode) prefixNode, result);
return result.toString();
} | java | {
"resource": ""
} |
q5548 | UriExtensions.toUriString | train | public String toUriString(final java.net.URI uri) {
return this.toUriString(URI.createURI(uri.normalize().toString()));
} | java | {
"resource": ""
} |
q5549 | SimpleCache.hasCachedValue | train | public boolean hasCachedValue(Key key) {
try {
readLock.lock();
return content.containsKey(key);
} finally {
readLock.unlock();
}
} | java | {
"resource": ""
} |
q5550 | ResourceStorageLoadable.loadEntries | train | protected void loadEntries(final StorageAwareResource resource, final ZipInputStream zipIn) throws IOException {
zipIn.getNextEntry();
BufferedInputStream _bufferedInputStream = new BufferedInputStream(zipIn);
this.readContents(resource, _bufferedInputStream);
zipIn.getNextEntry();
BufferedInputStream _bufferedInputStream_1 = new BufferedInputStream(zipIn);
this.readResourceDescription(resource, _bufferedInputStream_1);
if (this.storeNodeModel) {
zipIn.getNextEntry();
BufferedInputStream _bufferedInputStream_2 = new BufferedInputStream(zipIn);
this.readNodeModel(resource, _bufferedInputStream_2);
}
} | java | {
"resource": ""
} |
q5551 | AbstractTraceRegion.leafIterator | train | public final Iterator<AbstractTraceRegion> leafIterator() {
if (nestedRegions == null)
return Collections.<AbstractTraceRegion> singleton(this).iterator();
return new LeafIterator(this);
} | java | {
"resource": ""
} |
q5552 | TracingSugar.generateTracedFile | train | public void generateTracedFile(final IFileSystemAccess2 fsa, final String path, final EObject rootTrace, final StringConcatenationClient code) {
final CompositeGeneratorNode node = this.trace(rootTrace, code);
this.generateTracedFile(fsa, path, node);
} | java | {
"resource": ""
} |
q5553 | TracingSugar.generateTracedFile | train | public void generateTracedFile(final IFileSystemAccess2 fsa, final String path, final CompositeGeneratorNode rootNode) {
final GeneratorNodeProcessor.Result result = this.processor.process(rootNode);
fsa.generateFile(path, result);
} | java | {
"resource": ""
} |
q5554 | OperationCanceledManager.propagateAsErrorIfCancelException | train | public void propagateAsErrorIfCancelException(final Throwable t) {
if ((t instanceof OperationCanceledError)) {
throw ((OperationCanceledError)t);
}
final RuntimeException opCanceledException = this.getPlatformOperationCanceledException(t);
if ((opCanceledException != null)) {
throw new OperationCanceledError(opCanceledException);
}
} | java | {
"resource": ""
} |
q5555 | OperationCanceledManager.propagateIfCancelException | train | public void propagateIfCancelException(final Throwable t) {
final RuntimeException cancelException = this.getPlatformOperationCanceledException(t);
if ((cancelException != null)) {
throw cancelException;
}
} | java | {
"resource": ""
} |
q5556 | LazyURIEncoder.decode | train | public Triple<EObject, EReference, INode> decode(Resource res, String uriFragment) {
if (isUseIndexFragment(res)) {
return getLazyProxyInformation(res, uriFragment);
}
List<String> split = Strings.split(uriFragment, SEP);
EObject source = resolveShortFragment(res, split.get(1));
EReference ref = fromShortExternalForm(source.eClass(), split.get(2));
INode compositeNode = NodeModelUtils.getNode(source);
if (compositeNode==null)
throw new IllegalStateException("Couldn't resolve lazy link, because no node model is attached.");
INode textNode = getNode(compositeNode, split.get(3));
return Tuples.create(source, ref, textNode);
} | java | {
"resource": ""
} |
q5557 | OnChangeEvictingCache.get | train | @Override
public <T> T get(Object key, Resource resource, Provider<T> provider) {
if(resource == null) {
return provider.get();
}
CacheAdapter adapter = getOrCreate(resource);
T element = adapter.<T>internalGet(key);
if (element==null) {
element = provider.get();
cacheMiss(adapter);
adapter.set(key, element);
} else {
cacheHit(adapter);
}
if (element == CacheAdapter.NULL) {
return null;
}
return element;
} | java | {
"resource": ""
} |
q5558 | OnChangeEvictingCache.execWithoutCacheClear | train | public <Result, Param extends Resource> Result execWithoutCacheClear(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException {
CacheAdapter cacheAdapter = getOrCreate(resource);
try {
cacheAdapter.ignoreNotifications();
return transaction.exec(resource);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new WrappedException(e);
} finally {
cacheAdapter.listenToNotifications();
}
} | java | {
"resource": ""
} |
q5559 | OnChangeEvictingCache.execWithTemporaryCaching | train | public <Result, Param extends Resource> Result execWithTemporaryCaching(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException {
CacheAdapter cacheAdapter = getOrCreate(resource);
IgnoreValuesMemento memento = cacheAdapter.ignoreNewValues();
try {
return transaction.exec(resource);
} catch (Exception e) {
throw new WrappedException(e);
} finally {
memento.done();
}
} | java | {
"resource": ""
} |
q5560 | LazyLinkingResource.resolveLazyCrossReferences | train | public void resolveLazyCrossReferences(final CancelIndicator mon) {
final CancelIndicator monitor = mon == null ? CancelIndicator.NullImpl : mon;
TreeIterator<Object> iterator = EcoreUtil.getAllContents(this, true);
while (iterator.hasNext()) {
operationCanceledManager.checkCanceled(monitor);
InternalEObject source = (InternalEObject) iterator.next();
EStructuralFeature[] eStructuralFeatures = ((EClassImpl.FeatureSubsetSupplier) source.eClass()
.getEAllStructuralFeatures()).crossReferences();
if (eStructuralFeatures != null) {
for (EStructuralFeature crossRef : eStructuralFeatures) {
operationCanceledManager.checkCanceled(monitor);
resolveLazyCrossReference(source, crossRef);
}
}
}
} | java | {
"resource": ""
} |
q5561 | DescriptionUtils.collectOutgoingReferences | train | public Set<URI> collectOutgoingReferences(IResourceDescription description) {
URI resourceURI = description.getURI();
Set<URI> result = null;
for(IReferenceDescription reference: description.getReferenceDescriptions()) {
URI targetResource = reference.getTargetEObjectUri().trimFragment();
if (!resourceURI.equals(targetResource)) {
if (result == null)
result = Sets.newHashSet(targetResource);
else
result.add(targetResource);
}
}
if (result != null)
return result;
return Collections.emptySet();
} | java | {
"resource": ""
} |
q5562 | TailWriter.write | train | @Override
public void write(final char[] cbuf, final int off, final int len) throws IOException {
int offset = off;
int length = len;
while (suppressLineCount > 0 && length > 0) {
length = -1;
for (int i = 0; i < len && suppressLineCount > 0; i++) {
if (cbuf[off + i] == '\n') {
offset = off + i + 1;
length = len - i - 1;
suppressLineCount--;
}
}
if (length <= 0)
return;
}
delegate.write(cbuf, offset, length);
} | java | {
"resource": ""
} |
q5563 | DefaultTaskFinder.setEndTag | train | @Inject(optional = true)
protected Pattern setEndTag(@Named(AbstractMultiLineCommentProvider.END_TAG) final String endTag) {
return this.endTagPattern = Pattern.compile((endTag + "\\z"));
} | java | {
"resource": ""
} |
q5564 | GeneratorNodeExtensions.indent | train | public CompositeGeneratorNode indent(final CompositeGeneratorNode parent, final String indentString) {
final IndentNode indent = new IndentNode(indentString);
List<IGeneratorNode> _children = parent.getChildren();
_children.add(indent);
return indent;
} | java | {
"resource": ""
} |
q5565 | GeneratorNodeExtensions.appendNewLineIfNotEmpty | train | public CompositeGeneratorNode appendNewLineIfNotEmpty(final CompositeGeneratorNode parent) {
List<IGeneratorNode> _children = parent.getChildren();
String _lineDelimiter = this.wsConfig.getLineDelimiter();
NewLineNode _newLineNode = new NewLineNode(_lineDelimiter, true);
_children.add(_newLineNode);
return parent;
} | java | {
"resource": ""
} |
q5566 | GeneratorNodeExtensions.appendTemplate | train | public CompositeGeneratorNode appendTemplate(final CompositeGeneratorNode parent, final StringConcatenationClient templateString) {
final TemplateNode proc = new TemplateNode(templateString, this);
List<IGeneratorNode> _children = parent.getChildren();
_children.add(proc);
return parent;
} | java | {
"resource": ""
} |
q5567 | AbstractIndentationTokenSource.doSplitTokenImpl | train | protected void doSplitTokenImpl(Token token, ITokenAcceptor result) {
String text = token.getText();
int indentation = computeIndentation(text);
if (indentation == -1 || indentation == currentIndentation) {
// no change of indentation level detected simply process the token
result.accept(token);
} else if (indentation > currentIndentation) {
// indentation level increased
splitIntoBeginToken(token, indentation, result);
} else if (indentation < currentIndentation) {
// indentation level decreased
int charCount = computeIndentationRelevantCharCount(text);
if (charCount > 0) {
// emit whitespace including newline
splitWithText(token, text.substring(0, charCount), result);
}
// emit end tokens at the beginning of the line
decreaseIndentation(indentation, result);
if (charCount != text.length()) {
handleRemainingText(token, text.substring(charCount), indentation, result);
}
} else {
throw new IllegalStateException(String.valueOf(indentation));
}
} | java | {
"resource": ""
} |
q5568 | ResourceStorageFacade.getOrCreateResourceStorageLoadable | train | @Override
public ResourceStorageLoadable getOrCreateResourceStorageLoadable(final StorageAwareResource resource) {
try {
final ResourceStorageProviderAdapter stateProvider = IterableExtensions.<ResourceStorageProviderAdapter>head(Iterables.<ResourceStorageProviderAdapter>filter(resource.getResourceSet().eAdapters(), ResourceStorageProviderAdapter.class));
if ((stateProvider != null)) {
final ResourceStorageLoadable inputStream = stateProvider.getResourceStorageLoadable(resource);
if ((inputStream != null)) {
return inputStream;
}
}
InputStream _xifexpression = null;
boolean _exists = resource.getResourceSet().getURIConverter().exists(this.getBinaryStorageURI(resource.getURI()), CollectionLiterals.<Object, Object>emptyMap());
if (_exists) {
_xifexpression = resource.getResourceSet().getURIConverter().createInputStream(this.getBinaryStorageURI(resource.getURI()));
} else {
InputStream _xblockexpression = null;
{
final AbstractFileSystemAccess2 fsa = this.getFileSystemAccess(resource);
final String outputRelativePath = this.computeOutputPath(resource);
_xblockexpression = fsa.readBinaryFile(outputRelativePath);
}
_xifexpression = _xblockexpression;
}
final InputStream inputStream_1 = _xifexpression;
return this.createResourceStorageLoadable(inputStream_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
} | java | {
"resource": ""
} |
q5569 | CompletionPrefixProvider.getLastCompleteNodeByOffset | train | public INode getLastCompleteNodeByOffset(INode node, int offsetPosition, int completionOffset) {
return internalGetLastCompleteNodeByOffset(node.getRootNode(), offsetPosition);
} | java | {
"resource": ""
} |
q5570 | MergeableManifest.addRequiredBundles | train | public void addRequiredBundles(Set<String> bundles) {
// TODO manage transitive dependencies
// don't require self
Set<String> bundlesToMerge;
String bundleName = (String) getMainAttributes().get(BUNDLE_SYMBOLIC_NAME);
if (bundleName != null) {
int idx = bundleName.indexOf(';');
if (idx >= 0) {
bundleName = bundleName.substring(0, idx);
}
}
if (bundleName != null && bundles.contains(bundleName)
|| projectName != null && bundles.contains(projectName)) {
bundlesToMerge = new LinkedHashSet<String>(bundles);
bundlesToMerge.remove(bundleName);
bundlesToMerge.remove(projectName);
} else {
bundlesToMerge = bundles;
}
String s = (String) getMainAttributes().get(REQUIRE_BUNDLE);
Wrapper<Boolean> modified = Wrapper.wrap(this.modified);
String result = mergeIntoCommaSeparatedList(s, bundlesToMerge, modified, lineDelimiter);
this.modified = modified.get();
getMainAttributes().put(REQUIRE_BUNDLE, result);
} | java | {
"resource": ""
} |
q5571 | MergeableManifest.addExportedPackages | train | public void addExportedPackages(Set<String> packages) {
String s = (String) getMainAttributes().get(EXPORT_PACKAGE);
Wrapper<Boolean> modified = Wrapper.wrap(this.modified);
String result = mergeIntoCommaSeparatedList(s, packages, modified, lineDelimiter);
this.modified = modified.get();
getMainAttributes().put(EXPORT_PACKAGE, result);
} | java | {
"resource": ""
} |
q5572 | IdeContentProposalProvider.createProposals | train | public void createProposals(final Collection<ContentAssistContext> contexts, final IIdeContentProposalAcceptor acceptor) {
Iterable<ContentAssistContext> _filteredContexts = this.getFilteredContexts(contexts);
for (final ContentAssistContext context : _filteredContexts) {
ImmutableList<AbstractElement> _firstSetGrammarElements = context.getFirstSetGrammarElements();
for (final AbstractElement element : _firstSetGrammarElements) {
{
boolean _canAcceptMoreProposals = acceptor.canAcceptMoreProposals();
boolean _not = (!_canAcceptMoreProposals);
if (_not) {
return;
}
this.createProposals(element, context, acceptor);
}
}
}
} | java | {
"resource": ""
} |
q5573 | JavaStringConverter.convertFromJavaString | train | public String convertFromJavaString(String string, boolean useUnicode) {
int firstEscapeSequence = string.indexOf('\\');
if (firstEscapeSequence == -1) {
return string;
}
int length = string.length();
StringBuilder result = new StringBuilder(length);
appendRegion(string, 0, firstEscapeSequence, result);
return convertFromJavaString(string, useUnicode, firstEscapeSequence, result);
} | java | {
"resource": ""
} |
q5574 | JavaStringConverter.convertToJavaString | train | public String convertToJavaString(String input, boolean useUnicode) {
int length = input.length();
StringBuilder result = new StringBuilder(length + 4);
for (int i = 0; i < length; i++) {
escapeAndAppendTo(input.charAt(i), useUnicode, result);
}
return result.toString();
} | java | {
"resource": ""
} |
q5575 | DownloadAction.performDownload | train | private void performDownload(HttpResponse response, File destFile)
throws IOException {
HttpEntity entity = response.getEntity();
if (entity == null) {
return;
}
//get content length
long contentLength = entity.getContentLength();
if (contentLength >= 0) {
size = toLengthText(contentLength);
}
processedBytes = 0;
loggedKb = 0;
//open stream and start downloading
InputStream is = entity.getContent();
streamAndMove(is, destFile);
} | java | {
"resource": ""
} |
q5576 | DownloadAction.stream | train | private void stream(InputStream is, File destFile) throws IOException {
try {
startProgress();
OutputStream os = new FileOutputStream(destFile);
boolean finished = false;
try {
byte[] buf = new byte[1024 * 10];
int read;
while ((read = is.read(buf)) >= 0) {
os.write(buf, 0, read);
processedBytes += read;
logProgress();
}
os.flush();
finished = true;
} finally {
os.close();
if (!finished) {
destFile.delete();
}
}
} finally {
is.close();
completeProgress();
}
} | java | {
"resource": ""
} |
q5577 | DownloadAction.getCachedETag | train | private String getCachedETag(HttpHost host, String file) {
Map<String, Object> cachedETags = readCachedETags();
@SuppressWarnings("unchecked")
Map<String, Object> hostMap =
(Map<String, Object>)cachedETags.get(host.toURI());
if (hostMap == null) {
return null;
}
@SuppressWarnings("unchecked")
Map<String, String> etagMap = (Map<String, String>)hostMap.get(file);
if (etagMap == null) {
return null;
}
return etagMap.get("ETag");
} | java | {
"resource": ""
} |
q5578 | DownloadAction.makeDestFile | train | private File makeDestFile(URL src) {
if (dest == null) {
throw new IllegalArgumentException("Please provide a download destination");
}
File destFile = dest;
if (destFile.isDirectory()) {
//guess name from URL
String name = src.toString();
if (name.endsWith("/")) {
name = name.substring(0, name.length() - 1);
}
name = name.substring(name.lastIndexOf('/') + 1);
destFile = new File(dest, name);
} else {
//create destination directory
File parent = destFile.getParentFile();
if (parent != null) {
parent.mkdirs();
}
}
return destFile;
} | java | {
"resource": ""
} |
q5579 | DownloadAction.addAuthentication | train | private void addAuthentication(HttpHost host, Credentials credentials,
AuthScheme authScheme, HttpClientContext context) {
AuthCache authCache = context.getAuthCache();
if (authCache == null) {
authCache = new BasicAuthCache();
context.setAuthCache(authCache);
}
CredentialsProvider credsProvider = context.getCredentialsProvider();
if (credsProvider == null) {
credsProvider = new BasicCredentialsProvider();
context.setCredentialsProvider(credsProvider);
}
credsProvider.setCredentials(new AuthScope(host), credentials);
if (authScheme != null) {
authCache.put(host, authScheme);
}
} | java | {
"resource": ""
} |
q5580 | DownloadAction.toLengthText | train | private String toLengthText(long bytes) {
if (bytes < 1024) {
return bytes + " B";
} else if (bytes < 1024 * 1024) {
return (bytes / 1024) + " KB";
} else if (bytes < 1024 * 1024 * 1024) {
return String.format("%.2f MB", bytes / (1024.0 * 1024.0));
} else {
return String.format("%.2f GB", bytes / (1024.0 * 1024.0 * 1024.0));
}
} | java | {
"resource": ""
} |
q5581 | CachingHttpClientFactory.close | train | public void close() throws IOException {
for (CloseableHttpClient c : cachedClients.values()) {
c.close();
}
cachedClients.clear();
} | java | {
"resource": ""
} |
q5582 | Provider.getCurrentProvider | train | public static Provider getCurrentProvider(boolean useSwingEventQueue) {
Provider provider;
if (Platform.isX11()) {
provider = new X11Provider();
} else if (Platform.isWindows()) {
provider = new WindowsProvider();
} else if (Platform.isMac()) {
provider = new CarbonProvider();
} else {
LOGGER.warn("No suitable provider for " + System.getProperty("os.name"));
return null;
}
provider.setUseSwingEventQueue(useSwingEventQueue);
provider.init();
return provider;
} | java | {
"resource": ""
} |
q5583 | Provider.fireEvent | train | protected void fireEvent(HotKey hotKey) {
HotKeyEvent event = new HotKeyEvent(hotKey);
if (useSwingEventQueue) {
SwingUtilities.invokeLater(event);
} else {
if (eventQueue == null) {
eventQueue = Executors.newSingleThreadExecutor();
}
eventQueue.execute(event);
}
} | java | {
"resource": ""
} |
q5584 | GroovyContext.newInstance | train | public Object newInstance(String resource) {
try {
String name = resource.startsWith("/") ? resource : "/" + resource;
File file = new File(this.getClass().getResource(name).toURI());
return newInstance(classLoader.parseClass(new GroovyCodeSource(file), true));
} catch (Exception e) {
throw new GroovyClassInstantiationFailed(classLoader, resource, e);
}
} | java | {
"resource": ""
} |
q5585 | GuiceStepsFactory.addTypes | train | private void addTypes(Injector injector, List<Class<?>> types) {
for (Binding<?> binding : injector.getBindings().values()) {
Key<?> key = binding.getKey();
Type type = key.getTypeLiteral().getType();
if (hasAnnotatedMethods(type)) {
types.add(((Class<?>)type));
}
}
if (injector.getParent() != null) {
addTypes(injector.getParent(), types);
}
} | java | {
"resource": ""
} |
q5586 | StoryMapper.map | train | public void map(Story story, MetaFilter metaFilter) {
if (metaFilter.allow(story.getMeta())) {
boolean allowed = false;
for (Scenario scenario : story.getScenarios()) {
// scenario also inherits meta from story
Meta inherited = scenario.getMeta().inheritFrom(story.getMeta());
if (metaFilter.allow(inherited)) {
allowed = true;
break;
}
}
if (allowed) {
add(metaFilter.asString(), story);
}
}
} | java | {
"resource": ""
} |
q5587 | MetaFilter.createMetaMatcher | train | protected MetaMatcher createMetaMatcher(String filterAsString, Map<String, MetaMatcher> metaMatchers) {
for ( String key : metaMatchers.keySet() ){
if ( filterAsString.startsWith(key)){
return metaMatchers.get(key);
}
}
if (filterAsString.startsWith(GROOVY)) {
return new GroovyMetaMatcher();
}
return new DefaultMetaMatcher();
} | java | {
"resource": ""
} |
q5588 | CodeLocations.codeLocationFromClass | train | public static URL codeLocationFromClass(Class<?> codeLocationClass) {
String pathOfClass = codeLocationClass.getName().replace(".", "/") + ".class";
URL classResource = codeLocationClass.getClassLoader().getResource(pathOfClass);
String codeLocationPath = removeEnd(getPathFromURL(classResource), pathOfClass);
if(codeLocationPath.endsWith(".jar!/")) {
codeLocationPath=removeEnd(codeLocationPath,"!/");
}
return codeLocationFromPath(codeLocationPath);
} | java | {
"resource": ""
} |
q5589 | CodeLocations.codeLocationFromPath | train | public static URL codeLocationFromPath(String filePath) {
try {
return new File(filePath).toURI().toURL();
} catch (Exception e) {
throw new InvalidCodeLocation(filePath);
}
} | java | {
"resource": ""
} |
q5590 | CodeLocations.codeLocationFromURL | train | public static URL codeLocationFromURL(String url) {
try {
return new URL(url);
} catch (Exception e) {
throw new InvalidCodeLocation(url);
}
} | java | {
"resource": ""
} |
q5591 | StoryRunner.run | train | public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story) throws Throwable {
run(configuration, candidateSteps, story, MetaFilter.EMPTY);
} | java | {
"resource": ""
} |
q5592 | StoryRunner.run | train | public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter)
throws Throwable {
run(configuration, candidateSteps, story, filter, null);
} | java | {
"resource": ""
} |
q5593 | StoryRunner.run | train | public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter,
State beforeStories) throws Throwable {
run(configuration, new ProvidedStepsFactory(candidateSteps), story, filter, beforeStories);
} | java | {
"resource": ""
} |
q5594 | StoryRunner.run | train | public void run(Configuration configuration, InjectableStepsFactory stepsFactory, Story story, MetaFilter filter,
State beforeStories) throws Throwable {
RunContext context = new RunContext(configuration, stepsFactory, story.getPath(), filter);
if (beforeStories != null) {
context.stateIs(beforeStories);
}
Map<String, String> storyParameters = new HashMap<>();
run(context, story, storyParameters);
} | java | {
"resource": ""
} |
q5595 | StoryRunner.storyOfPath | train | public Story storyOfPath(Configuration configuration, String storyPath) {
String storyAsText = configuration.storyLoader().loadStoryAsText(storyPath);
return configuration.storyParser().parseStory(storyAsText, storyPath);
} | java | {
"resource": ""
} |
q5596 | StoryRunner.storyOfText | train | public Story storyOfText(Configuration configuration, String storyAsText, String storyId) {
return configuration.storyParser().parseStory(storyAsText, storyId);
} | java | {
"resource": ""
} |
q5597 | ScalaContext.newInstance | train | public Object newInstance(String className) {
try {
return classLoader.loadClass(className).newInstance();
} catch (Exception e) {
throw new ScalaInstanceNotFound(className);
}
} | java | {
"resource": ""
} |
q5598 | ChainedRow.values | train | @Override
public Map<String, String> values() {
Map<String, String> values = new LinkedHashMap<>();
for (Row each : delegates) {
for (Entry<String, String> entry : each.values().entrySet()) {
String name = entry.getKey();
if (!values.containsKey(name)) {
values.put(name, entry.getValue());
}
}
}
return values;
} | java | {
"resource": ""
} |
q5599 | StepFinder.stepsInstances | train | public List<Object> stepsInstances(List<CandidateSteps> candidateSteps) {
List<Object> instances = new ArrayList<>();
for (CandidateSteps steps : candidateSteps) {
if (steps instanceof Steps) {
instances.add(((Steps) steps).instance());
}
}
return instances;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.