Search in sources :

Example 51 with Stack

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();
}
Also used : TokenCursor(org.rstudio.studio.client.workbench.views.source.editors.text.ace.TokenCursor) JsArrayString(com.google.gwt.core.client.JsArrayString) Stack(java.util.Stack)

Example 52 with Stack

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();
}
Also used : Stack(java.util.Stack)

Example 53 with 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));
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TransformableView(com.android.systemui.statusbar.TransformableView) NotificationPanelView(com.android.systemui.statusbar.phone.NotificationPanelView) View(android.view.View) NotificationHeaderView(android.view.NotificationHeaderView) Stack(java.util.Stack)

Example 54 with Stack

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?");
    }
}
Also used : NullFilter(android.filterpacks.base.NullFilter) Stack(java.util.Stack) HashSet(java.util.HashSet)

Example 55 with Stack

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;
}
Also used : DataSchemaResolver(com.linkedin.data.schema.DataSchemaResolver) FileNotFoundException(java.io.FileNotFoundException) ResourceCompatibilityChecker(com.linkedin.restli.tools.compatibility.ResourceCompatibilityChecker) IOException(java.io.IOException) CompatibilityInfoMap(com.linkedin.restli.tools.compatibility.CompatibilityInfoMap) FileInputStream(java.io.FileInputStream) Stack(java.util.Stack)

Aggregations

Stack (java.util.Stack)245 HashSet (java.util.HashSet)42 ArrayList (java.util.ArrayList)37 File (java.io.File)23 IOException (java.io.IOException)22 View (android.view.View)18 Test (org.junit.Test)18 ViewGroup (android.view.ViewGroup)14 HashMap (java.util.HashMap)14 Set (java.util.Set)12 LinkedList (java.util.LinkedList)11 List (java.util.List)11 ImageView (android.widget.ImageView)10 Map (java.util.Map)10 Document (org.w3c.dom.Document)10 TestInputHandler (org.apache.maven.plugins.repository.testutil.TestInputHandler)9 PostfixMathCommandI (org.nfunk.jep.function.PostfixMathCommandI)9 DocumentBuilder (javax.xml.parsers.DocumentBuilder)8 NotificationPanelView (com.android.systemui.statusbar.phone.NotificationPanelView)7 TreeSet (java.util.TreeSet)7