A utility function to iterate to the primary (top most) context and return it.

@param uic the UIContext to retrieve the primary context for.
@return the primary context for the given context.
489617
public static UIContext getPrimaryUIContext(final UIContext uic) {
		if (uic == null) {
			return null;
		}

		UIContext primary = null;
		UIContext current = uic;

		while (primary == null) {
			if (current instanceof UIContextDelegate) {
				UIContext backing = ((UIContextDelegate) current).getBacking();
				if (backing != null) {
					current = backing;
				} else {
					// This case should probably never happen.
					primary = current;
					LOG.warn("UIContextDelegate found without a backing context");
				}
			} else {
				primary = current;
			}
		}

		return primary;
	}
1332128
@Override
    public <T> T getContext(Class<T> type) {
        for (Context context : contexts) {
            if (type.isInstance(context)) {
                return type.cast(context);
            }
        }
        return null;
    }
591538
public static <T> T getOrDefaultValue(String primaryKey, T defaultValue) {
        Object val = CFG.get(primaryKey);
        return val == null ? defaultValue : (T) CompatibleTypeUtils.convert(val, defaultValue.getClass());
    }
606166
function (context) {
            if (context) {
                if (this.contextBuilder) {
                    context = this.contextBuilder(context);
                }
                if (!context.scopeOrder) {
                    context.scopeOrder = this._defaults.scopeOrder;
                }
                return context;
            }
            return { scopeOrder: this._defaults.scopeOrder };
        }
1230388
def get_secondary_count(context, default=0):
    
    if not is_ar(context):
        return default

    primary = context.getPrimaryAnalysisRequest()

    if not primary:
        return default

    return len(primary.getSecondaryAnalysisRequests())
282208
public final QueryParser.primary_return primary() throws RecognitionException {
        QueryParser.primary_return retval = new QueryParser.primary_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token char_literal19=null;
        Token char_literal21=null;
        QueryParser.or_return or20 = null;

        QueryParser.simple_return simple22 = null;


        CommonTree char_literal19_tree=null;
        CommonTree char_literal21_tree=null;
        RewriteRuleTokenStream stream_25=new RewriteRuleTokenStream(adaptor,"token 25");
        RewriteRuleTokenStream stream_26=new RewriteRuleTokenStream(adaptor,"token 26");
        RewriteRuleSubtreeStream stream_or=new RewriteRuleSubtreeStream(adaptor,"rule or");
        RewriteRuleSubtreeStream stream_simple=new RewriteRuleSubtreeStream(adaptor,"rule simple");
        try {
            // src/riemann/Query.g:35:9: ( ( ( '(' or ')' ) -> ^( or ) | simple -> simple ) )
            // src/riemann/Query.g:35:12: ( ( '(' or ')' ) -> ^( or ) | simple -> simple )
            {
            // src/riemann/Query.g:35:12: ( ( '(' or ')' ) -> ^( or ) | simple -> simple )
            int alt11=2;
            int LA11_0 = input.LA(1);

            if ( (LA11_0==25) ) {
                alt11=1;
            }
            else if ( (LA11_0==TAGGED||(LA11_0>=27 && LA11_0<=38)) ) {
                alt11=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 11, 0, input);

                throw nvae;
            }
            switch (alt11) {
                case 1 :
                    // src/riemann/Query.g:36:4: ( '(' or ')' )
                    {
                    // src/riemann/Query.g:36:4: ( '(' or ')' )
                    // src/riemann/Query.g:36:5: '(' or ')'
                    {
                    char_literal19=(Token)match(input,25,FOLLOW_25_in_primary244);  
                    stream_25.add(char_literal19);

                    pushFollow(FOLLOW_or_in_primary246);
                    or20=or();

                    state._fsp--;

                    stream_or.add(or20.getTree());
                    char_literal21=(Token)match(input,26,FOLLOW_26_in_primary248);  
                    stream_26.add(char_literal21);


                    }



                    // AST REWRITE
                    // elements: or
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 36:17: -> ^( or )
                    {
                        // src/riemann/Query.g:36:20: ^( or )
                        {
                        CommonTree root_1 = (CommonTree)adaptor.nil();
                        root_1 = (CommonTree)adaptor.becomeRoot(stream_or.nextNode(), root_1);

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 2 :
                    // src/riemann/Query.g:37:6: simple
                    {
                    pushFollow(FOLLOW_simple_in_primary262);
                    simple22=simple();

                    state._fsp--;

                    stream_simple.add(simple22.getTree());


                    // AST REWRITE
                    // elements: simple
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (CommonTree)adaptor.nil();
                    // 37:13: -> simple
                    {
                        adaptor.addChild(root_0, stream_simple.nextTree());

                    }

                    retval.tree = root_0;
                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
282343
public static RequestContext get() {
        if (CURRENT_CONTEXT.get() == null) {
            synchronized (RequestContext.class) {
                if (CURRENT_CONTEXT.get() == null) {
                    createContext();
                }
            }
        }

        // ensure that RequestContextV1 is also initialized for this request
        RequestContextV1.get();

        return CURRENT_CONTEXT.get();
    }
14843
public ShowInContext getShowInContext()
	{
		IProcess process = getProcess();
		if (process == null)
		{
			return null;
		}
		IDebugTarget target = (IDebugTarget) process.getAdapter(IDebugTarget.class);
		ISelection selection = null;
		if (target == null)
		{
			selection = new TreeSelection(new TreePath(new Object[] {
					DebugPlugin.getDefault().getLaunchManager(),
					process.getLaunch(), process }));
		} else
		{
			selection = new TreeSelection(new TreePath(new Object[] {
					DebugPlugin.getDefault().getLaunchManager(),
					target.getLaunch(), target }));
		}
		return new ShowInContext(null, selection);
	}
1224944
public static <T> T getContext(ELContext context, Class<T> key) {
        return getContext(context, key, null);
    }
1038555
public Map getDestinationContext()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "getDestinationContext");
      
    Map context = foreignDest.getDefinition().getDestinationContext();
      
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "getDestinationContext", context);
      
    return context;
  }
128249
public static I_CmsContextMenuCommand getContextMenuCommand() {

        return new I_CmsContextMenuCommand() {

            public void execute(
                CmsUUID structureId,
                final I_CmsContextMenuHandler handler,
                CmsContextMenuEntryBean bean) {

                CmsConfirmDialog dialog = new CmsConfirmDialog(
                    Messages.get().key(Messages.GUI_DIALOG_LOGOUT_TITLE_0),
                    Messages.get().key(Messages.GUI_DIALOG_LOGOUT_TEXT_0));
                dialog.setOkText(Messages.get().key(Messages.GUI_YES_0));
                dialog.setCloseText(Messages.get().key(Messages.GUI_NO_0));
                dialog.setHandler(new I_CmsConfirmDialogHandler() {

                    public void onClose() {

                        // nothing to do
                    }

                    public void onOk() {

                        String logoutTarget = CmsCoreProvider.get().link(CmsCoreProvider.get().getLoginURL())
                            + "?logout=true";
                        handler.leavePage(logoutTarget);
                    }
                });
                dialog.center();
            }

            public A_CmsContextMenuItem getItemWidget(
                CmsUUID structureId,
                I_CmsContextMenuHandler handler,
                CmsContextMenuEntryBean bean) {

                return null;
            }

            public boolean hasItemWidget() {

                return false;
            }
        };
    }
606965
public static Context getContext() {
        Context context = LOCAL.get();
        if (context == null) {
            context = new Context(null, null);
            LOCAL.set(context);
        }
        return context;
    }
1279205
public String getFirst(String name, String defaultValue)
    {
        String value = getFirst(name);
        if (value == null) {
            value = defaultValue;
        }
        return value;
    }
591524
public static ControlContainerContext getContext() 
    {
        Stack<ControlContainerContext> contextStack = _threadContexts.get();
        if (contextStack == null || contextStack.size() == 0)
            return null;

        return contextStack.peek();
    }
607952
public Object getRowBeanForSubcontext(final SubUIContext subContext) {
		if (subContext.repeatRoot != getRepeatRoot()) {
			// TODO: Is this still necessary?
			throw new IllegalArgumentException("SubUIContext is not for this WRepeater instance.");
		}

		// We need to get the list using the parent context
		// so that e.g. caching in the scratch map works properly.
		UIContextHolder.pushContext(subContext.getParentContext());

		try {
			return getRowData(subContext.getRowId());
		} finally {
			UIContextHolder.popContext();
		}
	}
496561
function getReturnContext(state) {
    let context = state.tryContext;

    while (context) {
        if (context.hasFinalizer && context.position !== "finally") {
            return context;
        }
        context = context.upper;
    }

    return state;
}
375132
public DisplayContext getContext(DisplayContext.Type type) {
        return (type == DisplayContext.Type.CAPITALIZATION && capitalizationSetting != null)?
                capitalizationSetting: DisplayContext.CAPITALIZATION_NONE;
    }