-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mmews
committed
Feb 22, 2024
1 parent
ec802a2
commit 09a612a
Showing
8 changed files
with
802 additions
and
737 deletions.
There are no files selected for viewing
480 changes: 480 additions & 0 deletions
480
plugins/org.eclipse.n4js/src/org/eclipse/n4js/postprocessing/TypeProcessor.java
Large diffs are not rendered by default.
Oops, something went wrong.
456 changes: 0 additions & 456 deletions
456
plugins/org.eclipse.n4js/src/org/eclipse/n4js/postprocessing/TypeProcessor.xtend
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSDerivedStateComputer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (c) 2016 NumberFour AG. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* NumberFour AG - Initial API and implementation | ||
*/ | ||
package org.eclipse.n4js.resource; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.n4js.ts.types.TModule; | ||
import org.eclipse.n4js.typesbuilder.N4JSTypesBuilder; | ||
import org.eclipse.xtext.resource.DerivedStateAwareResource; | ||
import org.eclipse.xtext.resource.IDerivedStateComputer; | ||
|
||
import com.google.inject.Inject; | ||
|
||
/** | ||
* Derives the types model from the AST and stores it at the second index of the resource. See {@link N4JSTypesBuilder}. | ||
*/ | ||
public class N4JSDerivedStateComputer implements IDerivedStateComputer { | ||
|
||
@Inject | ||
private N4JSUnloader n4jsUnloader; | ||
@Inject | ||
private N4JSTypesBuilder typesBuilder; | ||
|
||
/** | ||
* Creates an {@link TModule} on the second slot of the resource. when the resource contents is not empty. | ||
*/ | ||
@Override | ||
public void installDerivedState(DerivedStateAwareResource resource, boolean preLinkingPhase) { | ||
List<EObject> contents = resource.getContents(); | ||
if (contents.isEmpty()) { | ||
String msg = "cannot install derived state in resource '" + resource.getURI().toString() + "' without AST"; | ||
throw new IllegalStateException(msg); | ||
} else if (contents.size() == 1) { | ||
typesBuilder.createTModuleFromSource(resource, preLinkingPhase); | ||
} else if (contents.size() == 2) { | ||
typesBuilder.relinkTModuleToSource(resource, preLinkingPhase); | ||
} else { | ||
throw new IllegalStateException("resource '" + resource.getURI().toString() + "' with more than two roots"); | ||
} | ||
} | ||
|
||
/** | ||
* Calls {@link N4JSUnloader#unloadRoot(EObject)} for the second slot root. Then all contents of the resource are | ||
* cleared. | ||
*/ | ||
@Override | ||
public void discardDerivedState(DerivedStateAwareResource resource) { | ||
List<EObject> contents = resource.getContents(); | ||
// resource.getContents().get(1-n)clear | ||
if (contents.isEmpty()) { | ||
return; | ||
} | ||
|
||
// other resources may hold references to the derived state thus we | ||
// have to unload (proxify) it explicitly before it is removed from the resource | ||
List<EObject> tail = contents.subList(1, contents.size()); | ||
for (EObject eo : tail) { | ||
n4jsUnloader.unloadRoot(eo); | ||
} | ||
tail.clear(); | ||
} | ||
} |
62 changes: 0 additions & 62 deletions
62
plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSDerivedStateComputer.xtend
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSDescriptionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) 2016 NumberFour AG. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* NumberFour AG - Initial API and implementation | ||
*/ | ||
package org.eclipse.n4js.resource; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.eclipse.emf.common.util.URI; | ||
import org.eclipse.xtext.resource.DescriptionUtils; | ||
import org.eclipse.xtext.resource.IResourceDescription; | ||
|
||
/** | ||
*/ | ||
public class N4JSDescriptionUtils extends DescriptionUtils { | ||
|
||
@Override | ||
public Set<URI> collectOutgoingReferences(IResourceDescription description) { | ||
return new HashSet<>(); | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
plugins/org.eclipse.n4js/src/org/eclipse/n4js/resource/N4JSDescriptionUtils.xtend
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.