/*++

NASM Assembly Language Plugin
Copyright (c) 2017-2018 Aidan Khoury. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

--*/

package com.nasmlanguage;

import com.intellij.lang.BracePair;
import com.intellij.lang.PairedBraceMatcher;
import com.intellij.psi.PsiFile;
import com.intellij.psi.tree.IElementType;
import com.nasmlanguage.psi.NASMTypes;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class NASMPairedBraceMatcher implements PairedBraceMatcher {
    private static final BracePair[] BRACE_PAIRS = new BracePair[]{
            new BracePair(NASMTypes.SQUARE_L, NASMTypes.SQUARE_R, true),
            new BracePair(NASMTypes.ROUND_L, NASMTypes.ROUND_R, false),
            new BracePair(NASMTypes.MACRO_TAG, NASMTypes.MACRO_END_TAG, true),
            new BracePair(NASMTypes.STRUC_TAG, NASMTypes.ENDSTRUC_TAG, true),
            new BracePair(NASMTypes.ISTRUC_TAG, NASMTypes.IEND_TAG, true),
            new BracePair(NASMTypes.IF_TAG, NASMTypes.ENDIF_TAG, true),
            new BracePair(NASMTypes.IFMACRO_TAG, NASMTypes.ENDIF_TAG, true)
            //new BracePair(NASMTypes.ELIF_TAG, NASMTypes.ENDIF_TAG, false),
            //new BracePair(NASMTypes.ELSE_TAG, NASMTypes.ENDIF_TAG, false)
    };

    @NotNull
    @Override
    public BracePair[] getPairs() {
        return BRACE_PAIRS;
    }

    @Override
    public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType lbraceType, @Nullable IElementType type) {
        return true;
    }

    @Override
    public int getCodeConstructStart(PsiFile file, int openingBraceOffset) {
        return openingBraceOffset;
    }
}

@@ -69,340 +69,605 @@
 oury
-. All rights reserved.%0A%0AThis program is free software: you can redistribute it and/or modify%0Ait under the terms of the GNU General Public License as published by%0Athe Free Software Foundation, either v
+%0A%0APermission is hereby granted, free of charge, to any person obtaining a copy%0Aof this software and associated documentation files (the %22Software%22), to deal%0Ain the Software without restriction, including without limitation the rights%0Ato use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0Acopies of the Software, and to permit p
 ers
-i
 on
- 3 of the License, or%0A(at your option) any later version.
+s to whom the Software is%0Afurnished to do so, subject to the following conditions:
 %0A%0ATh
-is program is distributed in the hope that it will be useful,%0Abut
+e above copyright notice and this permission notice shall be included in all%0Acopies or substantial portions of the Software.%0A%0ATHE SOFTWARE IS PROVIDED %22AS IS%22,
  WIT
@@ -675,59 +675,97 @@
 OUT 
+WARR
 AN
+T
 Y 
-WARRANTY; without even the implied warranty of%0A
+OF ANY KIND, EXPRESS OR%0AIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 MERC
@@ -775,20 +775,18 @@
 TABILITY
- or 
+,%0A
 FITNESS 
@@ -813,199 +813,287 @@
 POSE
-.  See the%0AGNU General Public License for more details.%0A%0AYou should have received a copy of the GNU General Public License%0Aalong with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E
+ AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0AAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0ALIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0AOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE%0ASOFTWARE
 .%0A%0A-

Update copyright notice with MIT license