code stringlengths 73 34.1k | label stringclasses 1 value |
|---|---|
public void setBackgroundColor(float r, float g, float b, float a) {
setBackgroundColorR(r);
setBackgroundColorG(g);
setBackgroundColorB(b);
setBackgroundColorA(a);
} | java |
public void addPostEffect(GVRMaterial postEffectData) {
GVRContext ctx = getGVRContext();
if (mPostEffects == null)
{
mPostEffects = new GVRRenderData(ctx, postEffectData);
GVRMesh dummyMesh = new GVRMesh(getGVRContext(),"float3 a_position float2 a_texcoord");
mPostEffects.setMesh(dummyMesh);
NativeCamera.setPostEffect(getNative(), mPostEffects.getNative());
mPostEffects.setCullFace(GVRRenderPass.GVRCullFaceEnum.None);
}
else
{
GVRRenderPass rpass = new GVRRenderPass(ctx, postEffectData);
rpass.setCullFace(GVRRenderPass.GVRCullFaceEnum.None);
mPostEffects.addPass(rpass);
}
} | java |
public int getBoneIndex(GVRSceneObject bone)
{
for (int i = 0; i < getNumBones(); ++i)
if (mBones[i] == bone)
return i;
return -1;
} | java |
public int getBoneIndex(String bonename)
{
for (int i = 0; i < getNumBones(); ++i)
if (mBoneNames[i].equals(bonename))
return i;
return -1;
} | java |
public void setBoneName(int boneindex, String bonename)
{
mBoneNames[boneindex] = bonename;
NativeSkeleton.setBoneName(getNative(), boneindex, bonename);
} | java |
public void poseFromBones()
{
for (int i = 0; i < getNumBones(); ++i)
{
GVRSceneObject bone = mBones[i];
if (bone == null)
{
continue;
}
if ((mBoneOptions[i] & BONE_LOCK_ROTATION) != 0)
{
continue;
}
GVRTransform trans = bone.getTransform();
mPose.setLocalMatrix(i, trans.getLocalModelMatrix4f());
}
mPose.sync();
updateBonePose();
} | java |
public void merge(GVRSkeleton newSkel)
{
int numBones = getNumBones();
List<Integer> parentBoneIds = new ArrayList<Integer>(numBones + newSkel.getNumBones());
List<String> newBoneNames = new ArrayList<String>(newSkel.getNumBones());
List<Matrix4f> newMatrices = new ArrayList<Matrix4f>(newSkel.getNumBones());
GVRPose oldBindPose = getBindPose();
GVRPose curPose = getPose();
for (int i = 0; i < numBones; ++i)
{
parentBoneIds.add(mParentBones[i]);
}
for (int j = 0; j < newSkel.getNumBones(); ++j)
{
String boneName = newSkel.getBoneName(j);
int boneId = getBoneIndex(boneName);
if (boneId < 0)
{
int parentId = newSkel.getParentBoneIndex(j);
Matrix4f m = new Matrix4f();
newSkel.getBindPose().getLocalMatrix(j, m);
newMatrices.add(m);
newBoneNames.add(boneName);
if (parentId >= 0)
{
boneName = newSkel.getBoneName(parentId);
parentId = getBoneIndex(boneName);
}
parentBoneIds.add(parentId);
}
}
if (parentBoneIds.size() == numBones)
{
return;
}
int n = numBones + parentBoneIds.size();
int[] parentIds = Arrays.copyOf(mParentBones, n);
int[] boneOptions = Arrays.copyOf(mBoneOptions, n);
String[] boneNames = Arrays.copyOf(mBoneNames, n);
mBones = Arrays.copyOf(mBones, n);
mPoseMatrices = new float[n * 16];
for (int i = 0; i < parentBoneIds.size(); ++i)
{
n = numBones + i;
parentIds[n] = parentBoneIds.get(i);
boneNames[n] = newBoneNames.get(i);
boneOptions[n] = BONE_ANIMATE;
}
mBoneOptions = boneOptions;
mBoneNames = boneNames;
mParentBones = parentIds;
mPose = new GVRPose(this);
mBindPose = new GVRPose(this);
mBindPose.copy(oldBindPose);
mPose.copy(curPose);
mBindPose.sync();
for (int j = 0; j < newSkel.getNumBones(); ++j)
{
mBindPose.setLocalMatrix(numBones + j, newMatrices.get(j));
mPose.setLocalMatrix(numBones + j, newMatrices.get(j));
}
setBindPose(mBindPose);
mPose.sync();
updateBonePose();
} | java |
public View getFullScreenView() {
if (mFullScreenView != null) {
return mFullScreenView;
}
final DisplayMetrics metrics = new DisplayMetrics();
mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
final int screenWidthPixels = Math.max(metrics.widthPixels, metrics.heightPixels);
final int screenHeightPixels = Math.min(metrics.widthPixels, metrics.heightPixels);
final ViewGroup.LayoutParams layout = new ViewGroup.LayoutParams(screenWidthPixels, screenHeightPixels);
mFullScreenView = new View(mActivity);
mFullScreenView.setLayoutParams(layout);
mRenderableViewGroup.addView(mFullScreenView);
return mFullScreenView;
} | java |
public final void unregisterView(final View view) {
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (null != mRenderableViewGroup && view.getParent() == mRenderableViewGroup) {
mRenderableViewGroup.removeView(view);
}
}
});
} | java |
public void clear() {
List<Widget> children = getChildren();
Log.d(TAG, "clear(%s): removing %d children", getName(), children.size());
for (Widget child : children) {
removeChild(child, true);
}
requestLayout();
} | java |
protected boolean inViewPort(final int dataIndex) {
boolean inViewPort = true;
for (Layout layout: mLayouts) {
inViewPort = inViewPort && (layout.inViewPort(dataIndex) || !layout.isClippingEnabled());
}
return inViewPort;
} | java |
public void setDataOffsets(int[] offsets)
{
assert(mLevels == offsets.length);
NativeBitmapImage.updateCompressed(getNative(), mWidth, mHeight, mImageSize, mData, mLevels, offsets);
mData = null;
} | java |
public static String getFilename(String path) throws IllegalArgumentException {
if (Pattern.matches(sPatternUrl, path))
return getURLFilename(path);
return new File(path).getName();
} | java |
public static String getParentDirectory(String filePath) throws IllegalArgumentException {
if (Pattern.matches(sPatternUrl, filePath))
return getURLParentDirectory(filePath);
return new File(filePath).getParent();
} | java |
public static String getURLParentDirectory(String urlString) throws IllegalArgumentException {
URL url = null;
try {
url = new URL(urlString);
} catch (MalformedURLException e) {
throw Exceptions.IllegalArgument("Malformed URL: %s", url);
}
String path = url.getPath();
int lastSlashIndex = path.lastIndexOf("/");
String directory = lastSlashIndex == -1 ? "" : path.substring(0, lastSlashIndex);
return String.format("%s://%s%s%s%s", url.getProtocol(),
url.getUserInfo() == null ? "" : url.getUserInfo() + "@",
url.getHost(),
url.getPort() == -1 ? "" : ":" + Integer.toString(url.getPort()),
directory);
} | java |
@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 |
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 |
public ContentAssistEntry createProposal(final String proposal, final ContentAssistContext context) {
return this.createProposal(proposal, context.getPrefix(), context, ContentAssistEntry.KIND_UNKNOWN, null);
} | java |
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 |
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 |
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 |
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 |
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 |
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 |
protected boolean isFiltered(Param param) {
AbstractElement elementToParse = param.elementToParse;
while (elementToParse != null) {
if (isFiltered(elementToParse, param)) {
return true;
}
elementToParse = getEnclosingSingleElementGroup(elementToParse);
}
return false;
} | java |
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 |
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 |
public static boolean isJavaLangType(String s) {
return getJavaDefaultTypes().contains(s) && Character.isUpperCase(s.charAt(0));
} | java |
public ContentAssistContext.Builder copy() {
Builder result = builderProvider.get();
result.copyFrom(this);
return result;
} | java |
public ImmutableList<AbstractElement> getFirstSetGrammarElements() {
if (firstSetGrammarElements == null) {
firstSetGrammarElements = ImmutableList.copyOf(mutableFirstSetGrammarElements);
}
return firstSetGrammarElements;
} | java |
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 |
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 |
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 |
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 |
protected Iterable<URI> getTargetURIs(final EObject primaryTarget) {
final TargetURIs result = targetURIsProvider.get();
uriCollector.add(primaryTarget, result);
return result;
} | java |
public void setRegularExpression(String regularExpression) {
if (regularExpression != null)
this.regularExpression = Pattern.compile(regularExpression);
else
this.regularExpression = null;
} | java |
public void registerServices(boolean force) {
Injector injector = Guice.createInjector(getGuiceModule());
injector.injectMembers(this);
registerInRegistry(force);
} | java |
public void register(Delta delta) {
final IResourceDescription newDesc = delta.getNew();
if (newDesc == null) {
removeDescription(delta.getUri());
} else {
addDescription(delta.getUri(), newDesc);
}
} | java |
protected AbsoluteURI getGeneratedLocation(PersistedTrace trace) {
AbsoluteURI path = trace.getPath();
String fileName = traceFileNameProvider.getJavaFromTrace(path.getURI().toString());
return new AbsoluteURI(fileName);
} | java |
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 |
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 |
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 |
@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 |
@Override
protected void doLinking() {
IParseResult parseResult = getParseResult();
if (parseResult == null || parseResult.getRootASTElement() == null)
return;
XtextLinker castedLinker = (XtextLinker) getLinker();
castedLinker.discardGeneratedPackages(parseResult.getRootASTElement());
} | java |
public static void setSourceLevelUrisWithoutCopy(final ResourceSet resourceSet, final Set<URI> uris) {
final SourceLevelURIsAdapter adapter = SourceLevelURIsAdapter.findOrCreateAdapter(resourceSet);
adapter.sourceLevelURIs = uris;
} | java |
public void setFileExtensions(final String fileExtensions) {
this.fileExtensions = IterableExtensions.<String>toList(((Iterable<String>)Conversions.doWrapArray(fileExtensions.trim().split("\\s*,\\s*"))));
} | java |
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 |
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 |
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 |
public void addRequiredBundles(Set<String> requiredBundles) {
addRequiredBundles(requiredBundles.toArray(new String[requiredBundles.size()]));
} | java |
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 |
public void addImportedPackages(Set<String> importedPackages) {
addImportedPackages(importedPackages.toArray(new String[importedPackages.size()]));
} | java |
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 |
public void addExportedPackages(Set<String> exportedPackages) {
addExportedPackages(exportedPackages.toArray(new String[exportedPackages.size()]));
} | java |
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 |
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 |
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 |
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 |
protected void _format(EObject obj, IFormattableDocument document) {
for (EObject child : obj.eContents())
document.format(child);
} | java |
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 |
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 |
public String stripUnnecessaryComments(String javaContent, AntlrOptions options) {
if (!options.isOptimizeCodeQuality()) {
return javaContent;
}
javaContent = stripMachineDependentPaths(javaContent);
if (options.isStripAllComments()) {
javaContent = stripAllComments(javaContent);
}
return javaContent;
} | java |
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 |
public String toUriString(final java.net.URI uri) {
return this.toUriString(URI.createURI(uri.normalize().toString()));
} | java |
public boolean hasCachedValue(Key key) {
try {
readLock.lock();
return content.containsKey(key);
} finally {
readLock.unlock();
}
} | java |
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 |
public final Iterator<AbstractTraceRegion> leafIterator() {
if (nestedRegions == null)
return Collections.<AbstractTraceRegion> singleton(this).iterator();
return new LeafIterator(this);
} | java |
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 |
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 |
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 |
public void propagateIfCancelException(final Throwable t) {
final RuntimeException cancelException = this.getPlatformOperationCanceledException(t);
if ((cancelException != null)) {
throw cancelException;
}
} | java |
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 |
@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 |
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 |
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 |
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 |
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 |
@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 |
@Inject(optional = true)
protected Pattern setEndTag(@Named(AbstractMultiLineCommentProvider.END_TAG) final String endTag) {
return this.endTagPattern = Pattern.compile((endTag + "\\z"));
} | java |
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 |
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 |
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 |
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 |
@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 |
public INode getLastCompleteNodeByOffset(INode node, int offsetPosition, int completionOffset) {
return internalGetLastCompleteNodeByOffset(node.getRootNode(), offsetPosition);
} | java |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
public void close() throws IOException {
for (CloseableHttpClient c : cachedClients.values()) {
c.close();
}
cachedClients.clear();
} | java |
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 |
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 |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.