This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,6 +1,5 @@
package edu.clemson.resolve.jetbrains;


import com.intellij.notification.NotificationGroup;
import org.jetbrains.annotations.NonNls;

@@ -32,28 +32,21 @@ public class RESOLVEParserDefinition implements ParserDefinition {

public static final IElementType WS = new ResTokenType("RESOLVE_WHITESPACE");
public static final IElementType NLS = new ResTokenType("RESOLVE_WS_NEW_LINES");

public static final TokenSet WHITESPACES = TokenSet.create(WS, NLS);
public static final TokenSet COMMENTS = TokenSet.create(LINE_COMMENT, MULTILINE_COMMENT);
public static final TokenSet STRING_LITERALS = TokenSet.create(STRING, RAW_STRING, CHAR);
public static final TokenSet NUMBERS = TokenSet.create(INT);

public static final TokenSet KEYWORDS = TokenSet.create(
BASE, BY, CART_PROD, CHANGING, CONCEPT, CONSTRAINTS, CONVENTIONS,
CORRESPONDENCE, DECREASING, DEFINITION, DO, ELSE, END, ENSURES, EXEMPLAR,
EXISTS, EXTENSION, EXTERNALLY, FACILITY, FAMILY, FAMILY_TYPE, FOR,
FORALL, HYPO, IF, IMPLEMENTATION, IMPLEMENTED, INDUCTIVE,
INITIALIZATION, IS, LAMBDA, MAINTAINING, MODELED, OPERATION, OF,
OTHERWISE, PARAM_TYPE, PRECIS, PROCEDURE, PROG_IF, RECORD,
RECURSIVE, REQUIRES, THEN, USES, VAR, WHICH_ENTAILS, WHILE, WITH,
CATEGORICAL, IMPLICIT, THEOREM, COROLLARY, EXTENDED);

public static final TokenSet OPERATORS = TokenSet.create(AT,
EQUALS, NEQUALS, AND, OR, NOT, CAT, LESS_OR_EQUAL, LESS,
GREATER_OR_EQUAL, GREATER, MOD, MUL, QUOTIENT, PLUS, MINUS,
COLON_EQUALS, COLON_EQUALS_COLON, RARROW,
TILDE, UNION, INTERSECT, IS_IN, IS_NOT_IN, BAR, DBL_BAR, IFF,
IMPLIES, TRUE, FALSE);

public static final TokenSet KEYWORDS = TokenSet.create(BASE, BY, CART_PROD, CHANGING, CONCEPT, CONSTRAINTS,
CONVENTIONS, CORRESPONDENCE, DECREASING, DEFINITION, DO, ELSE, END, ENSURES, EXEMPLAR, EXISTS, EXTENSION,
EXTERNALLY, FACILITY, FAMILY, FAMILY_TYPE, FOR, FORALL, FROM, HYPO, IF, IMPLEMENTATION, IMPLEMENTED,
INDUCTIVE, INITIALIZATION, IS, LAMBDA, MAINTAINING, MODELED, OPERATION, OF, OTHERWISE, PARAM_TYPE, PRECIS,
PROCEDURE, PROG_IF, RECORD, RECURSIVE, REQUIRES, THEN, USES, VAR, WHICH_ENTAILS, WHILE, WITH, CATEGORICAL,
IMPLICIT, THEOREM, COROLLARY, EXTENDED);
//TODO: Builtin unicode ops need adding here.
public static final TokenSet OPERATORS = TokenSet.create(AT, EQUALS, NEQUALS, AND, OR, NOT, CAT, LESS_OR_EQUAL,
LESS, GREATER_OR_EQUAL, GREATER, MOD, MUL, QUOTIENT, PLUS, MINUS, COLON_EQUALS, COLON_EQUALS_COLON, RARROW,
TILDE, UNION, INTERSECT, IS_IN, IS_NOT_IN, BAR, DBL_BAR, IFF, IMPLIES, TRUE, FALSE);
public static final TokenSet PARAMETER_MODES = TokenSet.create(ALTERS,
UPDATES, CLEARS, RESTORES, PRESERVES, REPLACES, EVALUATES);

@@ -186,7 +186,7 @@
extends("Math.*(DefnDecl)")="edu.clemson.resolve.jetbrains.psi.impl.ResAbstractMathDefnImpl"
extends("Math.*(Sig)")="edu.clemson.resolve.jetbrains.psi.impl.ResAbstractMathSigImpl"
extends(".*ModuleDecl")="edu.clemson.resolve.jetbrains.psi.impl.ResAbstractModuleImpl"
extends(".*((Var|Param|Field)Def|(MathTheorem|TypeParam|Operation|Procedure|OperationProcedure|Exemplar|Facility)Decl)|ModuleSpec|UsesSpec")="edu.clemson.resolve.jetbrains.psi.impl.ResNamedElementImpl"
extends(".*((Var|Param|Field)Def|(MathTheorem|TypeParam|Operation|Procedure|OperationProcedure|Exemplar|Facility)Decl)|ModuleSpec|ModuleIdentifier")="edu.clemson.resolve.jetbrains.psi.impl.ResNamedElementImpl"
extends("(TypeModel|TypeRepr)Decl")="edu.clemson.resolve.jetbrains.psi.impl.ResAbstractTypeLikeNodeImpl"
extends("OrInfixExp|SelectorExp")=InfixExp
extends("Math((Minus|Cat|Range|Plus|Div|Mult|Custom)InfixApplyExp|SelectorExp)")=MathInfixApplyExp // this attributes can be placed directly after rule
@@ -197,7 +197,7 @@
implements("OperationDecl|OperationProcedureDecl")="edu.clemson.resolve.jetbrains.psi.ResOperationLikeNode"
implements(".*ReferenceExp")="edu.clemson.resolve.jetbrains.psi.ResReferenceExpBase"
implements("(Spec|Impl)ModuleParameters")="edu.clemson.resolve.jetbrains.psi.ResModuleParameters"
implements(".*((Var|Param|Field)Def|(MathTheorem|TypeParam|Exemplar|Facility)Decl|UsesSpec)")="edu.clemson.resolve.jetbrains.psi.ResNamedElement"
implements(".*((Var|Param|Field)Def|(MathTheorem|TypeParam|Exemplar|Facility)Decl|ModuleIdentifier)")="edu.clemson.resolve.jetbrains.psi.ResNamedElement"
implements("(TypeModel|TypeRepr)Decl")="edu.clemson.resolve.jetbrains.psi.ResTypeLikeNodeDecl"
implements(".*Block")="edu.clemson.resolve.jetbrains.psi.ResBlock"

@@ -256,15 +256,17 @@ FacilityBlock

UsesList ::= 'uses' (UsesSpecGroup | '(' UsesSpecGroup+ ')' ';' )

UsesSpecGroup ::= ModuleIdentList ('from' ModuleIdentifier)? ';' {pin=1} //TODO: use the getAlias method here
UsesSpecGroup ::= ModuleIdentList ('from' ModuleIdentifier)? ';' {
pin=1 methods=[getFromModuleIdentifier /*TODO: getAlias()*/]
}

private ModuleIdentList ::= ModuleIdentifier (',' ModuleIdentifier)* {
/*methods=[getAlias getLocalPackageName shouldGoDeeper getPath getName]*/
recoverWhile=ModuleIdentListRec
}
private ModuleIdentListRec ::= !(';'|')'|'from'|'end')

ModuleIdentifier ::= identifier /*{methods=[getReferences resolve getPath getPathTextRange]}*/
ModuleIdentifier ::= identifier {methods=[getReferences resolve]}

// Module blocks & items

@@ -2,7 +2,10 @@

import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.RecursionManager;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceOwner;
import com.intellij.psi.impl.source.resolve.reference.impl.providers.PsiFileReference;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.scope.PsiScopeProcessor;
import com.intellij.psi.util.CachedValueProvider;
@@ -12,6 +15,7 @@
import com.intellij.util.containers.ContainerUtil;
import edu.clemson.resolve.jetbrains.ResTypes;
import edu.clemson.resolve.jetbrains.psi.*;
import edu.clemson.resolve.jetbrains.psi.impl.imports.ResModuleIdentifierReferenceSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@@ -33,7 +37,7 @@ public static TextRange getModuleSpecTextRange(@NotNull ResModuleSpec moduleSpec
}
@NotNull
public static TextRange getPathTextRange(@NotNull ResUsesString usesString) {
public static TextRange getTextRange(@NotNull ResUsesString usesString) {
String text = usesString.getText();
return !text.isEmpty() && isQuote(text.charAt(0)) ?
TextRange.create(1, text.length() - 1) : TextRange.EMPTY_RANGE;
@@ -64,53 +68,26 @@ public static boolean shouldGoDeeper(@SuppressWarnings("UnusedParameters") ResUs
private static boolean isQuote(char q) {
return q == '"';
}
@Nullable
public static PsiElement resolve(@NotNull ResUsesString importString) {
PsiReference[] references = importString.getReferences();
for (PsiReference reference : references) {
if (reference instanceof FileReferenceOwner) {
PsiFileReference lastFileReference =
((FileReferenceOwner) reference).getLastFileReference();
PsiElement result = lastFileReference != null ?
lastFileReference.resolve() : null;
return (result instanceof PsiDirectory) || (result instanceof ResFile) ? result : null;
}
}
return null;
}
@NotNull
public static PsiReference[] getReferences(@NotNull ResUsesString o) {
if (o.getTextLength() < 2) return PsiReference.EMPTY_ARRAY;
return new ResUsesReferenceSet(o).getAllReferences();
}
@NotNull
public static String getPath(@NotNull ResUsesString o) {
return unquote(o.getText());
}
}*/

@NotNull
private static String unquote(@Nullable String s) {
if (StringUtil.isEmpty(s)) return "";
char quote = s.charAt(0);
int startOffset = isQuote(quote) ? 1 : 0;
int endOffset = s.length();
if (s.length() > 1) {
char lastChar = s.charAt(s.length() - 1);
if (isQuote(quote) && lastChar == quote) {
endOffset = s.length() - 1;
}
if (!isQuote(quote) && isQuote(lastChar)) {
endOffset = s.length() - 1;
}
@Nullable
public static PsiElement resolve(@NotNull ResModuleIdentifier identifierString) {
PsiReference[] references = identifierString.getReferences();
for (PsiReference reference : references) {
if (reference instanceof FileReferenceOwner) {
PsiFileReference lastFileReference = ((FileReferenceOwner) reference).getLastFileReference();
PsiElement result = lastFileReference != null ? lastFileReference.resolve() : null;
return (result instanceof PsiDirectory) || (result instanceof ResFile) ? result : null;
}
return s.substring(startOffset, endOffset);
}
return null;
}

@NotNull
public static PsiReference[] getReferences(@NotNull ResModuleIdentifier o) {
return new ResModuleIdentifierReferenceSet(o).getAllReferences();
}
/*
@Nullable
public static ResFile getSpecification(ResFacilityDecl o) {
if (o.getModuleSpecList().isEmpty()) return null;
@@ -120,6 +97,14 @@ public static ResFile getSpecification(ResFacilityDecl o) {
return (ResFile) specFile;
}
*/

@Nullable
public static ResModuleIdentifier getFromModuleIdentifier(@NotNull ResUsesSpecGroup o) {
if (o.getFrom() == null) return null;
int last = o.getModuleIdentifierList().size() - 1;
return o.getModuleIdentifierList().get(last);
}

@NotNull
public static PsiElement getIdentifier(ResMathReferenceExp o) {
return PsiTreeUtil.getChildOfType(o, ResMathSymbolName.class);
@@ -11,6 +11,7 @@
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.OrderedSet;
import edu.clemson.resolve.jetbrains.psi.*;
import edu.clemson.resolve.semantics.ModuleIdentifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@@ -245,14 +246,30 @@ static boolean processFilesInSpecifiedUsesDirectories(@NotNull ResFile file,
@NotNull ResScopeProcessor processor,
@NotNull ResolveState state) {
List<ResUsesSpecGroup> groups = file.getUsesSpecGroups();
for (ResUsesSpecGroup usesGroup : groups) {
for (ResUsesSpecGroup group : groups) {
//we need to search the appropriate componentDir to find the module referenced by ResModuleIdentifier
//if from is not null, then it's safe to say the last ModuleIdentifier in the list is the one that
//identifies the directory/component we ultimately want to search
//PsiDirectory componentResolveDir = importString.resolve();
ResModuleIdentifier from = group.getFromModuleIdentifier();
if (from != null) {
PsiElement resolveDir = from.resolve();
//if the 'from' module identifier doesn't resolve back to a PSI directory (AND that directory
//isn't a root library component!) then skip to the next one, the user screwed up.
/*if (!(resolveDir instanceof PsiDirectory)) {
from = null;
continue;
}*/
int i;
i=0;
}
for (ResModuleIdentifier identifier : group.getModuleIdentifierList()) {
}
}
//for (Map.Entry<String, Collection<ResUsesSpec>> entry : file.getImportMap().entrySet()) {
/* for (ResUsesSpec o : file.getUsesSpecGroups()) {
ResUsesString importString = o.getUsesString();
if (o.getAlias() == null) {
//ok, if i just give the thing the ResFile, it won't get added
// (as it doesn't extend ResNamedElement)
PsiElement resolve = importString.resolve();
Set<ResModuleDecl> accessibleModules = new LinkedHashSet<>();
@@ -21,9 +21,9 @@
* <p>
* <a href="https://github.com/go-lang-plugin-org/go-lang-idea-plugin">https://github.com/go-lang-plugin-org/go-lang-idea-plugin/a>
*/
public class ResUsesReference extends FileReference {
public class ResModuleIdentifierReference extends FileReference {

public ResUsesReference(@NotNull FileReferenceSet fileReferenceSet, TextRange range, int index, String text) {
public ResModuleIdentifierReference(@NotNull FileReferenceSet fileReferenceSet, TextRange range, int index, String text) {
super(fileReferenceSet, range, index, text);
}

@@ -50,10 +50,12 @@ protected ResolveResult[] innerResolve(boolean caseSensitive,
for (ResolveResult resolveResult : innerResult) {
PsiElement element = resolveResult.getElement();
if (element instanceof PsiDirectory || element instanceof ResFile) {
if (isLast()) {
return new ResolveResult[]{resolveResult};
}
result.add(resolveResult);
return new ResolveResult[]{resolveResult};

/** if (isLast()) {
return new ResolveResult[]{resolveResult};
}**/
//result.add(resolveResult);
}

}
@@ -66,8 +68,7 @@ protected ResolveResult[] innerResolve(boolean caseSensitive,
@Override
protected Object createLookupItem(PsiElement candidate) {
if (candidate instanceof PsiDirectory) {
return RESOLVECompletionUtil
.createDirectoryLookupElement((PsiDirectory) candidate);
return RESOLVECompletionUtil.createDirectoryLookupElement((PsiDirectory) candidate);
}
return super.createLookupItem(candidate);
}
@@ -30,8 +30,8 @@
public class ResModuleIdentifierReferenceSet extends FileReferenceSet {

public ResModuleIdentifierReferenceSet(@NotNull ResModuleIdentifier moduleIdentifier) {
super(moduleIdentifier.getIdentifier().getText(), moduleIdentifier,
moduleIdentifier.getStartOffsetInParent(), null, true);
super(moduleIdentifier.getText(), moduleIdentifier,
moduleIdentifier.getTextRange().getStartOffset(), null, true);
}

@NotNull
@@ -65,6 +65,6 @@ public PsiFileSystemItem resolve() {
@NotNull
@Override
public FileReference createFileReference(TextRange range, int index, String text) {
return new ResUsesReference(this, range, index, text);
return new ResModuleIdentifierReference(this, range, index, text);
}
}