// Path: src/com/equadon/intellij/mips/icons/MipsIcons.java
// public interface MipsIcons {
//   Icon FILE = IconLoader.getIcon("/icons/mips-file-16.png");
//   Icon LABEL = IconLoader.getIcon("/icons/mips-label-16.png");
//   Icon DIRECTIVE = IconLoader.getIcon("/icons/mips-directive-16.png");
//   Icon INSTRUCTION = IconLoader.getIcon("/icons/mips-instruction-16.png");
// }
// 
// Path: src/com/equadon/intellij/mips/lang/psi/MipsFile.java
// public interface MipsFile extends PsiFile {
//   Collection<MipsLabelDefinition> getLabelDefinitions();
// }


import com.equadon.intellij.mips.icons.MipsIcons;
import com.equadon.intellij.mips.lang.psi.MipsFile;
import com.equadon.intellij.mips.lang.psi.MipsLabelDefinition;
import com.intellij.codeInsight.completion.CompletionContributor;
import com.intellij.codeInsight.completion.CompletionParameters;
import com.intellij.codeInsight.completion.CompletionProvider;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.completion.CompletionType;
import com.intellij.codeInsight.completion.InsertHandler;
import com.intellij.codeInsight.completion.InsertionContext;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mars.Globals;
import mars.assembler.Directives;
import mars.mips.instructions.Instruction;
import static com.intellij.patterns.PlatformPatterns.psiElement;
/*
 * Copyright 2017 Niklas Persson
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.equadon.intellij.mips.completion;






public class MipsCompletionContributor extends CompletionContributor {
  private static final Pattern INSTRUCTION_ID = Pattern.compile("^([^\\d]+)\\d{3} $");

  public MipsCompletionContributor() {
    // Completion for directives and instructions
// Path: src/com/equadon/intellij/mips/icons/MipsIcons.java
// public interface MipsIcons {
//   Icon FILE = IconLoader.getIcon("/icons/mips-file-16.png");
//   Icon LABEL = IconLoader.getIcon("/icons/mips-label-16.png");
//   Icon DIRECTIVE = IconLoader.getIcon("/icons/mips-directive-16.png");
//   Icon INSTRUCTION = IconLoader.getIcon("/icons/mips-instruction-16.png");
// }
// 
// Path: src/com/equadon/intellij/mips/lang/psi/MipsFile.java
// public interface MipsFile extends PsiFile {
//   Collection<MipsLabelDefinition> getLabelDefinitions();
// }


// Path: src/com/equadon/intellij/mips/completion/MipsCompletionContributor.java
import com.equadon.intellij.mips.icons.MipsIcons;
import com.equadon.intellij.mips.lang.psi.MipsFile;
import com.equadon.intellij.mips.lang.psi.MipsLabelDefinition;
import com.intellij.codeInsight.completion.CompletionContributor;
import com.intellij.codeInsight.completion.CompletionParameters;
import com.intellij.codeInsight.completion.CompletionProvider;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.completion.CompletionType;
import com.intellij.codeInsight.completion.InsertHandler;
import com.intellij.codeInsight.completion.InsertionContext;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import mars.Globals;
import mars.assembler.Directives;
import mars.mips.instructions.Instruction;
import static com.intellij.patterns.PlatformPatterns.psiElement;

/*
 * Copyright 2017 Niklas Persson
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.equadon.intellij.mips.completion;






public class MipsCompletionContributor extends CompletionContributor {
  private static final Pattern INSTRUCTION_ID = Pattern.compile("^([^\\d]+)\\d{3} $");

  public MipsCompletionContributor() {
    // Completion for directives and instructions
    extend(CompletionType.BASIC, psiElement().withParent(MipsFile.class), new CompletionProvider<CompletionParameters>() {