diff --git a/src/schemely/actions/SchemeTemplatesFactory.java b/src/schemely/actions/SchemeTemplatesFactory.java index cf38b00..e703e39 100644 --- a/src/schemely/actions/SchemeTemplatesFactory.java +++ b/src/schemely/actions/SchemeTemplatesFactory.java @@ -16,11 +16,6 @@ public class SchemeTemplatesFactory implements FileTemplateGroupDescriptorFactor { @NonNls private static final String SCHEME_FILE = "SchemeFile.scm"; - @NonNls - static final String NAME_TEMPLATE_PROPERTY = "NAME"; - @NonNls - static final String LOW_CASE_NAME_TEMPLATE_PROPERTY = "lowCaseName"; - public FileTemplateGroupDescriptor getFileTemplatesDescriptor() { @@ -31,36 +26,4 @@ public FileTemplateGroupDescriptor getFileTemplatesDescriptor() group.addTemplate(new FileTemplateDescriptor(SCHEME_FILE, SchemeIcons.SCHEME_ICON)); return group; } - - public static PsiFile createFromTemplate(PsiDirectory directory, - String name, - String fileName, - String templateName, - @NonNls String... parameters) throws IncorrectOperationException - { - FileTemplate template = FileTemplateManager.getInstance().getInternalTemplate(templateName); - Properties properties = new Properties(FileTemplateManager.getInstance().getDefaultProperties()); - JavaTemplateUtil.setPackageNameAttribute(properties, directory); - properties.setProperty(NAME_TEMPLATE_PROPERTY, name); - properties.setProperty(LOW_CASE_NAME_TEMPLATE_PROPERTY, name.substring(0, 1).toLowerCase() + name.substring(1)); - for (int i = 0; i < parameters.length; i += 2) - { - properties.setProperty(parameters[i], parameters[i + 1]); - } - String text; - try - { - text = template.getText(properties); - } - catch (Exception e) - { - throw new RuntimeException("Unable to load template for " + - FileTemplateManager.getInstance().internalTemplateToSubject(templateName), e); - } - - PsiFileFactory factory = PsiFileFactory.getInstance(directory.getProject()); - PsiFile file = factory.createFileFromText(fileName, text); - return (PsiFile) directory.add(file); - } - } diff --git a/src/schemely/psi/impl/symbols/SchemeIdentifier.java b/src/schemely/psi/impl/symbols/SchemeIdentifier.java index 75a0d9e..948fc7d 100644 --- a/src/schemely/psi/impl/symbols/SchemeIdentifier.java +++ b/src/schemely/psi/impl/symbols/SchemeIdentifier.java @@ -6,7 +6,6 @@ import com.intellij.openapi.util.Iconable; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; -import com.intellij.psi.impl.source.resolve.ResolveCache; import com.intellij.psi.tree.IElementType; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; @@ -16,10 +15,6 @@ import schemely.lexer.TokenSets; import schemely.lexer.Tokens; import schemely.psi.impl.SchemePsiElementBase; -import schemely.psi.resolve.ResolveUtil; -import schemely.psi.resolve.SchemeResolveResult; -import schemely.psi.resolve.processors.ResolveProcessor; -import schemely.psi.resolve.processors.SymbolResolveProcessor; import schemely.psi.util.SchemePsiElementFactory; import schemely.psi.util.SchemePsiUtil; @@ -254,30 +249,4 @@ public String getNameString() { return getText(); } - - public static class IdentifierResolver implements ResolveCache.Resolver - { - @Override - public PsiElement resolve(PsiReference psiReference, boolean incompleteCode) - { - SchemeIdentifier schemeIdentifier = (SchemeIdentifier) psiReference; - if (ResolveUtil.getQuotingLevel(schemeIdentifier) != 0) - { - return null; - } - - String name = schemeIdentifier.getReferenceName(); - if (name == null) - { - return null; - } - - ResolveProcessor processor = new SymbolResolveProcessor(name); - - ResolveUtil.resolve(schemeIdentifier, processor); - - SchemeResolveResult[] results = processor.getCandidates(); - return results.length == 1 ? results[0].getElement() : null; - } - } } diff --git a/src/schemely/psi/resolve/completion/CompletionProcessor.java b/src/schemely/psi/resolve/completion/CompletionProcessor.java deleted file mode 100644 index 7642c70..0000000 --- a/src/schemely/psi/resolve/completion/CompletionProcessor.java +++ /dev/null @@ -1,20 +0,0 @@ -package schemely.psi.resolve.completion; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.ResolveState; -import schemely.psi.resolve.processors.SymbolResolveProcessor; - - -public class CompletionProcessor extends SymbolResolveProcessor -{ - public CompletionProcessor() - { - super(null); - } - - public boolean execute(PsiElement element, ResolveState state) - { - super.execute(element, state); - return true; - } -} diff --git a/src/schemely/psi/resolve/processors/ResolveProcessor.java b/src/schemely/psi/resolve/processors/ResolveProcessor.java deleted file mode 100644 index abfd9fd..0000000 --- a/src/schemely/psi/resolve/processors/ResolveProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -package schemely.psi.resolve.processors; - -import com.intellij.psi.scope.ElementClassHint; -import com.intellij.psi.scope.NameHint; -import com.intellij.psi.scope.PsiScopeProcessor; -import com.intellij.util.containers.HashSet; -import schemely.psi.resolve.SchemeResolveResult; - - -public abstract class ResolveProcessor implements PsiScopeProcessor, NameHint, ElementClassHint -{ - protected HashSet candidates = new HashSet(); - protected final String name; - - public ResolveProcessor(String name) - { - this.name = name; - } - - public SchemeResolveResult[] getCandidates() - { - return candidates.toArray(new SchemeResolveResult[candidates.size()]); - } - - public void handleEvent(Event event, Object o) - { - } -} diff --git a/src/schemely/psi/resolve/processors/SymbolResolveProcessor.java b/src/schemely/psi/resolve/processors/SymbolResolveProcessor.java deleted file mode 100644 index 2943989..0000000 --- a/src/schemely/psi/resolve/processors/SymbolResolveProcessor.java +++ /dev/null @@ -1,57 +0,0 @@ -package schemely.psi.resolve.processors; - -import com.intellij.openapi.util.Key; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNamedElement; -import com.intellij.psi.ResolveState; -import com.intellij.psi.scope.NameHint; -import schemely.psi.resolve.SchemeResolveResult; - -import java.util.HashSet; -import java.util.Set; - - -public class SymbolResolveProcessor extends ResolveProcessor -{ - private final Set processedElements = new HashSet(); - - public SymbolResolveProcessor(String name) - { - super(name); - } - - public boolean execute(PsiElement element, ResolveState resolveState) - { - if ((element instanceof PsiNamedElement) && !processedElements.contains(element)) - { - PsiNamedElement namedElement = (PsiNamedElement) element; - - candidates.add(new SchemeResolveResult(namedElement)); - processedElements.add(namedElement); - - return false; - } - - return true; - } - - @Override - public T getHint(Key hintKey) - { - if (hintKey.equals(NameHint.KEY)) - { - return (T) this; - } - return null; - } - - public String getName(ResolveState resolveState) - { - return name; - } - - public boolean shouldProcess(DeclarationKind kind) - { - return true; - } -} diff --git a/src/schemely/scheme/sisc/SISCConfigUtil.java b/src/schemely/scheme/sisc/SISCConfigUtil.java deleted file mode 100644 index 0ad94be..0000000 --- a/src/schemely/scheme/sisc/SISCConfigUtil.java +++ /dev/null @@ -1,16 +0,0 @@ -package schemely.scheme.sisc; - -import com.intellij.openapi.application.PathManager; - -import java.io.File; - -/** - * @author Colin Fleming - */ -public class SISCConfigUtil -{ - public static String getJarPathForResource(Class aClass, String resourceName) { - String resourceRoot = PathManager.getResourceRoot(aClass, '/' + resourceName); - return new File(resourceRoot).getAbsoluteFile().getAbsolutePath(); - } -} diff --git a/src/schemely/scheme/sisc/psi/SISCFile.java b/src/schemely/scheme/sisc/psi/SISCFile.java index fade39c..e150b18 100644 --- a/src/schemely/scheme/sisc/psi/SISCFile.java +++ b/src/schemely/scheme/sisc/psi/SISCFile.java @@ -14,7 +14,6 @@ import com.intellij.util.PathUtil; import org.jetbrains.annotations.NotNull; import schemely.psi.impl.SchemeFile; -import schemely.scheme.sisc.SISCConfigUtil; import java.util.Arrays; import java.util.Collection; @@ -24,28 +23,6 @@ */ public class SISCFile extends SchemeFile { - private static final Collection bootFiles = Arrays.asList(// These are from the heap - "sisc/boot/init.scm", - "sisc/boot/compat.scm", - "sisc/boot/analyzer.scm", - "sisc/boot/eval.scm", - "sisc/boot/init2.scm", - "sisc/boot/repl.scm", - "sisc/boot/psyntax.ss", - "sisc/boot/psyntax.scm", - // TODO maybe control if we load this - "sisc/modules/std-modules.scm", - // Natively supported SRFIs - "sisc/libs/srfi/srfi-0.scm", - "sisc/libs/srfi/srfi-7.scm", - "sisc/libs/srfi/srfi-22.scm", - "sisc/libs/srfi/srfi-28.scm", - "sisc/libs/srfi/srfi-30.scm", - "sisc/libs/srfi/srfi-39.scm", - "sisc/libs/srfi/srfi-48.scm", - "sisc/libs/srfi/srfi-55.scm", - "sisc/libs/srfi/srfi-62.scm"); - public SISCFile(FileViewProvider viewProvider) { super(viewProvider); @@ -62,33 +39,6 @@ public boolean processDeclarations(@NotNull PsiScopeProcessor processor, return false; } - String sourcePath = SISCConfigUtil.getJarPathForResource(sisc.REPL.class, "sisc/boot/repl.scm"); - String sourceURL = VfsUtil.pathToUrl(sourcePath); - VirtualFile sourceFile = VirtualFileManager.getInstance().findFileByUrl(sourceURL); - if (sourceFile != null) - { - VirtualFile jarFile = JarFileSystem.getInstance().getJarRootForLocalFile(sourceFile); - if (jarFile != null) - { - for (String bootFile : bootFiles) - { - VirtualFile file = jarFile.findFileByRelativePath(bootFile); - if (file != null) - { - PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file); - if (psiFile instanceof SchemeFile) - { - SchemeFile schemeFile = (SchemeFile) psiFile; - if (!schemeFile.processTopLevelDefinitions(processor, state, lastParent, place)) - { - return false; - } - } - } - } - } - } - String url = VfsUtil.pathToUrl(PathUtil.getJarPathForClass(SISCFile.class)); VirtualFile sdkFile = VirtualFileManager.getInstance().findFileByUrl(url); if (sdkFile != null)