use of java.util.Stack in project rstudio by rstudio.
the class TextEditingTargetRenameHelper method renameFunctionArgument.
private int renameFunctionArgument(String functionName, String argName) {
TokenCursor cursor = editor_.getSession().getMode().getCodeModel().getTokenCursor();
Stack<String> functionNames = new Stack<String>();
boolean renaming = false;
do {
if (cursor.isLeftBracket()) {
if (cursor.valueEquals("(") && cursor.peekBwd(1).isValidForFunctionCall()) {
String currentFunctionName = cursor.peekBwd(1).getValue();
renaming = currentFunctionName.equals(functionName);
functionNames.push(functionName);
pushState(STATE_FUNCTION_CALL);
} else {
pushState(STATE_DEFAULT);
}
}
if (cursor.isRightBracket()) {
popState();
if (cursor.valueEquals(")") && !functionNames.empty()) {
functionNames.pop();
renaming = !functionNames.empty() && functionNames.peek().equals(functionName);
}
}
if (renaming && peekState() == STATE_FUNCTION_CALL && cursor.valueEquals(argName) && cursor.peekFwd(1).valueEquals("=")) {
ranges_.add(getTokenRange(cursor));
}
} while (cursor.moveToNextToken());
return applyRanges();
}
use of java.util.Stack in project nokogiri by sparklemotion.
the class NokogiriHandler method startDocument.
@Override
public void startDocument() throws SAXException {
call("start_document");
characterStack = new Stack();
}
use of java.util.Stack in project platform_frameworks_base by android.
the class NotificationHeaderViewWrapper method updateCropToPaddingForImageViews.
/**
* Since we are deactivating the clipping when transforming the ImageViews don't get clipped
* anymore during these transitions. We can avoid that by using
* {@link ImageView#setCropToPadding(boolean)} on all ImageViews.
*/
private void updateCropToPaddingForImageViews() {
Stack<View> stack = new Stack<>();
stack.push(mView);
while (!stack.isEmpty()) {
View child = stack.pop();
if (child instanceof ImageView) {
((ImageView) child).setCropToPadding(true);
} else if (child instanceof ViewGroup) {
ViewGroup group = (ViewGroup) child;
for (int i = 0; i < group.getChildCount(); i++) {
stack.push(group.getChildAt(i));
}
}
}
}
use of java.util.Stack in project platform_frameworks_base by android.
the class FilterGraph method runTypeCheck.
private void runTypeCheck() {
Stack<Filter> filterStack = new Stack<Filter>();
Set<Filter> processedFilters = new HashSet<Filter>();
filterStack.addAll(getSourceFilters());
while (!filterStack.empty()) {
// Get current filter and mark as processed
Filter filter = filterStack.pop();
processedFilters.add(filter);
// Anchor output formats
updateOutputs(filter);
// Perform type check
if (mLogVerbose)
Log.v(TAG, "Running type check on " + filter + "...");
runTypeCheckOn(filter);
// Push connected filters onto stack
for (OutputPort port : filter.getOutputPorts()) {
Filter target = port.getTargetFilter();
if (target != null && readyForProcessing(target, processedFilters)) {
filterStack.push(target);
}
}
}
// Make sure all ports were setup
if (processedFilters.size() != getFilters().size()) {
throw new RuntimeException("Could not schedule all filters! Is your graph malformed?");
}
}
use of java.util.Stack in project rest.li by linkedin.
the class RestLiSnapshotCompatibilityChecker method checkCompatibility.
private CompatibilityInfoMap checkCompatibility(String prevRestModelPath, String currRestModelPath, CompatibilityLevel compatLevel, boolean isAgainstRestSpec) {
final CompatibilityInfoMap infoMap = _infoMap;
if (compatLevel == CompatibilityLevel.OFF) {
// skip check entirely.
return infoMap;
}
final Stack<Object> path = new Stack<Object>();
path.push("");
FileInputStream prevSnapshotFile = null;
FileInputStream currSnapshotFile = null;
try {
prevSnapshotFile = new FileInputStream(prevRestModelPath);
} catch (FileNotFoundException e) {
infoMap.addRestSpecInfo(CompatibilityInfo.Type.RESOURCE_NEW, path, currRestModelPath);
}
try {
currSnapshotFile = new FileInputStream(currRestModelPath);
} catch (FileNotFoundException e) {
infoMap.addRestSpecInfo(CompatibilityInfo.Type.RESOURCE_MISSING, path, prevRestModelPath);
}
if (prevSnapshotFile == null || currSnapshotFile == null) {
return infoMap;
}
AbstractSnapshot prevSnapshot = null;
AbstractSnapshot currSnapshot = null;
try {
if (isAgainstRestSpec) {
prevSnapshot = new RestSpec(prevSnapshotFile);
} else {
prevSnapshot = new Snapshot(prevSnapshotFile);
}
currSnapshot = new Snapshot(currSnapshotFile);
} catch (IOException e) {
infoMap.addRestSpecInfo(CompatibilityInfo.Type.OTHER_ERROR, path, e.getMessage());
}
if (prevSnapshot == null || currSnapshot == null) {
return infoMap;
}
final DataSchemaResolver currResolver = createResolverFromSnapshot(currSnapshot, _resolverPath);
final DataSchemaResolver prevResolver;
if (isAgainstRestSpec) {
prevResolver = currResolver;
} else {
prevResolver = createResolverFromSnapshot(prevSnapshot, _resolverPath);
}
final ResourceCompatibilityChecker checker = new ResourceCompatibilityChecker(prevSnapshot.getResourceSchema(), prevResolver, currSnapshot.getResourceSchema(), currResolver);
checker.check(compatLevel);
infoMap.addAll(checker.getInfoMap());
return infoMap;
}
Aggregations