Commit f5057434 authored by Alexander Ryndin's avatar Alexander Ryndin
Browse files

Merge branch 'master' into ryndin

# Conflicts:
#	pom.xml
parents daa47dec 49661615
......@@ -47,7 +47,6 @@
<languages.version>4.0.1-SNAPSHOT</languages.version>
<SIUnit.version>0.1.1-fGWiGhVOHEqxe9fiCfQF6Q</SIUnit.version>
<struct.version>0.1.1-fGWiGhVOHEqxe9fiCfQF6Q</struct.version>
<Common-MontiCar.version>0.1.1-fGWiGhVOHEqxe9fiCfQF6Q</Common-MontiCar.version>
<!-- .. Libraries .................................................. -->
......@@ -180,25 +179,6 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>montiarc.languages</groupId>
<artifactId>tagging</artifactId>
<version>${languages.version}</version>
</dependency>
<dependency>
<groupId>montiarc.languages</groupId>
<artifactId>montiarc-fe</artifactId>
<version>${languages.version}</version>
</dependency>
<dependency>
<groupId>montiarc.languages</groupId>
<artifactId>montiarc-fe</artifactId>
<classifier>${grammars.classifier}</classifier>
<version>${languages.version}</version>
</dependency>
<!-- .. Test Libraries ............................................... -->
<dependency>
<groupId>junit</groupId>
......
......@@ -20,23 +20,23 @@
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.monticar.ValueSymbol;
import de.monticore.lang.embeddedmontiarc.helper.SymbolPrinter;
import de.monticore.lang.montiarc.tagging._symboltable.TaggingScopeSpanningSymbol;
import de.monticore.symboltable.types.TypeSymbol;
import de.monticore.symboltable.types.references.TypeReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import de.monticore.lang.embeddedmontiarc.helper.SymbolPrinter;
import de.monticore.lang.monticar.ValueSymbol;
import de.monticore.symboltable.CommonScopeSpanningSymbol;
import de.monticore.symboltable.types.TypeSymbol;
import de.monticore.symboltable.types.references.TypeReference;
/**
* Represents an instance of a component.
*
* @author Robert Heim
*/
public class ComponentInstanceSymbol extends TaggingScopeSpanningSymbol implements ElementInstance {
public class ComponentInstanceSymbol extends CommonScopeSpanningSymbol implements ElementInstance {
public static final EMAComponentInstanceKind KIND = EMAComponentInstanceKind.INSTANCE;
......
......@@ -25,12 +25,12 @@ import de.monticore.lang.embeddedmontiarc.EmbeddedMontiArcConstants;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc.types.EMAVariable;
import de.monticore.lang.embeddedmontiarc.helper.SymbolPrinter;
import de.monticore.lang.embeddedmontiarc.helper.Timing;
import de.monticore.lang.montiarc.tagging._symboltable.TaggingScopeSpanningSymbol;
import de.monticore.lang.monticar.common2._ast.ASTParameter;
import de.monticore.lang.monticar.mcexpressions._ast.ASTExpression;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.ts.MCFieldSymbol;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.symboltable.CommonScopeSpanningSymbol;
import de.monticore.symboltable.ImportStatement;
import de.monticore.symboltable.SymbolKind;
import de.monticore.symboltable.modifiers.AccessModifier;
......@@ -54,7 +54,7 @@ import static de.monticore.symboltable.Symbols.sortSymbolsByPosition;
*
* @author Robert Heim
*/
public class ComponentSymbol extends TaggingScopeSpanningSymbol {
public class ComponentSymbol extends CommonScopeSpanningSymbol {
public static final ComponentKind KIND = new ComponentKind();
private final List<EMAAComponentImplementationSymbol> implementations = new ArrayList<>();
......
......@@ -22,7 +22,7 @@ package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc.types.TypesPrinter;
import de.monticore.lang.embeddedmontiarc.helper.SymbolPrinter;
import de.monticore.lang.montiarc.tagging._symboltable.TaggingSymbol;
import de.monticore.symboltable.CommonSymbol;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.Splitters;
import de.se_rwth.commons.logging.Log;
......@@ -38,7 +38,7 @@ import java.util.Optional;
*
* @author Arne Haber, Michael von Wenckstern
*/
public class ConnectorSymbol extends TaggingSymbol implements ElementInstance {
public class ConnectorSymbol extends CommonSymbol implements ElementInstance {
/* generated by template symboltable.symbols.KindConstantDeclaration*/
......
......@@ -20,9 +20,9 @@
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.montiarc.montiarc._symboltable.PortKind;
import de.monticore.symboltable.SymbolKind;
public class ConstantPortKind extends PortKind {
public class ConstantPortKind implements SymbolKind {
public static final ConstantPortKind INSTANCE = new ConstantPortKind();
public ConstantPortKind(){
......
......@@ -26,7 +26,6 @@ package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
* @author Robert Heim
*/
public class EMAAComponentImplementationKind
extends de.monticore.lang.montiarc.montiarc._symboltable.AComponentImplementationKind
implements de.monticore.symboltable.SymbolKind {
public static final EMAAComponentImplementationKind INSTANCE = new EMAAComponentImplementationKind();
......
......@@ -20,13 +20,15 @@
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.symboltable.CommonSymbol;
/**
* TODO Do we really need this?
*
* @author Robert Heim
*/
public abstract class EMAAComponentImplementationSymbol
extends de.monticore.lang.montiarc.montiarc._symboltable.AComponentImplementationSymbol {
extends CommonSymbol {
public static final EMAAComponentImplementationKind KIND = EMAAComponentImplementationKind.INSTANCE;
......@@ -36,7 +38,7 @@ public abstract class EMAAComponentImplementationSymbol
* @param name
*/
public EMAAComponentImplementationSymbol(String name) {
super(name);
super(name, KIND);
}
}
......@@ -41,7 +41,7 @@ import java.util.Collection;
* TODO static methods should call a protected doMethod() to allow extending this class
* TODO the builder should also be used to create a new ComponentSymbol with a build() method
*/
public class EMAComponentBuilder extends de.monticore.lang.montiarc.montiarc._symboltable.ComponentBuilder {
public class EMAComponentBuilder {
protected static EMAComponentBuilder instance = null;
protected static EMAComponentBuilder getInstance() {
......
......@@ -26,7 +26,6 @@ package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
* @author Robert Heim
*/
public class EMAComponentInstanceKind
extends de.monticore.lang.montiarc.montiarc._symboltable.ComponentInstanceKind
implements de.monticore.symboltable.SymbolKind {
public static final EMAComponentInstanceKind INSTANCE = new EMAComponentInstanceKind();
......
......@@ -24,7 +24,6 @@
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
public class EMAConnectorKind
extends de.monticore.lang.montiarc.montiarc._symboltable.ConnectorKind
implements de.monticore.symboltable.SymbolKind {
public static final EMAConnectorKind INSTANCE = new EMAConnectorKind();
......
......@@ -20,18 +20,23 @@
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import de.monticore.symboltable.Symbol;
import de.monticore.symboltable.SymbolKind;
import de.monticore.symboltable.resolving.CommonResolvingFilter;
import de.monticore.symboltable.resolving.ResolvingFilter;
import de.monticore.symboltable.resolving.ResolvingInfo;
import java.util.*;
/**
* Created by MichaelvonWenckstern on 02.09.2016.
*/
public class EMAConnectorResolvingFilter<S extends Symbol>
extends de.monticore.lang.montiarc.montiarc._symboltable.MAConnectorResolvingFilter<S> {
extends CommonResolvingFilter<S> {
public EMAConnectorResolvingFilter(SymbolKind targetKind) {
super(targetKind);
......
......@@ -24,7 +24,6 @@
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
public class EMAExpandedComponentInstanceKind
extends de.monticore.lang.montiarc.montiarc._symboltable.ExpandedComponentInstanceKind
implements de.monticore.symboltable.SymbolKind {
public static final EMAExpandedComponentInstanceKind INSTANCE = new EMAExpandedComponentInstanceKind();
......
......@@ -51,7 +51,7 @@ import java.util.stream.Collectors;
*
* @author Robert Heim
*/
public class EMAJavaHelper extends de.monticore.lang.montiarc.montiarc._symboltable.JavaHelper {
public class EMAJavaHelper {
private final static MontiCarSymbolFactory jSymbolFactory = new MontiCarSymbolFactory();
/**
......
......@@ -20,19 +20,12 @@
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.montiarc.tagging._symboltable.TagKind;
import de.monticore.lang.montiarc.tagging._symboltable.TagSymbol;
import de.monticore.symboltable.Scope;
import java.util.Collection;
/**
* Created by kt on 27.02.2017.
*/
public interface ElementInstance {
public Collection<TagSymbol> getTags();
public <T extends TagSymbol> Collection<T> getTags(final TagKind tagKind);
public String getName();
public Scope getEnclosingScope() ;
}
......@@ -35,7 +35,7 @@ import java.util.function.Predicate;
*
* @see <a href="https://sselab.de/lab2/private/trac/MontiArc4/ticket/36">Ticket 36</a>
*/
public class EmbeddedMontiArcArtifactScope extends de.monticore.lang.montiarc.montiarc._symboltable.MontiArcArtifactScope {
public class EmbeddedMontiArcArtifactScope extends ArtifactScope {
private CommonQualifiedNamesCalculator qualifiedNamesCalculator = new CommonQualifiedNamesCalculator();
......
......@@ -23,13 +23,10 @@ package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import com.google.common.collect.ImmutableSet;
import de.monticore.ast.ASTNode;
import de.monticore.lang.monticar.ts.MontiCarTypeSymbol;
import de.monticore.lang.montiarc.tagging._symboltable.TagSymbol;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.types2._symboltable.UnitNumberResolutionSymbol;
import de.monticore.lang.monticar.si._symboltable.SIUnitRangesSymbol;
import de.monticore.lang.monticar.si._symboltable.SIUnitSymbol;
import de.monticore.lang.montiarc.tagging._symboltable.TagSymbolCreator;
import de.monticore.lang.montiarc.tagging._symboltable.TagableModelingLanguage;
import de.monticore.modelloader.ModelingLanguageModelLoader;
import de.monticore.symboltable.resolving.CommonResolvingFilter;
import de.monticore.lang.monticar.ts.MCFieldSymbol;
......@@ -43,12 +40,10 @@ import java.util.LinkedHashSet;
*
* @author Robert Heim, Michael von Wenckstern
*/
public class EmbeddedMontiArcLanguage extends EmbeddedMontiArcLanguageTOP implements TagableModelingLanguage {
public class EmbeddedMontiArcLanguage extends EmbeddedMontiArcLanguageTOP {
public static final String FILE_ENDING = "ema";
protected LinkedHashSet<TagSymbolCreator> tagSymbolCreators = new LinkedHashSet<>();
public EmbeddedMontiArcLanguage() {
super("Embedded MontiArc Language", FILE_ENDING);
}
......@@ -58,32 +53,24 @@ public class EmbeddedMontiArcLanguage extends EmbeddedMontiArcLanguageTOP implem
super.initResolvingFilters();
// is done in generated TOP-language addResolver(new
// CommonResolvingFilter<ComponentSymbol>(ComponentSymbol.class, ComponentSymbol.KIND));
addResolver(new CommonResolvingFilter<>(ComponentInstanceSymbol.KIND));
addResolver(new CommonResolvingFilter<>(PortSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(ComponentInstanceSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(PortSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(PortArraySymbol.KIND));
addResolver(new EMAConnectorResolvingFilter<>(ConnectorSymbol.KIND));
addResolver(new CommonResolvingFilter<>(ExpandedComponentInstanceSymbol.KIND));
addResolver(new CommonResolvingFilter<>(SIUnitSymbol.KIND));
addResolver(new CommonResolvingFilter<>(SIUnitRangesSymbol.KIND));
addResolver(new CommonResolvingFilter<>(MCTypeSymbol.KIND));
addResolver(new CommonResolvingFilter<>(MCFieldSymbol.KIND));
addResolver(new CommonResolvingFilter<>(JMethodSymbol.KIND));
addResolvingFilter(new EMAConnectorResolvingFilter<>(ConnectorSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(ExpandedComponentInstanceSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(SIUnitSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(SIUnitRangesSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(MCTypeSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(MCFieldSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(JMethodSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(ResolutionDeclarationSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(UnitNumberResolutionSymbol.KIND));
//addResolvingFilter(CommonResolvingFilter.create(ComponentKind.KIND));
//addResolvingFilter(CommonResolvingFilter.create(TagSymbol.KIND));
addResolvingFilter(new CommonResolvingFilter<>(MontiCarTypeSymbol.KIND));
addResolvingFilter(CommonResolvingFilter.create(MontiCarTypeSymbol.KIND));
setModelNameCalculator(new EmbeddedMontiArcModelNameCalculator());
}
public void addTagSymbolCreator(TagSymbolCreator tagSymbolCreator) {
this.tagSymbolCreators.add(tagSymbolCreator);
}
public ImmutableSet<TagSymbolCreator> getTagSymbolCreators() {
return ImmutableSet.copyOf(this.tagSymbolCreators);
}
/**
* @see de.monticore.CommonModelingLanguage#provideModelLoader()
*/
......
......@@ -20,27 +20,17 @@
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTEMACompilationUnit;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EmbeddedMontiArcModelLoaderTOP;
import de.monticore.lang.montiarc.tagging._ast.ASTTaggingUnit;
import de.monticore.lang.montiarc.tagging._parser.TaggingParser;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.ResolvingConfiguration;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.logging.Log;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EmbeddedMontiArcLanguage.TAG_FILE_ENDING;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTEMACompilationUnit;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.ResolvingConfiguration;
/**
* Created by Michael von Wenckstern on 30.05.2016.
......@@ -71,67 +61,8 @@ public class EmbeddedMontiArcModelLoader extends EmbeddedMontiArcModelLoaderTOP
for (ASTEMACompilationUnit ast : asts) {
createSymbolTableFromAST(ast, qualifiedModelName, enclosingScope, ResolvingConfiguration);
// load tags of ast
for (ASTTaggingUnit unit : loadTags(ast.getPackage(), modelPath)) {
this.getModelingLanguage().getTagSymbolCreators().stream()
.forEachOrdered(tc -> tc.create(unit, enclosingScope));
}
}
return asts;
}
protected Collection<ASTTaggingUnit> loadTags(final List<String> packageName, final ModelPath modelPath) {
// TODO use File.separator instead of "\\" or "/"
String qualifiedModelName = Joiners.DOT.join(packageName);
checkArgument(!isNullOrEmpty(qualifiedModelName));
final Collection<ASTTaggingUnit> foundModels = new ArrayList<>();
for (Path mp : getEntriesFromModelPath(modelPath)) {
for (String pN : packageName) {
final Path completePath = Paths.get(mp.toString(), pN);
final File f = completePath.toFile();
if (f != null && f.isDirectory()) {
List<String> tagFiles = Arrays.stream(f.listFiles())
.filter(s -> s.isFile())
.map(s -> s.getPath())
.filter(s -> s.endsWith(TAG_FILE_ENDING))
.collect(Collectors.toList());
tagFiles.stream().forEachOrdered(t -> {
final TaggingParser parser = new TaggingParser();
Optional<ASTTaggingUnit> ast = Optional.empty();
try {
ast = parser.parse(t);
}
catch (IOException e) {
Log.error("could not open file " + t, e);
}
if (ast.isPresent()) {
if (!completePath.endsWith(
ast.get().getPackage().stream().collect(Collectors.joining(File.separator)))) {
Path p = Paths.get(t);
String expectedPackage = mp.toUri().relativize(p.toUri()).getPath();
if (p.getParent() != null) {
expectedPackage = mp.toUri().relativize(p.getParent().toUri()).getPath();
}
expectedPackage = expectedPackage.replace(File.separator, ".").replace("/", ".");
if (expectedPackage.endsWith(".")) {
expectedPackage = expectedPackage.substring(0, expectedPackage.length() - 1);
}
Log.error(
String.format("0xAC050 package name in '%s' is wrong. package name is '%s' but should be '%s'",
t, Joiners.DOT.join(ast.get().getPackage()), expectedPackage));
}
else {
foundModels.add(ast.get());
}
}
});
}
}
}
return foundModels;
}
}
......@@ -20,13 +20,18 @@
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
import de.monticore.CommonModelNameCalculator;
import de.monticore.symboltable.SymbolKind;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.Splitters;
import java.util.*;
/**
* Helps loading inner components, by mapping their full-qualified names to the full-qualified name
* of the most outer component of the file the inner one is defined in. This way the SymTab knows
......@@ -39,7 +44,7 @@ import java.util.*;
* @author Robert Heim, Michael von Wenckstern
*/
public class EmbeddedMontiArcModelNameCalculator
extends de.monticore.lang.montiarc.montiarc._symboltable.MontiArcModelNameCalculator {
extends CommonModelNameCalculator {
@Override
public Set<String> calculateModelNames(final String name, final SymbolKind kind) {
......
......@@ -22,9 +22,10 @@
/* generated by template symboltable.SymbolKind*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.montiarc.montiarc._symboltable.PortKind;
public class EmbeddedPortKind extends PortKind {
import de.monticore.symboltable.SymbolKind;
public class EmbeddedPortKind implements SymbolKind {
public static final EmbeddedPortKind INSTANCE = new EmbeddedPortKind();
......
......@@ -22,10 +22,10 @@ package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc.types.EMAVariable;
import de.monticore.lang.embeddedmontiarc.helper.SymbolPrinter;
import de.monticore.lang.montiarc.tagging._symboltable.TaggingScopeSpanningSymbol;
import de.monticore.lang.monticar.mcexpressions._ast.ASTExpression;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution;
import de.monticore.symboltable.CommonScopeSpanningSymbol;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.types.references.ActualTypeArgument;
import de.se_rwth.commons.logging.Log;
......@@ -88,7 +88,7 @@ import java.util.stream.Collectors;
* standard symbol table mechanism
*/
public class ExpandedComponentInstanceSymbol
extends TaggingScopeSpanningSymbol implements ElementInstance {
extends CommonScopeSpanningSymbol implements ElementInstance {
public static final EMAExpandedComponentInstanceKind KIND = new EMAExpandedComponentInstanceKind();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment