當前位置: 首頁>>代碼示例>>Java>>正文


Java MetaborgRuntimeException類代碼示例

本文整理匯總了Java中org.metaborg.core.MetaborgRuntimeException的典型用法代碼示例。如果您正苦於以下問題:Java MetaborgRuntimeException類的具體用法?Java MetaborgRuntimeException怎麽用?Java MetaborgRuntimeException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MetaborgRuntimeException類屬於org.metaborg.core包,在下文中一共展示了MetaborgRuntimeException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseAll

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
/**
 * Parses the whole buffer.
 *
 * @return The parse result.
 */
private ISpoofaxParseUnit parseAll(final ISpoofaxInputUnit input) {
    final ISpoofaxParseUnit parseResult;
    final FileObject resource = input.source();
    try {
        if(!input.detached()) {
            this.parseResultProcessor.invalidate(resource);
        }

        parseResult = this.syntaxService.parse(input);

        if(!input.detached()) {
            this.parseResultProcessor.update(resource, parseResult);
        }
    } catch(final ParseException e) {
        if(!input.detached()) {
            this.parseResultProcessor.error(resource, e);
        }
        throw new MetaborgRuntimeException("Unhandled exception", e);
    }
    return parseResult;
}
 
開發者ID:metaborg,項目名稱:spoofax-intellij,代碼行數:27,代碼來源:MetaborgFileElementType.java

示例2: update

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
@Override public void update(A result, Set<FileName> removedResources) {
    if(result.detached()) {
        throw new MetaborgRuntimeException("Cannot process updates for detached (no source) units");
    }
    final FileObject resource = result.source();
    final FileName name = resource.getName();
    if(removedResources.contains(name)) {
        remove(resource);
    } else {
        logger.trace("Pushing analysis result for {}", name);
        final BehaviorSubject<AnalysisChange<A>> updates = getUpdates(name);
        updates.onNext(AnalysisChange.update(resource, result));
    }
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:15,代碼來源:AnalysisResultProcessor.java

示例3: error

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
@Override public void error(Iterable<P> results, AnalysisException exception) {
    for(P parseResult : results) {
        final FileObject resource = parseResult.source();
        if(parseResult.detached()) {
            throw new MetaborgRuntimeException("Cannot process analysis errors for detached (no source) units");
        }
        final BehaviorSubject<AnalysisChange<A>> updates = getUpdates(resource.getName());
        updates.onNext(AnalysisChange.<A>error(resource, exception));
    }
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:11,代碼來源:AnalysisResultProcessor.java

示例4: localFile

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
@Override public File localFile(FileObject resource, FileObject dir) {
    if(resource instanceof LocalFile) {
        return FileUtils.toFile(resource);
    }

    final File localDir = localPath(dir);
    if(localDir == null) {
        throw new MetaborgRuntimeException("Replication directory " + dir
            + " is not on the local filesystem, cannot get local file for " + resource);
    }
    try {
        dir.createFolder();

        final FileObject copyLoc;
        if(resource.getType() == FileType.FOLDER) {
            copyLoc = dir;
        } else {
            copyLoc = dir.resolveFile(resource.getName().getBaseName());
        }
        copyLoc.copyFrom(resource, new AllFileSelector());

        return localDir;
    } catch(FileSystemException e) {
        throw new MetaborgRuntimeException("Could not get local file for " + resource, e);
    }
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:27,代碼來源:ResourceService.java

示例5: find

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
@Nullable protected FileObject find(Iterable<FileObject> dirs, String path) {
    FileObject file = null;
    for(FileObject dir : dirs) {
        try {
            FileObject candidate = dir.resolveFile(path);
            if(candidate.exists()) {
                if(file != null) {
                    throw new MetaborgRuntimeException("Found multiple candidates for " + path);
                } else {
                    file = candidate;
                }
            }
        } catch(FileSystemException e) {
            logger.warn("Error when trying to resolve {} in {}", e, path, dir);
        }
    }
    return file;
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:19,代碼來源:CommonPaths.java

示例6: loadJars

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
private void loadJars(HybridInterpreter runtime, Iterable<FileObject> jars) throws MetaborgException {
    try {
        final URL[] classpath = new URL[Iterables.size(jars)];
        int i = 0;
        for(FileObject jar : jars) {
            final File localJar = resourceService.localFile(jar);
            classpath[i] = localJar.toURI().toURL();
            ++i;
        }
        logger.trace("Loading jar files {}", (Object) classpath);
        final ClassLoader classLoader = new StrategoRuntimeClassLoader(additionalClassLoaders);
        runtime.loadJars(classLoader, classpath);
    } catch(IncompatibleJarException | IOException | MetaborgRuntimeException e) {
        throw new MetaborgException("Failed to load JAR", e);
    }
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:17,代碼來源:StrategoRuntimeService.java

示例7: update

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
@Override public ILanguageImpl update(String name, IFacet syntaxFacet) {
    final ILanguageImpl dialect = nameToDialect.get(name);
    if(dialect == null) {
        final String message = String.format("Dialect with name %s does not exist", name);
        logger.error(message);
        throw new MetaborgRuntimeException(message);
    }
    logger.debug("Updating syntax facet for dialect {}", name);

    final FileObject location = Iterables.get(dialect.components(), 0).location();
    final ILanguageImpl newDialect = createDialect(name, location, dialect, syntaxFacet, false, false);

    nameToDialect.put(name, newDialect);

    return newDialect;
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:17,代碼來源:DialectService.java

示例8: parseAll

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
/**
 * Parses the whole buffer.
 *
 * @return The parse result.
 */
private ISpoofaxParseUnit parseAll() {
    // TODO: Optimize parsing? Is there a parse cache? I think so.
    final ISpoofaxInputUnit input =
        unitService.inputUnit(file, buffer.toString(), languageImpl, null, parserConfiguration);
    try {
        return syntaxService.parse(input);
    } catch(final ParseException e) {
        throw new MetaborgRuntimeException("Unhandled exception", e);
    }
}
 
開發者ID:metaborg,項目名稱:spoofax-intellij,代碼行數:16,代碼來源:SpoofaxHighlightingLexer.java

示例9: projectLocation

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
public FileObject projectLocation() throws MetaborgException {
    try {
        return resourceService.resolve(projectPath);
    } catch(MetaborgRuntimeException e) {
        throw new MetaborgException("Cannot resolve " + projectPath, e);
    }
}
 
開發者ID:metaborg,項目名稱:spoofax-sunshine,代碼行數:8,代碼來源:ProjectPathDelegate.java

示例10: inputResource

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
public FileObject inputResource() throws MetaborgException {
    try {
        return resourceService.resolve(inputPath);
    } catch(MetaborgRuntimeException e) {
        final String message = String.format("Cannot resolve %s", inputPath);
        throw new MetaborgException(message, e);
    }
}
 
開發者ID:metaborg,項目名稱:spoofax-sunshine,代碼行數:9,代碼來源:InputDelegate.java

示例11: projectLocation

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
public FileObject projectLocation() throws MetaborgException {
    try {
        return resourceService.resolve(projectPath);
    } catch(MetaborgRuntimeException e) {
        final String message = String.format("Cannot resolve %s", projectPath);
        throw new MetaborgException(message, e);
    }
}
 
開發者ID:metaborg,項目名稱:spoofax-sunshine,代碼行數:9,代碼來源:ProjectPathDelegate.java

示例12: multipleUnexpectedFacets

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
/**
 * Try to get a single facet, but have multiple. Assert that exception is thrown.
 */
@Test(expected = MetaborgRuntimeException.class) public void multipleUnexpectedFacets() throws Exception {
    final LanguageVersion version = version(0, 0, 1);
    final FileObject location = createDir("ram:///");

    final ILanguageComponent component = language(groupId, "org.metaborg.lang.entity", version, location, "Entity",
            new DescriptionFacet("Entity language", null), new DescriptionFacet("Entity language", null));
    component.facet(DescriptionFacet.class);
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:12,代碼來源:LanguageServiceTest.java

示例13: SpoofaxContext

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
public SpoofaxContext(FileObject baseDir, FileObject depDir) {
    if(injector == null) {
        throw new MetaborgRuntimeException("Creating context while injector has not been set");
    }

    this.baseDir = toFile(baseDir);
    this.baseURI = FileUtils.toURI(baseDir);
    this.depDir = toFile(depDir);

    init();
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:12,代碼來源:SpoofaxContext.java

示例14: init

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
public void init() {
    this.base = this.resourceService().resolve(baseURI);
    this.project = projectService.get(base);
    if(this.project == null) {
        this.languageSpec = null;
        return;
    }

    try {
        this.languageSpec = languageSpecService.get(project);
    } catch(ConfigException e) {
        throw new MetaborgRuntimeException(
            "Cannot convert project " + project + " into a language specification project", e);
    }
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:16,代碼來源:SpoofaxContext.java

示例15: invalidate

import org.metaborg.core.MetaborgRuntimeException; //導入依賴的package包/類
@Override public void invalidate(Iterable<P> results) {
    for(P parseResult : results) {
        if(parseResult.detached()) {
            throw new MetaborgRuntimeException("Cannot invalidate results for detached (no source) units");
        }
        invalidate(parseResult.source());
    }
}
 
開發者ID:metaborg,項目名稱:spoofax,代碼行數:9,代碼來源:AnalysisResultProcessor.java


注:本文中的org.metaborg.core.MetaborgRuntimeException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。