Allows for reconstruction via CompositeData.

@param cd composite data
@return Scope class instance
178549
public static Scope from(CompositeData cd) {
        IScope parent = null;
        ScopeType type = ScopeType.UNDEFINED;
        String name = null;
        boolean persistent = false;
        if (cd.containsKey("parent")) {
            parent = (IScope) cd.get("parent");
        }
        if (cd.containsKey("type")) {
            type = (ScopeType) cd.get("type");
        }
        if (cd.containsKey("name")) {
            name = (String) cd.get("name");
        }
        if (cd.containsKey("persistent")) {
            persistent = (Boolean) cd.get("persistent");
        }
        return new Scope(new Builder(parent, type, name, persistent));
    }
685410
public static function scopedConstructFrom($class, $values)
    {
        if( isset( $values[ 'pk' ] ) )
            $values[ 'id' ] = $values[ 'pk' ];

        $obj = new $class(isset($values['id']) ? $values['id'] : null);
        $obj->refreshFrom($values);
        return $obj;
    }
85455
function getScopeData(session, offset) {
        var path = session.path,
            fileInfo = {
                type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
                name: path,
                offsetLines: 0,
                text: ScopeManager.filterText(session.getJavascriptText())
            };

        ScopeManager.postMessage({
            type: MessageIds.TERN_SCOPEDATA_MSG,
            fileInfo: fileInfo,
            offset: offset
        });

        var ternPromise = ScopeManager.addPendingRequest(fileInfo.name, offset, MessageIds.TERN_SCOPEDATA_MSG);

        var result = new $.Deferred();

        ternPromise.done(function (response) {
            result.resolveWith(null, [response.scope]);
        }).fail(function () {
            result.reject();
        });

        return result;
    }
886315
private Cache getScopeCache(String scope) throws InvalidScopeException {
        Cache scopeCache = scopeManager.getCache(scope);
        if (scopeCache == null) {
            throw new InvalidScopeException("The scope " + scope + " doesn't exist");
        } else {
            return scopeCache;
        }
    }
1219268
public static Map<String, IDLProxyObject> create(File file, boolean debug, File path) throws IOException {
        List<CodeDependent> cds = new ArrayList<CodeDependent>();
        return create(file, debug, path, cds, new HashSet<String>());
    }
465931
private static boolean serialClassInclude(ClassDoc cd) {
        if (cd.isEnum()) {
            return false;
        }
        try {
            cd.superclassType();
        } catch (NullPointerException e) {
            //Workaround for null pointer bug in ClassDoc.superclassType().
            return false;
        }
        if (cd.isSerializable()) {
            if (cd.tags("serial").length > 0) {
                return serialDocInclude(cd);
            } else if (cd.isPublic() || cd.isProtected()) {
                return true;
            } else {
                return false;
            }
        }
        return false;
    }
34911
public <Instance> Instance createInstance(InvocationHandler invocationHandler, CompositeType compositeType) {
        Class<?>[] classes = compositeType.getClasses();
        Constructor<?> constructor = classCache.getIfPresent(compositeType);
        if (constructor == null) {
            Class<?> type;
            try {
                type = Proxy.getProxyClass(classLoader, classes);
            } catch (IllegalArgumentException e) {
                throw new XOException("Cannot create proxy for " + compositeType + " of classes " + compositeType.getClasses(), e);
            }
            try {
                constructor = type.getConstructor(new Class<?>[] { InvocationHandler.class });
            } catch (NoSuchMethodException e) {
                throw new XOException("Cannot find constructor for " + compositeType, e);
            }
            classCache.put(compositeType, constructor);
        }
        Instance instance;
        try {
            instance = (Instance) constructor.newInstance(invocationHandler);
        } catch (Exception e) {
            throw new XOException("Cannot create instance of  " + compositeType, e);
        }
        return interceptorFactory.addInterceptor(instance, classes);
    }
1086778
private void initFinalPositionAndOffset(BufferObjectDataInput in, ClassDefinition cd) {
        int fieldCount;
        try {
            // final position after portable is read
            finalPosition = in.readInt();
            fieldCount = in.readInt();
        } catch (IOException e) {
            throw new HazelcastSerializationException(e);
        }
        if (fieldCount != cd.getFieldCount()) {
            throw new IllegalStateException("Field count[" + fieldCount + "] in stream does not match " + cd);
        }
        offset = in.position();
    }
1047088
public Options getOptionsFor(ClassDoc cd) {
	Options localOpt = getGlobalOptions();
	overrideForClass(localOpt, cd);
	localOpt.setOptions(cd);
	return localOpt;
    }
323047
protected static function selectOverrideScope( $scope, $identifier, $dir, $default )
    {
        if ( $scope !== null )
        {
            $def = self::defaultOverrideDirs();
            if ( isset( $def[$scope] ) )
                return $scope;
            eZDebug::writeWarning( "Undefined override dir scope: '$scope' with dir: '$dir'", __METHOD__ );
        }
        if ( $identifier === 'siteaccess' )
            return 'siteaccess';
        else if ( $identifier && strpos($identifier, 'extension:') === 0 )
            return 'extension';
        else if ( strpos($dir, 'siteaccess') !== false )
            return 'siteaccess';
        else if ( strpos($dir, 'extension') !== false )
            return 'extension';

        eZDebug::writeStrict( "Could not figgure out INI scope for \$identifier: '$identifier' with \$dir: '$dir', falling back to '$default'", __METHOD__ );
        return $default;
    }
1364923
private SortedSet<ClassDoc> get(Map<ClassDoc, SortedSet<ClassDoc>> map, ClassDoc cd) {
        SortedSet<ClassDoc> aset = map.get(cd);
        if (aset == null) {
            return new TreeSet<>(comparator);
        }
        return aset;
    }
1251876
private Collection<ClassDoc> implementingClasses(ClassDoc cd) {
        Collection<ClassDoc> ret = classToImplementingClass.get(cd.qualifiedName());
        if (ret == null) {
            ret = new TreeSet<ClassDoc>();
            List<ClassDoc> impl = classtree.implementingclasses(cd);
            if (impl != null) {
                ret.addAll(impl);
                for (Iterator<ClassDoc> it = impl.iterator(); it.hasNext();) {
                    ret.addAll(subclasses(it.next()));
                }
            }
            for (Iterator<ClassDoc> it = subinterfaces(cd).iterator(); it.hasNext();) {
                ret.addAll(implementingClasses(it.next()));
            }
            addAll(classToImplementingClass, cd, ret);
        }
        return ret;
    }
153489
public final S getClosestContainerScope() {
    S scope = getClosestHoistScope();
    if (scope.isBlockScope()) {
      scope = scope.getParent();
      checkState(!scope.isBlockScope());
    }
    return scope;
  }
641387
public Detail read (String category, String discid)
        throws IOException, CDDBException
    {
        // sanity check
        if (_sock == null) {
            throw new CDDBException(500, "Not connected");
        }

        // construct the query
        StringBuilder req = new StringBuilder("cddb read ");
        req.append(category).append(" ");
        req.append(discid);

        // make the request
        Response rsp = request(req.toString());
        // anything other than an OK response earns an exception
        if (rsp.code != 210 /* OK, entry follows */) {
            throw new CDDBException(rsp.code, rsp.message);
        }

        Detail detail = new Detail();

        // parse the category and discid from the response string
        int sidx = rsp.message.indexOf(" ");
        if (sidx == -1) {
            throw new CDDBException(500, "Malformed read response: " +
                                    rsp.message);
        }
        detail.category = rsp.message.substring(0, sidx);
        detail.discid = rsp.message.substring(sidx+1);

        ArrayList<String> tnames = new ArrayList<String>();
        ArrayList<String> texts = new ArrayList<String>();

        // now parse the contents
        String input = _in.readLine();
        for (int lno = 0; !input.equals(CDDBProtocol.TERMINATOR); lno++) {
            if (input.startsWith("#")) {
                // skip comments

            } else if (input.startsWith("DTITLE")) {
                if (detail.title == null) {
                    detail.title = contents(input, lno);
                } else {
                    detail.title += contents(input, lno);
                }

            } else if (input.startsWith("DYEAR")) {
                String yearStr = contents(input, lno);
                try {
                    detail.year = Integer.parseInt(yearStr);
                } catch (NumberFormatException nfEx) {
                    detail.year = -1;
                }

            } else if (input.startsWith("DGENRE")) {
                if (detail.genre == null) {
                    detail.genre = contents(input, lno);
                } else {
                    detail.genre += contents(input, lno);
                }

            } else if (input.startsWith("EXTD")) {
                if (detail.extendedData == null) {
                    detail.extendedData = contents(input, lno);
                } else {
                    detail.extendedData += contents(input, lno);
                }

            } else if (input.startsWith("TTITLE")) {
                append(tnames, index(input, "TTITLE", lno), contents(input, lno));

            } else if (input.startsWith("EXTT")) {
                append(texts, index(input, "EXTT", lno), contents(input, lno));
            }

            // read in the next line of input
            input = _in.readLine();
        }

        // convert the lists into arrays
        detail.trackNames = new String[tnames.size()];
        tnames.toArray(detail.trackNames);
        detail.extendedTrackData = new String[texts.size()];
        texts.toArray(detail.extendedTrackData);

        return detail;
    }
103491
@Override
    public CompletableFuture<CreateScopeStatus> createScope(final String scopeName) {
        return getScope(scopeName).createScope().handle((result, ex) -> {
            if (ex == null) {
                return CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.SUCCESS).build();
            }
            if (ex instanceof StoreException.DataExistsException ||
                    ex.getCause() instanceof StoreException.DataExistsException) {
                return CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.SCOPE_EXISTS).build();
            } else {
                log.debug("Create scope failed due to ", ex);
                return CreateScopeStatus.newBuilder().setStatus(CreateScopeStatus.Status.FAILURE).build();
            }
        });
    }
461432
public static DocPath forPackage(ClassDoc cd) {
        return (cd == null) ? empty : forPackage(cd.containingPackage());
    }
121505
AttrContext dup(Scope scope) {
        AttrContext info = new AttrContext();
        info.scope = scope;
        info.staticLevel = staticLevel;
        info.isSelfCall = isSelfCall;
        info.selectSuper = selectSuper;
        info.pendingResolutionPhase = pendingResolutionPhase;
        info.lint = lint;
        info.enclVar = enclVar;
        info.returnResult = returnResult;
        info.defaultSuperCallSite = defaultSuperCallSite;
        info.isSerializable = isSerializable;
        info.preferredTreeForDiagnostics = preferredTreeForDiagnostics;
        return info;
    }