Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge with master #221

Merged
merged 8 commits into from
Apr 10, 2015
4 changes: 2 additions & 2 deletions gen/com/intellij/plugins/haxe/lang/parser/HaxeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -5295,19 +5295,19 @@ static boolean topLevel(PsiBuilder b, int l) {

/* ********************************************************** */
// classDeclaration
// | interfaceDeclaration
// | externClassDeclaration
// | abstractClassDeclaration
// | interfaceDeclaration
// | enumDeclaration
// | typedefDeclaration
static boolean topLevelDeclaration(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "topLevelDeclaration")) return false;
boolean r;
Marker m = enter_section_(b);
r = classDeclaration(b, l + 1);
if (!r) r = interfaceDeclaration(b, l + 1);
if (!r) r = externClassDeclaration(b, l + 1);
if (!r) r = abstractClassDeclaration(b, l + 1);
if (!r) r = interfaceDeclaration(b, l + 1);
if (!r) r = enumDeclaration(b, l + 1);
if (!r) r = typedefDeclaration(b, l + 1);
exit_section_(b, m, null, r);
Expand Down
2 changes: 1 addition & 1 deletion grammar/haxe.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ private importStatementAll ::= importStatementWithWildcard | importStatementWith
usingStatement ::= 'using' simpleQualifiedReferenceExpression ';' {pin=1}

private topLevelDeclaration ::= classDeclaration
| interfaceDeclaration
| externClassDeclaration
| abstractClassDeclaration
| interfaceDeclaration
| enumDeclaration
| typedefDeclaration

Expand Down
6 changes: 4 additions & 2 deletions src/com/intellij/plugins/haxe/HaxeComponentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ public static HaxeComponentType typeOf(PsiElement element) {
element instanceof HaxeFunctionLiteral) {
return FUNCTION;
}
if (element instanceof HaxeVarDeclarationPart ||
if (element instanceof HaxeVarDeclaration ||
element instanceof HaxeVarDeclarationPart ||
element instanceof HaxeEnumValueDeclaration ||
element instanceof HaxeAnonymousTypeField) {
return FIELD;
}
if (element instanceof HaxeLocalVarDeclarationPart ||
if (element instanceof HaxeLocalVarDeclaration ||
element instanceof HaxeLocalVarDeclarationPart ||
element instanceof HaxeForStatement) {
return VARIABLE;
}
Expand Down
14 changes: 9 additions & 5 deletions src/com/intellij/plugins/haxe/compilation/HaxeCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkAdditionalData;
import com.intellij.openapi.roots.CompilerModuleExtension;
Expand Down Expand Up @@ -136,9 +137,7 @@ private static ProcessingItem[] run(CompileContext context,
}
HaxeCommonCompilerUtil.CompilationContext compilationContext = createCompilationContext(context, module, configuration);



if (compileModule(context, compilationContext)) {
if (compileModule(context, module, compilationContext)) {
final int index = findProcessingItemIndexByModule(items, configuration.getConfigurationModule());
if (index != -1) {
return new ProcessingItem[]{items[index]};
Expand All @@ -154,21 +153,26 @@ private static ProcessingItem[] make(CompileContext context, ProcessingItem[] it
continue;
}
final MyProcessingItem myProcessingItem = (MyProcessingItem)processingItem;
if (compileModule(context, createCompilationContext(context, myProcessingItem.myModule, null))) {
if (compileModule(context, myProcessingItem.myModule, createCompilationContext(context, myProcessingItem.myModule, null))) {
result.add(processingItem);
}
}
return result.toArray(new ProcessingItem[result.size()]);
}

private static boolean compileModule(final CompileContext context, @NotNull final HaxeCommonCompilerUtil.CompilationContext compilationContext) {
private static boolean compileModule(final CompileContext context,
Module module,
@NotNull final HaxeCommonCompilerUtil.CompilationContext compilationContext) {

/*
if ((skipBuildMap.get(module) != null) && (skipBuildMap.get(module).booleanValue())) {
return false;
}
*/

if (!ModuleUtil.getModuleType(module).equals(HaxeModuleType.getInstance())) {
return true;
}

boolean compiled = HaxeCommonCompilerUtil.compile(compilationContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ protected List<PsiElement> getOccurrences(PsiElement element, @NotNull final Hax
context = PsiTreeUtil.getParentOfType(context, HaxeComponent.class, true);
type = HaxeComponentType.typeOf(context);
}
while (type != null && notFunctionMethodClass(type));
while (type != null && notFunctionMethodClass(type)); // XXX-EBatTiVo: Probably should not stop if type == null.
if (context == null) {
context = expression.getContainingFile();
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/intellij/plugins/haxe/lang/psi/HaxeComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
/**
* @author: Fedor.Korotkov
*/
public interface HaxeComponent extends HaxePsiCompositeElement, PsiNamedElement, HaxeNamedComponent {
public interface HaxeComponent extends HaxeNamedComponent, PsiNamedElement {
}
12 changes: 11 additions & 1 deletion src/com/intellij/plugins/haxe/lang/psi/HaxePsiField.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,15 @@
/**
* Created by srikanthg on 10/9/14.
*/
public interface HaxePsiField extends HaxeNamedComponent, PsiField {
//
// NOTE: This class MUST derive from HaxeComponent -- not HaxeNamedComponent for
// certain refactorings (that use HaxeQualifiedNameProvider) to work correctly.
// If the derivation changes, an exception is thrown out of than class, and
// refactorings requiring names silently fail (becase of a cast exception).
// See testSrc/com/intellij/plugins/haxe/ide/refactoring/introduce/HaxeIntroduceVariableTest#ReplaceAll3()
//
// |||||||||||||
// vvvvvvvvvvvvv
public interface HaxePsiField extends HaxeComponent, PsiField {

}
79 changes: 52 additions & 27 deletions src/com/intellij/plugins/haxe/lang/psi/HaxeResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,33 +106,6 @@ public List<? extends PsiElement> resolve(@NotNull HaxeReference reference, bool

PsiFile psiFile = reference.getContainingFile();

List<PsiElement> importStatementWithWildcardList = ContainerUtil.findAll(psiFile.getChildren(), new Condition<PsiElement>() {
@Override
public boolean value(PsiElement element) {
return element instanceof HaxeImportStatementWithWildcard &&
UsefulPsiTreeUtil.isImportStatementWildcardForType(UsefulPsiTreeUtil.getQNameForImportStatementWithWildcardType(
(HaxeImportStatementWithWildcard)element));
}
});

for (PsiElement importStatementWithWildcard : importStatementWithWildcardList) {
HaxeImportStatementWithWildcard importStatementWithWildcard1 = (HaxeImportStatementWithWildcard)importStatementWithWildcard;
String qNameForImportStatementWithWildcardType =
UsefulPsiTreeUtil.getQNameForImportStatementWithWildcardType(importStatementWithWildcard1);

HaxeClass haxeClass = HaxeResolveUtil.findClassByQName(qNameForImportStatementWithWildcardType, importStatementWithWildcard1.getContext());

if (haxeClass != null) {
String referenceText = reference.getText();
HaxeNamedComponent namedSubComponent = HaxeResolveUtil.findNamedSubComponent(haxeClass, referenceText);

if (namedSubComponent != null && namedSubComponent.isStatic()) {
result.add(namedSubComponent.getComponentName().getIdentifier());
return result;
}
}
}

if (reference instanceof HaxeReferenceExpression) {
String text1 = reference.getText();
PsiElement element = null;
Expand Down Expand Up @@ -175,6 +148,58 @@ public boolean value(PsiElement element) {
}
}

List<PsiElement> importStatementWithWildcardList = ContainerUtil.findAll(psiFile.getChildren(), new Condition<PsiElement>() {
@Override
public boolean value(PsiElement element) {
return element instanceof HaxeImportStatementWithWildcard &&
UsefulPsiTreeUtil.isImportStatementWildcardForType(UsefulPsiTreeUtil.getQNameForImportStatementWithWildcardType(
(HaxeImportStatementWithWildcard)element));
}
});

for (PsiElement importStatementWithWildcard : importStatementWithWildcardList) {
HaxeImportStatementWithWildcard importStatementWithWildcard1 = (HaxeImportStatementWithWildcard)importStatementWithWildcard;
String qNameForImportStatementWithWildcardType =
UsefulPsiTreeUtil.getQNameForImportStatementWithWildcardType(importStatementWithWildcard1);

HaxeClass haxeClass = HaxeResolveUtil.findClassByQName(qNameForImportStatementWithWildcardType, importStatementWithWildcard1.getContext());

if (haxeClass != null) {
String referenceText = reference.getText();
HaxeNamedComponent namedSubComponent = HaxeResolveUtil.findNamedSubComponent(haxeClass, referenceText);

if (namedSubComponent != null && namedSubComponent.isStatic()) {
result.add(namedSubComponent.getComponentName().getIdentifier());
return result;
}
}
}

List<PsiElement> importStatementWithInSupportList = ContainerUtil.findAll(psiFile.getChildren(), new Condition<PsiElement>() {
@Override
public boolean value(PsiElement element) {
if (element instanceof HaxeImportStatementWithInSupport) {
PsiElement resolve;
HaxeReferenceExpression referenceExpression = ((HaxeImportStatementWithInSupport)element).getReferenceExpression();
resolve = referenceExpression.resolve();

if (resolve != null) {
return resolve instanceof PsiMethod;
}
}
return false;
}
});

HaxeImportStatementWithInSupport importStatementWithInSupport;
for (int i = 0; i < importStatementWithInSupportList.size(); i++) {
importStatementWithInSupport = (HaxeImportStatementWithInSupport)importStatementWithInSupportList.get(i);
if (reference.getText().equals(importStatementWithInSupport.getIdentifier().getText())) {
result.add(importStatementWithInSupport.getReferenceExpression().resolve());
return result;
}
}

return ContainerUtil.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,6 @@ public PsiClass getContainingClass() {
return PsiTreeUtil.getParentOfType(this, HaxeClass.class, true);
}

@Override
public PsiElement getContext() {
final PsiClass cc = getContainingClass();
return cc != null ? cc : super.getContext();
}

@NotNull
@Override
public MethodSignature getSignature(@NotNull PsiSubstitutor substitutor) {
Expand Down